🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
Auto-update documentation after merge [skip ci]
camel-docs-bot77a4ffe01cc7
diff --git a/docs/mintlify/reference/camel.configs.anthropic_config.mdx b/docs/mintlify/reference/camel.configs.anthropic_config.mdxindex d02cf1ec0..20c56402c 100644--- a/docs/mintlify/reference/camel.configs.anthropic_config.mdx+++ b/docs/mintlify/reference/camel.configs.anthropic_config.mdx@@ -23,5 +23,6 @@ See: https://docs.anthropic.com/en/api/messages- **stream** (bool, optional): Whether to incrementally stream the response using server-sent events. (default: :obj:`None`)- **metadata** (dict, optional): An object describing metadata about the request. Can include user_id as an external identifier for the user associated with the request. (default: :obj:`None`)- **tool_choice** (dict, optional): How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all. (default: :obj:`None`)+- **cache_control** (`Optional[Literal["5m", "1h"]], optional`): The cache control TTL for prompt caching. Use '5m' for 5-minute cache or '1h' for 1-hour cache. (default: :obj:`None`)- **extra_headers** (Optional[dict], optional): Additional headers for the request. (default: :obj:`None`)- **extra_body** (dict, optional): Extra body parameters to be passed to the Anthropic API.diff --git a/docs/mintlify/reference/camel.configs.openai_config.mdx b/docs/mintlify/reference/camel.configs.openai_config.mdxindex b48ae7b2e..75eb220ae 100644--- a/docs/mintlify/reference/camel.configs.openai_config.mdx+++ b/docs/mintlify/reference/camel.configs.openai_config.mdx@@ -29,4 +29,5 @@ OpenAI API.- **tool_choice** (Union[dict[str, str], str], optional): Controls which (if any) tool is called by the model. :obj:`"none"` means the model will not call any tool and instead generates a message. :obj:`"auto"` means the model can pick between generating a message or calling one or more tools. :obj:`"required"` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. :obj:`"none"` is the default when no tools are present. :obj:`"auto"` is the default if tools are present.- **reasoning_effort** (str, optional): A parameter specifying the level of reasoning used by certain model types. Valid values are :obj: `"low"`, :obj:`"medium"`, or :obj:`"high"`. If set, it is only applied to the model types that support it (e.g., :obj:`o1`, :obj:`o1mini`, :obj:`o1preview`, :obj:`o3mini`). If not provided or if the model type does not support it, this parameter is ignored. (default: :obj:`None`)- **parallel_tool_calls** (bool, optional): A parameter specifying whether the model should call tools in parallel or not. (default: :obj:`None`)+- **prompt_cache_key** (str, optional): A key used by the OpenAI Prompt Caching system to identify and reuse cached prompt segments. (default: :obj:`None`)- **extra_headers**: Optional[Dict[str, str]]: Extra headers to use for the model. (default: :obj:`None`)diff --git a/docs/mintlify/reference/camel.models.anthropic_model.mdx b/docs/mintlify/reference/camel.models.anthropic_model.mdxindex 39338c117..6623a5298 100644--- a/docs/mintlify/reference/camel.models.anthropic_model.mdx+++ b/docs/mintlify/reference/camel.models.anthropic_model.mdx@@ -26,20 +26,23 @@ removed## AnthropicModel```python-class AnthropicModel(OpenAICompatibleModel):+class AnthropicModel(BaseModelBackend):```-Anthropic API in a unified OpenAICompatibleModel interface.+Anthropic API in a unified BaseModelBackend interface.**Parameters:**- **model_type** (Union[ModelType, str]): Model for which a backend is created, one of CLAUDE_* series.-- **model_config_dict** (Optional[Dict[str, Any]], optional): A dictionary that will be fed into `openai.ChatCompletion.create()`. If :obj:`None`, :obj:`AnthropicConfig().as_dict()` will be used. (default: :obj:`None`)+- **model_config_dict** (Optional[Dict[str, Any]], optional): A dictionary that will be fed into Anthropic API. If :obj:`None`, :obj:`AnthropicConfig().as_dict()` will be used. (default: :obj:`None`)- **api_key** (Optional[str], optional): The API key for authenticating with the Anthropic service. (default: :obj:`None`)-- **url** (Optional[str], optional): The url to the Anthropic service. (default: :obj:`https://api.anthropic.com/v1/`)+- **url** (Optional[str], optional): The url to the Anthropic service. (default: :obj:`None`)- **token_counter** (Optional[BaseTokenCounter], optional): Token counter to use for the model. If not provided, :obj:`AnthropicTokenCounter` will be used. (default: :obj:`None`)- **timeout** (Optional[float], optional): The timeout value in seconds for API calls. If not provided, will fall back to the MODEL_TIMEOUT environment variable or default to 180 seconds. (default: :obj:`None`)-- **max_retries** (int, optional): Maximum number of retries for API calls. (default: :obj:`3`) **kwargs (Any): Additional arguments to pass to the client initialization.+- **max_retries** (int, optional): Maximum number of retries for API calls. (default: :obj:`3`)+- **client** (Optional[Any], optional): A custom synchronous Anthropic client instance. If provided, this client will be used instead of creating a new one. (default: :obj:`None`)+- **async_client** (Optional[Any], optional): A custom asynchronous Anthropic client instance. If provided, this client will be used instead of creating a new one. (default: :obj:`None`)+- **use_beta_for_structured_outputs** (bool, optional): Whether to use the beta API for structured outputs. (default: :obj:`False`) **kwargs (Any): Additional arguments to pass to the client initialization.<a id="camel.models.anthropic_model.AnthropicModel.__init__"></a>@@ -55,6 +58,9 @@ def __init__(token_counter: Optional[BaseTokenCounter] = None,timeout: Optional[float] = None,max_retries: int = 3,+ client: Optional[Any] = None,+ async_client: Optional[Any] = None,+ use_beta_for_structured_outputs: bool = False,**kwargs: Any):```@@ -69,31 +75,165 @@ def token_counter(self):**Returns:**- OpenAITokenCounter: The token counter following the model's+ AnthropicTokenCounter: The token counter following the model'stokenization style.-<a id="camel.models.anthropic_model.AnthropicModel._request_chat_completion"></a>+<a id="camel.models.anthropic_model.AnthropicModel._convert_openai_to_anthropic_messages"></a>-### _request_chat_completion+### _convert_openai_to_anthropic_messages```python-def _request_chat_completion(+def _convert_openai_to_anthropic_messages(self, messages: List[OpenAIMessage]):+```++Convert OpenAI format messages to Anthropic format.++**Parameters:**++- **messages** (List[OpenAIMessage]): Messages in OpenAI format.++**Returns:**++ tuple[Optional[str], List[Dict[str, Any]]]: A tuple containing+the system message (if any) and the list of messages in+Anthropic format.++<a id="camel.models.anthropic_model.AnthropicModel._convert_anthropic_to_openai_response"></a>++### _convert_anthropic_to_openai_response++```python+def _convert_anthropic_to_openai_response(self, response: Any, model: str):+```++Convert Anthropic API response to OpenAI ChatCompletion format.++**Parameters:**++- **response**: The response object from Anthropic API.+- **model** (str): The model name.++**Returns:**++ ChatCompletion: Response in OpenAI format.++<a id="camel.models.anthropic_model.AnthropicModel._convert_anthropic_stream_to_openai_chunk"></a>++### _convert_anthropic_stream_to_openai_chunk++```python+def _convert_anthropic_stream_to_openai_chunk(+ self,+ chunk: Any,+ model: str,+ tool_call_index: Dict[str, int],+ finish_reason_sent: bool = False+):+```++Convert Anthropic streaming chunk to OpenAI ChatCompletionChunk.++**Parameters:**++- **chunk**: The streaming chunk from Anthropic API.+- **model** (str): The model name.+- **tool_call_index** (Dict[str, int]): A mutable dict tracking tool call indices by their IDs, used to maintain consistent indexing across streaming chunks.++**Returns:**++ ChatCompletionChunk: Chunk in OpenAI format.++<a id="camel.models.anthropic_model.AnthropicModel._convert_openai_tools_to_anthropic"></a>++### _convert_openai_tools_to_anthropic++```python+def _convert_openai_tools_to_anthropic(self, tools: Optional[List[Dict[str, Any]]]):+```++Convert OpenAI tools format to Anthropic tools format.++**Parameters:**++- **tools** (Optional[List[Dict[str, Any]]]): Tools in OpenAI format.++**Returns:**++ Optional[List[Dict[str, Any]]]: Tools in Anthropic format.++<a id="camel.models.anthropic_model.AnthropicModel._run"></a>++### _run++```python+def _run(self,messages: List[OpenAIMessage],+ response_format: Optional[Type[BaseModel]] = None,tools: Optional[List[Dict[str, Any]]] = None):```-<a id="camel.models.anthropic_model.AnthropicModel._patch_anthropic_token_counter"></a>+Runs inference of Anthropic chat completion.++**Parameters:**-### _patch_anthropic_token_counter+- **messages** (List[OpenAIMessage]): Message list with the chat history in OpenAI API format.+- **response_format** (Optional[Type[BaseModel]]): The format of the response. (Not supported by Anthropic API directly)+- **tools** (Optional[List[Dict[str, Any]]]): The schema of the tools to use for the request.++**Returns:**++ Union[ChatCompletion, Stream[ChatCompletionChunk]]:+`ChatCompletion` in the non-stream mode, or+`Stream[ChatCompletionChunk]` in the stream mode.++<a id="camel.models.anthropic_model.AnthropicModel._wrap_anthropic_stream"></a>++### _wrap_anthropic_stream```python-def _patch_anthropic_token_counter(self):+def _wrap_anthropic_stream(self, stream: Any, model: str):```-Monkey patch the AnthropicTokenCounter class to handle trailing-whitespace.+Wrap Anthropic streaming response to OpenAI Stream format.++**Parameters:**++- **stream**: The streaming response from Anthropic API.+- **model** (str): The model name.++**Returns:**++ Stream[ChatCompletionChunk]: Stream in OpenAI format.++<a id="camel.models.anthropic_model.AnthropicModel._wrap_anthropic_async_stream"></a>++### _wrap_anthropic_async_stream++```python+def _wrap_anthropic_async_stream(self, stream: Any, model: str):+```++Wrap Anthropic async streaming response to OpenAI AsyncStream.++**Parameters:**++- **stream**: The async streaming response from Anthropic API.+- **model** (str): The model name.++**Returns:**++ AsyncStream[ChatCompletionChunk]: AsyncStream in OpenAI format.++<a id="camel.models.anthropic_model.AnthropicModel.stream"></a>++### stream++```python+def stream(self):+```++**Returns:**-This patches the count_tokens_from_messages method to strip trailing-whitespace from message content before sending to the Anthropic API.+ bool: Whether the model is in stream mode.