agentscope.models.model

The model wrapper base class.

class ModelWrapperBase(config_name: str | None = None, model_name: str | None = None, **kwargs: Any)[source]

Bases: ABC

The base class for model wrapper.

format(*args: Msg | list[Msg] | None, multi_agent_mode: bool = True) List[dict] | str[source]

Format the input messages into the format that the model API required.

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

The type of the model wrapper, which is to identify the model wrapper class in model configuration.