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
@deprecated(
"This class will be removed in a future version. Use {} which is TypedDict."
)
@dataclass
class TraceConfig()
Trace config.
This class represents a trace config.
class TraceConfigDict(TypedDict)
Trace config dict.
This class represents a trace config dictionary.
get_trace_config_dict
def get_trace_config_dict(
config: Union[TraceConfig, TraceConfigDict]) -> TraceConfigDict
Convert a TraceConfig object to a TraceConfigDict.
Arguments:
| Name | Description |
|---|
config | Either a TraceConfig object or a TraceConfigDict dictionary. |
Returns:
A TraceConfigDict dictionary representation of the config.
class Trace(EventEmittingBaseContainer)
A class representing a trace in the logging system.
A trace is a high-level container for tracking a complete operation or workflow.
__init__
def __init__(config: Union[TraceConfig, TraceConfigDict], writer: LogWriter)
Initialize a new Trace instance.
Arguments:
| Name | Description |
|---|
config | Configuration for the trace, either as a TraceConfig object or a TraceConfigDict. |
writer | The LogWriter instance to use for writing log entries. |
def set_input(input: str)
Set the input for this trace.
Arguments:
| Name | Description |
|---|
input | The input string to set. |
@staticmethod
def set_input_(writer: LogWriter, trace_id: str, input: str)
Static method to set the input for a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to update. |
input | The input string to set. |
set_output
def set_output(output: str)
Set the output for this trace.
Arguments:
| Name | Description |
|---|
output | The output string to set. |
set_output_
@staticmethod
def set_output_(writer: LogWriter, trace_id: str, output: str)
Static method to set the output for a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to update. |
output | The output string to set. |
generation
def generation(
config: Union[GenerationConfig, GenerationConfigDict]) -> Generation
Add a generation to this trace.
Arguments:
| Name | Description |
|---|
config | Configuration for the generation. |
Returns:
A new Generation instance.
def tool_call(config: Union[ToolCallConfig, ToolCallConfigDict]) -> ToolCall
Add a tool call to this trace.
Arguments:
| Name | Description |
|---|
config | Configuration for the tool call. |
Returns:
A new ToolCall instance.
@staticmethod
def tool_call_(writer: LogWriter, trace_id: str,
config: Union[ToolCallConfig, ToolCallConfigDict]) -> ToolCall
Static method to add a tool call to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the tool call to. |
config | Configuration for the tool call. |
Returns:
A new ToolCall instance.
generation_
@staticmethod
def generation_(
writer: LogWriter, trace_id: str,
config: Union[GenerationConfig, GenerationConfigDict]) -> Generation
Static method to add a generation to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the generation to. |
config | Configuration for the generation. |
Returns:
A new Generation instance.
add_error
def add_error(config: ErrorConfig) -> Error
Add an error to this trace.
Arguments:
| Name | Description |
|---|
config | Configuration for the error. |
Returns:
A new Error instance.
error_
@staticmethod
def error_(writer: LogWriter, trace_id: str, config: ErrorConfig) -> Error
Static method to add an error to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the error to. |
config | Configuration for the error. |
Returns:
A new Error instance.
retrieval
def retrieval(config: Union[RetrievalConfig, RetrievalConfigDict])
Add a retrieval to this trace.
Arguments:
| Name | Description |
|---|
config | Configuration for the retrieval. |
Returns:
A new Retrieval instance.
retrieval_
@staticmethod
def retrieval_(writer: LogWriter, trace_id: str,
config: Union[RetrievalConfig, RetrievalConfigDict])
Static method to add a retrieval to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the retrieval to. |
config | Configuration for the retrieval. |
Returns:
A new Retrieval instance.
span
def span(config: Union["SpanConfig", "SpanConfigDict"]) -> "Span"
Add a span to this trace.
Arguments:
| Name | Description |
|---|
config | Configuration for the span. |
Returns:
A new Span instance.
span_
@staticmethod
def span_(writer: LogWriter, trace_id: str,
config: Union["SpanConfig", "SpanConfigDict"]) -> "Span"
Static method to add a span to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the span to. |
config | Configuration for the span. |
Returns:
A new Span instance.
feedback
def feedback(feedback: Union[Feedback, FeedbackDict])
Add feedback to this trace.
Arguments:
| Name | Description |
|---|
feedback | The feedback to add. |
feedback_
@staticmethod
def feedback_(writer: LogWriter, trace_id: str, feedback: Union[Feedback,
FeedbackDict])
Static method to add feedback to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the feedback to. |
feedback | The feedback to add. |
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 tag key. |
value | The tag value. |
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, trace_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. |
trace_id | The ID of the trace to add the attachment to. |
attachment | The attachment to add. |
end_
@staticmethod
def end_(writer: LogWriter,
trace_id: str,
data: Optional[Dict[str, str]] = None)
Static method to end a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to end. |
data | Additional data to include in the end event. |
Returns:
The result of the end operation.
event_
@staticmethod
def event_(writer: LogWriter,
trace_id: str,
id: str,
event: str,
tags: Optional[Dict[str, str]] = None,
metadata: Optional[Dict[str, Any]] = None)
Static method to add a custom event to a trace.
Arguments:
| Name | Description |
|---|
writer | The LogWriter instance to use. |
trace_id | The ID of the trace to add the event to. |
id | The ID of the event. |
event | The name of the event. |
tags | Optional tags to associate with the event. |
metadata | Optional metadata to include with the event. |
Returns:
The result of the event operation.
data
def data() -> Dict[str, Any]
Get the data representation of this trace.
Returns:
A dictionary containing the trace data.