agentscope.models.anthropic_model module

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)[源代码]

基类:ModelWrapperBase

The Anthropic model wrapper for AgentScope.

format(*args: Msg | list[Msg] | None, multi_agent_mode: bool = True) list[dict[str, object]][源代码]

Format the messages for anthropic model input.

参数:
  • *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.

返回:

A list of formatted messages.

返回类型:

list[dict[str, object]]

format_tools_json_schemas(schemas: dict[str, dict]) list[dict][源代码]

Format the JSON schemas of the tool functions to the format that the model API provider expects.

示例

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"],

}

}

}

}

参数:

schemas (dict[str, dict]) -- The tools JSON schemas parsed from the service toolkit module, which can be accessed by service_toolkit.json_schemas.

返回:

The formatted JSON schemas of the tool functions.

返回类型:

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.