anthropic
autogen.oai.anthropic.AnthropicClient
AnthropicClient
Initialize the Anthropic API client.
Name | Description |
---|---|
**kwargs | Type: Any |
Instance Attributes
api_key
aws_access_key
aws_region
aws_secret_key
aws_session_token
gcp_auth_token
gcp_project_id
gcp_region
Instance Methods
convert_tools_to_functions
Convert tool definitions into Anthropic-compatible functions,
updating nested $ref paths in property schemas.
Name | Description |
---|---|
tools | List of tool definitions. Type: list |
Type | Description |
---|---|
list | list: List of functions with updated $ref paths. |
cost
Calculate the cost of the completion using the Anthropic pricing.
Parameters:Name | Description |
---|---|
response |
create
Creates a completion using the Anthropic API.
Parameters:Name | Description |
---|---|
params | Type: dict[str, Any] |
get_usage
Get the usage of tokens and their cost information.
Parameters:Name | Description |
---|---|
response | Type: ChatCompletion |
load_config
Load the configuration for the Anthropic API client.
Parameters:Name | Description |
---|---|
params | Type: dict[str, Any] |
message_retrieval
Retrieve and return a list of strings or a list of Choice.Message from the response.
NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI’s ChatCompletion Message object,
since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.
Name | Description |
---|---|
response |
openai_func_to_anthropic
Name | Description |
---|---|
openai_func | Type: dict |