Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge [skip ci]

camel-docs-bot7b35eebd302a
diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.json
index bf64eeec5..fbe680f26 100644
--- a/docs/mintlify/docs.json
+++ b/docs/mintlify/docs.json
@@ -313,6 +313,7 @@
"reference/camel.models.anthropic_model",
"reference/camel.models.atlascloud_model",
"reference/camel.models.avian_model",
+ "reference/camel.models.aws_bedrock_converse_model",
"reference/camel.models.aws_bedrock_model",
"reference/camel.models.azure_openai_model",
"reference/camel.models.base_audio_model",
diff --git a/docs/mintlify/reference/camel.configs.bedrock_config.mdx b/docs/mintlify/reference/camel.configs.bedrock_config.mdx
index 160fa4e87..ec88f4f84 100644
--- a/docs/mintlify/reference/camel.configs.bedrock_config.mdx
+++ b/docs/mintlify/reference/camel.configs.bedrock_config.mdx
@@ -17,7 +17,9 @@ compatibility.
- **temperature** (float, optional): Sampling temperature to use, between :obj:`0` and :obj:`2`. Higher values make the output more random, while lower values make it more focused and deterministic. (default: :obj:`None`)
- **top_p** (float, optional): An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So :obj:`0.1` means only the tokens comprising the top 10% probability mass are considered. (default: :obj:`None`)
- **top_k** (int, optional): The number of top tokens to consider.
+- **stop** (list[str], optional): Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. (default: :obj:`None`)
- **stream** (bool, optional): If True, partial message deltas will be sent as data-only server-sent events as they become available. (default: :obj:`None`)
- **tools** (list[FunctionTool], optional): A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
- **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`)
+- **cache_control** (`Optional[Literal["5m", "1h"]], optional`): Cache TTL for Bedrock prompt caching. Set to :obj:`"5m"` for 5-minute or :obj:`"1h"` for 1-hour TTL (only supported by some models). Cache checkpoints are inserted on both the system message and the last user message. (default: :obj:`None`)
diff --git a/docs/mintlify/reference/camel.configs.gemini_config.mdx b/docs/mintlify/reference/camel.configs.gemini_config.mdx
index dfb464baa..017e2effb 100644
--- a/docs/mintlify/reference/camel.configs.gemini_config.mdx
+++ b/docs/mintlify/reference/camel.configs.gemini_config.mdx
@@ -22,3 +22,6 @@ Gemini API.
- **max_tokens** (int, optional): The maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. (default: :obj:`None`)
- **tools** (list[FunctionTool], optional): A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
- **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.
+- **cache_control** (str, optional): Reserved cache TTL field for API compatibility. Gemini explicit caches are created via :obj:`GeminiModel.create_cache()`, and this field is not applied automatically to requests. Format: "300s", "3600s", etc. (default: :obj:`None`)
+- **cached_content** (str, optional): Reference to an existing cache to use.
+- **Format**: "cachedContents/\{cache_id\}". When set, the model will use the cached content instead of re-processing the same context. (default: :obj:`None`)
diff --git a/docs/mintlify/reference/camel.models.aws_bedrock_converse_model.mdx b/docs/mintlify/reference/camel.models.aws_bedrock_converse_model.mdx
new file mode 100644
index 000000000..2e94e2ef7
--- /dev/null
+++ b/docs/mintlify/reference/camel.models.aws_bedrock_converse_model.mdx
@@ -0,0 +1,192 @@
+<a id="camel.models.aws_bedrock_converse_model"></a>
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel"></a>
+
+## AWSBedrockConverseModel
+
+```python
+class AWSBedrockConverseModel(BaseModelBackend):
+```
+
+AWS Bedrock Converse API backend with prompt caching support.
+
+**Parameters:**
+
+- **model_type** (Union[ModelType, str]): Model for which a backend is created.
+- **model_config_dict** (Dict[str, Any], optional): A dictionary that will be fed into the backend constructor. If :obj:`None`, :obj:`BedrockConfig().as_dict()` will be used. (default: :obj:`None`)
+- **api_key** (str, optional): The API key for authenticating with the AWS Bedrock service. (default: :obj:`None`)
+- **region_name** (str, optional): The AWS region name, e.g. `__INLINE_CODE_0____INLINE_CODE_1__None`)
+- **aws_access_key_id** (str, optional): Explicit IAM access key ID. (default: :obj:`None`)
+- **aws_secret_access_key** (str, optional): Explicit IAM secret access key. (default: :obj:`None`)
+- **aws_session_token** (str, optional): Temporary session token for STS credentials. (default: :obj:`None`)
+- **token_counter** (BaseTokenCounter, optional): Token counter to use for the model. If not provided, :obj:`OpenAITokenCounter( ModelType.GPT_4O_MINI)` will be used. (default: :obj:`None`)
+- **timeout** (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.
+- **References**:
+- **https**: //docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ model_type: Union[ModelType, str],
+ model_config_dict: Optional[Dict[str, Any]] = None,
+ api_key: Optional[str] = None,
+ region_name: Optional[str] = None,
+ aws_access_key_id: Optional[str] = None,
+ aws_secret_access_key: Optional[str] = None,
+ aws_session_token: Optional[str] = None,
+ token_counter: Optional[BaseTokenCounter] = None,
+ timeout: Optional[float] = None,
+ max_retries: int = 3,
+ **kwargs: Any
+):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel.bedrock_client"></a>
+
+### bedrock_client
+
+```python
+def bedrock_client(self):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel.token_counter"></a>
+
+### token_counter
+
+```python
+def token_counter(self):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel.stream"></a>
+
+### stream
+
+```python
+def stream(self):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._new_cache_point"></a>
+
+### _new_cache_point
+
+```python
+def _new_cache_point(ttl: Optional[str] = None):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._parse_json_or_text"></a>
+
+### _parse_json_or_text
+
+```python
+def _parse_json_or_text(value: Any):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._extract_text"></a>
+
+### _extract_text
+
+```python
+def _extract_text(content: Any):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._parse_data_image"></a>
+
+### _parse_data_image
+
+```python
+def _parse_data_image(url: str):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._to_bedrock_content_blocks"></a>
+
+### _to_bedrock_content_blocks
+
+```python
+def _to_bedrock_content_blocks(self, content: Any):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._convert_openai_to_bedrock_messages"></a>
+
+### _convert_openai_to_bedrock_messages
+
+```python
+def _convert_openai_to_bedrock_messages(self, messages: List[OpenAIMessage]):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._convert_openai_tools_to_bedrock"></a>
+
+### _convert_openai_tools_to_bedrock
+
+```python
+def _convert_openai_tools_to_bedrock(self, tools: Optional[List[Dict[str, Any]]]):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._convert_tool_choice"></a>
+
+### _convert_tool_choice
+
+```python
+def _convert_tool_choice(self, tool_choice: Any):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._build_converse_request"></a>
+
+### _build_converse_request
+
+```python
+def _build_converse_request(
+ self,
+ messages: List[OpenAIMessage],
+ tools: Optional[List[Dict[str, Any]]] = None
+):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._map_stop_reason"></a>
+
+### _map_stop_reason
+
+```python
+def _map_stop_reason(stop_reason: Optional[str]):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._parse_bedrock_usage"></a>
+
+### _parse_bedrock_usage
+
+```python
+def _parse_bedrock_usage(usage_raw: Dict[str, Any]):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._convert_converse_to_openai_response"></a>
+
+### _convert_converse_to_openai_response
+
+```python
+def _convert_converse_to_openai_response(self, response: Dict[str, Any], model: str):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._converse_stream_to_openai_chunks"></a>
+
+### _converse_stream_to_openai_chunks
+
+```python
+def _converse_stream_to_openai_chunks(self, stream_obj: Dict[str, Any], model: str):
+```
+
+<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._run"></a>
+
+### _run
+
+```python
+def _run(
+ self,
+ messages: List[OpenAIMessage],
+ response_format: Optional[Type[BaseModel]] = None,
+ tools: Optional[List[Dict[str, Any]]] = None
+):
+```
diff --git a/docs/mintlify/reference/camel.models.gemini_model.mdx b/docs/mintlify/reference/camel.models.gemini_model.mdx
index b93c91237..c101ac9d1 100644
--- a/docs/mintlify/reference/camel.models.gemini_model.mdx
+++ b/docs/mintlify/reference/camel.models.gemini_model.mdx
@@ -38,6 +38,169 @@ def __init__(
):
```
+<a id="camel.models.gemini_model.GeminiModel.native_client"></a>
+
+### native_client
+
+```python
+def native_client(self):
+```
+
+**Returns:**
+
+ genai.Client: The native Google GenAI client.
+
+<a id="camel.models.gemini_model.GeminiModel.create_cache"></a>
+
+### create_cache
+
+```python
+def create_cache(
+ self,
+ contents: List[Dict[str, Any]],
+ ttl: str = '300s',
+ display_name: Optional[str] = None,
+ system_instruction: Optional[str] = None
+):
+```
+
+Create a cache for reusing content across requests.
+
+**Parameters:**
+
+- **contents** (List[Dict[str, Any]]): The content to cache. Should be a list of message dicts with 'role' and 'parts' keys.
+- **ttl** (str, optional): Time-to-live for the cache as an integer number of seconds followed by `__INLINE_CODE_0____INLINE_CODE_1____INLINE_CODE_2____INLINE_CODE_3____INLINE_CODE_4____INLINE_CODE_5____INLINE_CODE_6____INLINE_CODE_7__"300s"`)
+- **display_name** (str, optional): A human-readable name for the cache. (default: :obj:`None`)
+- **system_instruction** (str, optional): System instruction to cache. (default: :obj:`None`)
+
+**Returns:**
+
+ str: The cache name in format "cachedContents/\{cache_id\}".
+
+<a id="camel.models.gemini_model.GeminiModel.list_caches"></a>
+
+### list_caches
+
+```python
+def list_caches(self):
+```
+
+**Returns:**
+
+ List[CachedContent]: A list of cached content objects.
+
+<a id="camel.models.gemini_model.GeminiModel.get_cache"></a>
+
+### get_cache
+
+```python
+def get_cache(self, cache_name: str):
+```
+
+Get details of a specific cache.
+
+**Parameters:**
+
+- **cache_name** (str): The cache name in format "cachedContents/\{id\}".
+
+**Returns:**
+
+ CachedContent: The cached content object.
+
+<a id="camel.models.gemini_model.GeminiModel.update_cache"></a>
+
+### update_cache
+
+```python
+def update_cache(self, cache_name: str, ttl: str):
+```
+
+Update the TTL of an existing cache.
+
+**Parameters:**
+
+- **cache_name** (str): The cache name in format "cachedContents/\{id\}".
+- **ttl** (str): New time-to-live for the cache.
+
+**Returns:**
+
+ CachedContent: The updated cached content object.
+
+<a id="camel.models.gemini_model.GeminiModel.delete_cache"></a>
+
+### delete_cache
+
+```python
+def delete_cache(self, cache_name: str):
+```
+
+Delete a cache.
+
+**Parameters:**
+
+- **cache_name** (str): The cache name in format "cachedContents/\{id\}".
+
+<a id="camel.models.gemini_model.GeminiModel.cached_content"></a>
+
+### cached_content
+
+```python
+def cached_content(self):
+```
+
+**Returns:**
+
+ Optional[str]: The cache name or None if not set.
+
+<a id="camel.models.gemini_model.GeminiModel.cached_content"></a>
+
+### cached_content
+
+```python
+def cached_content(self, value: Optional[str]):
+```
+
+Set or clear the cached content to use for requests.
+
+**Parameters:**
+
+- **value** (Optional[str]): The cache name (e.g., "cachedContents/xxx") or None to clear.
+
+<a id="camel.models.gemini_model.GeminiModel._sanitize_tools_for_gemini"></a>
+
+### _sanitize_tools_for_gemini
+
+```python
+def _sanitize_tools_for_gemini(tools: List[Dict[str, Any]]):
+```
+
+<a id="camel.models.gemini_model.GeminiModel._prepare_request_config"></a>
+
+### _prepare_request_config
+
+```python
+def _prepare_request_config(self, tools: Optional[List[Dict[str, Any]]] = None):
+```
+
+<a id="camel.models.gemini_model.GeminiModel._is_stale_cached_content_error"></a>
+
+### _is_stale_cached_content_error
+
+```python
+def _is_stale_cached_content_error(self, err: Exception):
+```
+
+<a id="camel.models.gemini_model.GeminiModel._handle_stale_cache_error"></a>
+
+### _handle_stale_cache_error
+
+```python
+def _handle_stale_cache_error(self, err: Exception):
+```
+
+If *err* is a stale-cached-content error, log a warning and clear
+the cache so the caller can retry. Otherwise re-raise *err*.
+
<a id="camel.models.gemini_model.GeminiModel._process_messages"></a>
### _process_messages
@@ -168,3 +331,16 @@ def _request_chat_completion(
tools: Optional[List[Dict[str, Any]]] = None
):
```
+
+<a id="camel.models.gemini_model.GeminiModel._request_parse"></a>
+
+### _request_parse
+
+```python
+def _request_parse(
+ self,
+ messages: List[OpenAIMessage],
+ response_format: Type[BaseModel],
+ tools: Optional[List[Dict[str, Any]]] = None
+):
+```