AnthropicEndpoint

Wisej.AI.Endpoints.AnthropicEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI (3.5.0.0)

Represents an endpoint for connecting to Anthropic services.

public class AnthropicEndpoint : SmartHttpEndpoint

This class is used to configure and manage connections to Anthropic endpoints, providing methods to send messages and handle responses. It inherits from SmartHttpEndpoint.

Constructors

AnthropicEndpoint()

Initializes a new instance of the AnthropicEndpoint 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 by the Anthropic endpoint. (Default: "claude-3-5-sonnet-20241022")

URL

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

Methods

AddMessages(payload, session, messages)

Adds messages to the payload for the Anthropic API request.

Parameter
Type
Description

payload

The payload to be sent.

session

The current session.

messages

The list of messages to include.

Prepares the system message and other messages for the API request.Throws:

AddOptions(message, session)

Adds options to the message before sending it to the Anthropic endpoint.

Parameter
Type
Description

message

The message to be sent.

session

The current session.

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

BuildMessage(message)

Builds a message object for the Anthropic API.

Parameter
Type
Description

message

The message to be converted.

Returns: Object. An object representing the message for the API.

Handles different input types, including text and images.Throws:

ReadAssistantMessage(response, message)

Reads the assistant's message from the response.

Parameter
Type
Description

response

The response from the API.

message

The message object to populate.

Parses the response content and updates the message text.Throws:

ReadUsage(message, reply)

Reads the usage information from the API reply.

Parameter
Type
Description

message

The message object to update.

reply

The dynamic reply object from the API.

Last updated