Skip to main content

AmazonBedrockEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI

Represents an endpoint for connecting to Amazon Bedrock services.

public class AmazonBedrockEndpoint : SmartHttpEndpoint

This class is used to configure and manage connections to Amazon Bedrock endpoints, specifically for interacting with the Anthropic API.

Constructors​

AmazonBedrockEndpoint()​

Initializes a new instance of the AmazonBedrockEndpoint class.

Sets default values for authentication, model, URL, and headers.

Properties​

Authentication​

String: Gets or sets the authentication method for the endpoint. (Default: "x-api-key")

Model​

String: Gets or sets the model used for the endpoint. (Default: "claude-3-opus-20240229")

URL​

String: Gets or sets the URL for the endpoint. (Default: "https://api.anthropic.com/v1/messages")

Methods​

AddMessages(payload, session, messages)​

Adds messages to the payload.

ParameterTypeDescription
payloadObjectThe payload to which messages are added.
sessionSmartSessionThe current session context.
messagesIList<Message>The list of messages to add.

Ensures the system message is complete and prepares the payload for sending.

AddOptions(message, session)​

Adds options to the message payload.

ParameterTypeDescription
messageObjectThe message payload to modify.
sessionSmartSessionThe current session context.

Sets default values for temperature and max tokens in the message payload.

BuildMessage(message)​

Builds a message object from a Message instance.

ParameterTypeDescription
messageMessageThe message to convert.

Returns: Object. A dynamic object representing the message.

Handles different input types, including text and images.

ReadAssistantMessage(response, message)​

Reads the assistant's message from the response.

ParameterTypeDescription
responseResponseThe response containing the assistant's message.
messageMessageThe message object to populate.

Parses the response stream to extract the assistant's message content.

ReadUsage(message, reply)​

Reads the usage information from the reply.

ParameterTypeDescription
messageMessageThe message object to update with usage data.
replyObjectThe dynamic reply object containing usage information.