CompletionReceived

org.llm4s.trace.TraceEvent.CompletionReceived
See theCompletionReceived companion object
final case class CompletionReceived extends TraceEvent

A model returned a completion. A client wrapped in TracingLLMClient fills in the call's details as well, which a backend that follows the OpenTelemetry GenAI conventions reports on the call's chat <model> span (#2275).

Value parameters

content

the completion's text: message content, which backends record only when told to

duration

how long the call took; the event's timestamp is its end

finishReasons

why the model stopped, as the provider reported it

id

the completion's id (gen_ai.response.id)

input

the request's messages: message content, which backends record only when told to; not included in toJson

model

the requested model (gen_ai.request.model)

options

the options the request was sent with

provider

the canonical id of the provider called (openai, anthropic, ...), when known

responseModel

the model that answered, when the provider reported it

serverAddress

the host the request went to, when known

streamed

whether the completion was streamed (streamComplete)

toolCalls

how many tool calls the completion asked for

usage

the call's token usage, when the provider reported it

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def eventType: String
def toJson: Value
def withContent(content: String): CompletionReceived
def withDuration(duration: FiniteDuration): CompletionReceived
def withDuration(duration: Option[FiniteDuration]): CompletionReceived
def withFinishReasons(finishReasons: Seq[String]): CompletionReceived
def withId(id: String): CompletionReceived
def withModel(model: String): CompletionReceived
def withProvider(provider: Option[ProviderId]): CompletionReceived
def withResponseModel(responseModel: String): CompletionReceived
def withResponseModel(responseModel: Option[String]): CompletionReceived
def withServerAddress(serverAddress: String): CompletionReceived
def withServerAddress(serverAddress: Option[String]): CompletionReceived
def withStreamed(streamed: Boolean): CompletionReceived
def withTimestamp(timestamp: Instant): CompletionReceived
def withToolCalls(toolCalls: Int): CompletionReceived
def withUsage(usage: Option[TokenUsage]): CompletionReceived

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def span: Option[TraceSpan]

Where this event sits in a trace, when its emitter places it in one (design 4.58): the span it is, that span's parent and when it started; the event's timestamp is its end. None for an event traced on its own. Only TraceEvent.CustomEvent, TraceEvent.TokenUsageRecorded, TraceEvent.ErrorOccurred and TraceEvent.AgentRunEnded carry one.

Where this event sits in a trace, when its emitter places it in one (design 4.58): the span it is, that span's parent and when it started; the event's timestamp is its end. None for an event traced on its own. Only TraceEvent.CustomEvent, TraceEvent.TokenUsageRecorded, TraceEvent.ErrorOccurred and TraceEvent.AgentRunEnded carry one.

Attributes

Inherited from:
TraceEvent