View module source on GitHub

MaximBedrockClient

class MaximBedrockClient()

Maxim Bedrock client wrapper.

This class provides a wrapper around the Bedrock client to integrate with Maxim’s logging and monitoring capabilities. It allows tracking and logging of Bedrock API interactions through the Maxim platform.

__init__

def __init__(logger: Logger, client: BaseClient)

Initialize the Maxim Bedrock client.

Arguments:

NameTypeDescription
loggerLoggerThe Maxim logger instance for tracking interactions.
clientBaseClientThe Bedrock client instance to wrap.

converse_stream

def converse_stream(messages: Iterable[BedrockMessageParam],
                    system: Optional[Union[str, List[Dict[str, str]]]] = None,
                    *,
                    modelId: str,
                    max_tokens: Optional[int] = None,
                    trace_id: Optional[str] = None,
                    generation_name: Optional[str] = None,
                    inferenceConfig: Optional[Dict[str, Any]] = None,
                    toolConfig: Optional[Dict[str, Any]] = None,
                    guardrailConfig: Optional[Dict[str, Any]] = None,
                    performanceConfig: Optional[Dict[str, Any]] = None,
                    additionalModelRequestFields: Optional[Dict[str,
                                                                Any]] = None,
                    **kwargs: Any) -> Iterator[BedrockStreamEvent]

Converse with the Bedrock client.

Arguments:

NameTypeDescription
messagesIterable[BedrockMessageParam]The messages to send to the Bedrock client.
systemOptional[Union[str, List[Dict[str, str]]]]The system message to send to the Bedrock client.
modelIdstrThe model ID to use for the Bedrock client.
max_tokensOptional[int]The maximum number of tokens to generate.
trace_idOptional[str]The trace ID to use for the Bedrock client.
generation_nameOptional[str]The name of the generation to use for the Bedrock client.
inferenceConfigOptional[Dict[str, Any]]The inference configuration to use for the Bedrock client.
toolConfigOptional[Dict[str, Any]]The tool configuration to use for the Bedrock client.
guardrailConfigOptional[Dict[str, Any]]The guardrail configuration to use for the Bedrock client.
performanceConfigOptional[Dict[str, Any]]The performance configuration to use for the Bedrock client.
additionalModelRequestFieldsOptional[Dict[str, Any]]The additional model request fields to use for the Bedrock client.

Returns:

NameDescription
Iterator[BedrockStreamEvent]An iterator over the Bedrock stream events.

converse

def converse(messages: Iterable[BedrockMessageParam],
             system: Optional[Union[str, List[Dict[str, str]]]] = None,
             *,
             modelId: str,
             max_tokens: Optional[int] = None,
             trace_id: Optional[str] = None,
             generation_name: Optional[str] = None,
             inferenceConfig: Optional[Dict[str, Any]] = None,
             toolConfig: Optional[Dict[str, Any]] = None,
             guardrailConfig: Optional[Dict[str, Any]] = None,
             performanceConfig: Optional[Dict[str, Any]] = None,
             additionalModelRequestFields: Optional[Dict[str, Any]] = None,
             **kwargs: Any) -> BedrockMessage

Converse with the Bedrock client.

Arguments:

NameTypeDescription
messagesIterable[BedrockMessageParam]The messages to send to the Bedrock client.
systemOptional[Union[str, List[Dict[str, str]]]]The system message to send to the Bedrock client.
modelIdstrThe model ID to use for the Bedrock client.
max_tokensOptional[int]The maximum number of tokens to generate.
trace_idOptional[str]The trace ID to use for the Bedrock client.
generation_nameOptional[str]The name of the generation to use for the Bedrock client.
inferenceConfigOptional[Dict[str, Any]]The inference configuration to use for the Bedrock client.
toolConfigOptional[Dict[str, Any]]The tool configuration to use for the Bedrock client.
guardrailConfigOptional[Dict[str, Any]]The guardrail configuration to use for the Bedrock client.
performanceConfigOptional[Dict[str, Any]]The performance configuration to use for the Bedrock client.
additionalModelRequestFieldsOptional[Dict[str, Any]]The additional model request fields to use for the Bedrock client.

Returns:

NameDescription
BedrockMessageThe response from the Bedrock client.

async_client

@property
def async_client() -> MaximBedrockAsyncClient

Get the async client.

Returns:

NameDescription
[MaximBedrockAsyncClient](/sdk/python/references/logger/bedrock/async_client)The async client.