agentscope.models.anthropic_model
The Anthropic model wrapper for AgentScope.
- class AnthropicChatWrapper(model_name: str, config_name: str | None = None, api_key: str | None = None, stream: bool = False, client_kwargs: dict | None = None)[source]
Bases:
ModelWrapperBase
The Anthropic model wrapper for AgentScope.
- format(*args: Msg | list[Msg] | None, multi_agent_mode: bool = True) list[dict[str, object]] [source]
Format the messages for anthropic model input.
- Parameters:
*args (Union[Msg, list[Msg], None]) – The message(s) to be formatted. The None input will be ignored.
multi_agent_mode (bool, defaults to True) – Formatting the messages in multi-agent mode or not. If false, the messages will be formatted in chat mode, where only a user and an assistant roles are involved.
- Returns:
A list of formatted messages.
- Return type:
list[dict[str, object]]
- format_tools_json_schemas(schemas: dict[str, dict]) list[dict] [source]
Format the JSON schemas of the tool functions to the format that the model API provider expects.
Example
An example of the input schemas parsed from the service toolkit
..code-block:: json
- {
- “bing_search”: {
“type”: “function”, “function”: {
“name”: “bing_search”, “description”: “Search the web using Bing.”, “parameters”: {
“type”: “object”, “properties”: {
- “query”: {
“type”: “string”, “description”: “The search query.”,
}
}, “required”: [“query”],
}
}
}
}
- Parameters:
schemas (dict[str, dict]) – The tools JSON schemas parsed from the service toolkit module, which can be accessed by service_toolkit.json_schemas.
- Returns:
The formatted JSON schemas of the tool functions.
- Return type:
list[dict]
- config_name: str
The name of the model configuration.
- model_name: str
The name of the model, which is used in model api calling.
- model_type: str = 'anthropic_chat'
The type of the model wrapper, which is to identify the model wrapper class in model configuration.