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

6.5 KB
Raw Blame
<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`)
- **url** (str, optional): Custom endpoint URL for the Bedrock Runtime service (e.g. VPC endpoint). Falls back to the `__INLINE_CODE_0____INLINE_CODE_1__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,
    url: 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._ensure_additional_properties_false"></a>

### _ensure_additional_properties_false

```python
def _ensure_additional_properties_false(schema: Dict[str, Any]):
```

Recursively set `__INLINE_CODE_0__` on all object
types in *schema*.  AWS Bedrock requires this or it raises a
`__INLINE_CODE_1__`.

<a id="camel.models.aws_bedrock_converse_model.AWSBedrockConverseModel._convert_response_format_to_output_config"></a>

### _convert_response_format_to_output_config

```python
def _convert_response_format_to_output_config(response_format: Type[BaseModel]):
```

<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,
    response_format: Optional[Type[BaseModel]] = 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
):
```