Documentation Index
Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
View module source on GitHub
class GenerationRequestTextMessageContent(TypedDict)
This class is used to represent a text message in a generation request.
class GenerationRequestImageMessageContent(TypedDict)
This class is used to represent an image message in a generation request.
class GenerationRequestMessage(TypedDict)
This class is used to represent a message in a generation request.
class GenerationConfigDict(TypedDict)
Generation config dict.
This class represents a generation config dictionary.
get_generation_config_dict
def get_generation_config_dict(
config: Union[GenerationConfig,
GenerationConfigDict]) -> dict[str, Any]
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.
class GenerationToolCallFunction(TypedDict)
Generation tool call function.
This class represents a tool call function.
class GenerationToolCall(TypedDict)
Generation tool call.
This class represents a tool call.
class TextContent(TypedDict)
Text content.
This class represents a text content.
class ImageContent(TypedDict)
Image content.
This class represents an image content.
class AudioContent(TypedDict)
Audio content.
This class represents an audio content.
class GenerationResultMessage(TypedDict)
Generation result message.
This class represents a generation result message.
class GenerationResultChoice(TypedDict)
Generation result choice.
This class represents a generation result choice.
class TokenDetails(TypedDict)
Token details.
This class represents token details.
class GenerationUsage(TypedDict)
Generation usage.
This class represents generation usage.
class GenerationResult(TypedDict)
Generation result.
This class represents a generation result.
get_generation_error_config_dict
def get_generation_error_config_dict(
config: Union[GenerationError, GenerationErrorTypedDict]
) -> GenerationErrorTypedDict
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.
class Generation(BaseContainer)
__init__
def __init__(config: Union[GenerationConfig, GenerationConfigDict],
writer: LogWriter)
Initialize a generation.
Arguments:
| Name | Description |
|---|
config | The config to initialize the generation with. |
writer | The writer to use. |
set_provider_
@staticmethod
def set_provider_(writer: LogWriter, id: str, provider: str)
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
def set_provider(provider: str)
Set the provider for this trace.
Arguments:
| Name | Description |
|---|
provider | The provider to set. |
set_model_
@staticmethod
def set_model_(writer: LogWriter, id: str, model: str)
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
def set_model(model: str)
Set the model for this trace.
Arguments:
| Name | Description |
|---|
model | The model to set. |
add_message_
@staticmethod
def add_message_(writer: LogWriter, id: str,
message: GenerationRequestMessage)
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
def add_message(message: GenerationRequestMessage) -> None
Add a message to this trace.
Arguments:
| Name | Description |
|---|
message | The message to add. |
set_model_parameters_
@staticmethod
def set_model_parameters_(writer: LogWriter, id: str,
model_parameters: Dict[str, Any])
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
def set_model_parameters(model_parameters: Dict[str, Any])
Set the model parameters for this trace.
Arguments:
| Name | Description |
|---|
model_parameters | The model parameters to set. |
add_attachment
def add_attachment(attachment: Union[FileAttachment, FileDataAttachment,
UrlAttachment])
Add an attachment to this trace.
Arguments:
| Name | Description |
|---|
attachment | The attachment to add. |
add_attachment_
@staticmethod
def add_attachment_(writer: LogWriter, generation_id: str,
attachment: Union[FileAttachment, FileDataAttachment,
UrlAttachment])
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_
@staticmethod
def result_(writer: LogWriter, id: str, result: Union[GenerationResult,
Dict[str, Any]])
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_
@staticmethod
def end_(writer: LogWriter, id: str, data: Optional[Dict[str, Any]] = None)
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_
@staticmethod
def add_tag_(writer: LogWriter, id: str, key: str, value: str)
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
@staticmethod
def convert_chat_completion(chat_completion: Dict[str, Any])
Convert a chat completion to a generation result.
Arguments:
| Name | Description |
|---|
chat_completion | The chat completion to convert. |
Returns:
A generation result.
convert_result
@staticmethod
def convert_result(
result: Union[Any, GenerationResult, Dict[str, Any]]
) -> Union[Any, GenerationResult, Dict[str, Any]]
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
def error(error: Union[GenerationError, GenerationErrorTypedDict])
Add an error to this trace.
Arguments:
| Name | Description |
|---|
error | The error to add. |
error_
@staticmethod
def error_(writer: LogWriter, id: str, error: Union[GenerationError,
GenerationErrorTypedDict])
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
def data() -> Dict[str, Any]
Get the data for this trace.
Returns:
A dictionary containing the data for this trace.