components.Generation
Generation functionality for Components integration.
GenerationRequestTextMessageContent
This class is used to represent a text message in a generation request.
GenerationRequestImageMessageContent
This class is used to represent an image message in a generation request.
GenerationRequestMessage
This class is used to represent a message in a generation request.
GenerationConfigDict
Generation config dict.
This class represents a generation config dictionary.
get_generation_config_dict
Convert a generation config to a generation config dict else return the config.
Arguments:
Name | Type | Description |
---|---|---|
config | Union[GenerationConfig, GenerationConfigDict] | The config to get the dict from. |
Returns:
dict[str, Any]: The generation config dict.
GenerationToolCallFunction
Generation tool call function.
This class represents a tool call function.
GenerationToolCall
Generation tool call.
This class represents a tool call.
TextContent
Text content.
This class represents a text content.
ImageContent
Image content.
This class represents an image content.
AudioContent
Audio content.
This class represents an audio content.
GenerationResultMessage
Generation result message.
This class represents a generation result message.
GenerationResultChoice
Generation result choice.
This class represents a generation result choice.
TokenDetails
Token details.
This class represents token details.
GenerationUsage
Generation usage.
This class represents generation usage.
GenerationResult
Generation result.
This class represents a generation result.
get_generation_error_config_dict
Convert a generation error to a generation error dict else return the error.
Arguments:
Name | Description |
---|---|
config | Either a TraceConfig object or a TraceConfigDict dictionary. |
Returns:
A TraceConfigDict dictionary representation of the config.
Generation
__init__
Initialize a generation.
Arguments:
Name | Description |
---|---|
config | The config to initialize the generation with. |
writer | The writer to use. |
set_provider_
Static method to set the provider for a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to set the provider for. |
provider | The provider to set. |
set_provider
Set the provider for this trace.
Arguments:
Name | Description |
---|---|
provider | The provider to set. |
set_model_
Static method to set the model for a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to set the model for. |
model | The model to set. |
set_model
Set the model for this trace.
Arguments:
Name | Description |
---|---|
model | The model to set. |
add_message_
Static method to add a message to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to add the message to. |
message | The message to add. |
add_message
Add a message to this trace.
Arguments:
Name | Description |
---|---|
message | The message to add. |
set_model_parameters_
Static method to set the model parameters for a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to set the model parameters for. |
model_parameters | The model parameters to set. |
set_model_parameters
Set the model parameters for this trace.
Arguments:
Name | Description |
---|---|
model_parameters | The model parameters to set. |
add_attachment
Add an attachment to this trace.
Arguments:
Name | Description |
---|---|
attachment | The attachment to add. |
add_attachment_
Static method to add an attachment to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
generation_id | The ID of the generation to add the attachment to. |
attachment | The attachment to add. |
result_
Static method to add a result to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to add the result to. |
result | The result to add. |
end_
Static method to end a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to end. |
data | The data to add to the trace. |
add_tag_
Static method to add a tag to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to add the tag to. |
key | The key of the tag to add. |
value | The value of the tag to add. |
convert_chat_completion
Convert a chat completion to a generation result.
Arguments:
Name | Description |
---|---|
chat_completion | The chat completion to convert. |
Returns:
A generation result.
convert_result
Convert a result to a generation result.
Arguments:
Name | Description |
---|---|
result | The result to convert. |
Returns:
A generation result.
result
Add a result to this trace.
Arguments:
Name | Description |
---|---|
result | The result to add. |
error
Add an error to this trace.
Arguments:
Name | Description |
---|---|
error | The error to add. |
error_
Static method to add an error to a trace.
Arguments:
Name | Description |
---|---|
writer | The LogWriter instance to use. |
id | The ID of the trace to add the error to. |
error | The error to add. |
data
Get the data for this trace.
Returns:
A dictionary containing the data for this trace.