GitHub

API reference for Service.

The client: an authenticated HttpClient for the Bedrock Runtime operations it does not model, and the Converse calls. make builds it; Service(client, converse, converse_stream) makes one of two functions (a test double, say).

Attributes

AttributeTypeDescription
clientHttpClientService[HttpClientError | AiError] = client

The underlying client with the base URL and authentication; resolving the credentials can fail with an AiError.

Functions

__init__

__init__(client, converse, converse_stream) -> None
ParameterTypeDescription
clientHttpClientService[HttpClientError | AiError]
converseCallable[[W.ConverseRequest], Effect[W.ConverseResponse, AiError]]
converse_streamCallable[[W.ConverseRequest], Stream[W.ConverseStreamEvent, AiError]]
def __init__(
    self,
    client: HttpClientService[HttpClientError | AiError],
    converse: Callable[[W.ConverseRequest], Effect[W.ConverseResponse, AiError]],
    converse_stream: Callable[[W.ConverseRequest], Stream[W.ConverseStreamEvent, AiError]],
) -> None:
    self.client = client
    self._converse = converse
    self._converse_stream = converse_stream

converse

converse(request) -> Effect[W.ConverseResponse, AiError]

The Converse operation: modelId names the model in the URL, the other fields are the body; an AmazonBedrockConfig in context transforms the client for this call.

ParameterTypeDescription
requestW.ConverseRequest

Returns Effect[W.ConverseResponse, AiError]

def converse(self, request: W.ConverseRequest) -> Effect[W.ConverseResponse, AiError]:
    """The Converse operation: ``modelId`` names the model in the URL,
    the other fields are the body; an ``AmazonBedrockConfig`` in context
    transforms the client for this call."""
    return self._converse(request)

converse_stream

converse_stream(request) -> Stream[W.ConverseStreamEvent, AiError]

The ConverseStream operation's decoded events.

ParameterTypeDescription
requestW.ConverseRequest

Returns Stream[W.ConverseStreamEvent, AiError]

def converse_stream(self, request: W.ConverseRequest) -> Stream[W.ConverseStreamEvent, AiError]:
    """The ConverseStream operation's decoded events."""
    return self._converse_stream(request)