autogen_ext.models.anthropic.config 源代码
from typing import Any, Dict, List, Literal, Optional, Union
from autogen_core.models import ModelCapabilities, ModelInfo # type: ignore
from pydantic import BaseModel, SecretStr
from typing_extensions import Required, TypedDict
class ResponseFormat(TypedDict):
type: Literal["text", "json_object"]
class CreateArguments(TypedDict, total=False):
model: str
max_tokens: Optional[int]
temperature: Optional[float]
top_p: Optional[float]
top_k: Optional[int]
stop_sequences: Optional[List[str]]
response_format: Optional[ResponseFormat]
metadata: Optional[Dict[str, str]]
[文档]
class BedrockInfo(TypedDict):
"""BedrockInfo 是一个包含 bedrock 属性信息的字典。
预期用于模型客户端的 bedrock_info 属性。
"""
aws_access_key: Required[str]
"""用于获取 bedrock 模型访问权限的 aws 账户访问密钥"""
aws_secret_key: Required[str]
"""用于获取 bedrock 模型访问权限的 aws 账户访问密钥"""
aws_session_token: Required[str]
"""用于获取Bedrock模型访问权限的AWS账户会话令牌"""
aws_region: Required[str]
"""用于获取Bedrock模型访问权限的AWS账户所在区域"""
class BaseAnthropicClientConfiguration(CreateArguments, total=False):
api_key: str
base_url: Optional[str]
model_capabilities: ModelCapabilities # type: ignore
model_info: ModelInfo
"""模型支持的功能特性,默认由模型名称决定,但如果传入了值则会被覆盖"""
timeout: Optional[float]
max_retries: Optional[int]
default_headers: Optional[Dict[str, str]]
[文档]
class AnthropicClientConfiguration(BaseAnthropicClientConfiguration, total=False):
tools: Optional[List[Dict[str, Any]]]
tool_choice: Optional[Union[Literal["auto", "any", "none"], Dict[str, Any]]]
[文档]
class AnthropicBedrockClientConfiguration(AnthropicClientConfiguration, total=False):
bedrock_info: BedrockInfo
# Pydantic equivalents of the above TypedDicts
[文档]
class CreateArgumentsConfigModel(BaseModel):
model: str
max_tokens: int | None = 4096
temperature: float | None = 1.0
top_p: float | None = None
top_k: int | None = None
stop_sequences: List[str] | None = None
response_format: ResponseFormat | None = None
metadata: Dict[str, str] | None = None
class BaseAnthropicClientConfigurationConfigModel(CreateArgumentsConfigModel):
api_key: SecretStr | None = None
base_url: str | None = None
model_capabilities: ModelCapabilities | None = None # type: ignore
model_info: ModelInfo | None = None
timeout: float | None = None
max_retries: int | None = None
default_headers: Dict[str, str] | None = None
[文档]
class AnthropicClientConfigurationConfigModel(BaseAnthropicClientConfigurationConfigModel):
tools: List[Dict[str, Any]] | None = None
tool_choice: Union[Literal["auto", "any", "none"], Dict[str, Any]] | None = None
class BedrockInfoConfigModel(TypedDict):
aws_access_key: Required[SecretStr]
"""用于获取Bedrock模型访问权限的AWS账户访问密钥"""
aws_session_token: Required[SecretStr]
"""用于获取Bedrock模型访问权限的AWS账户会话令牌"""
aws_region: Required[str]
"""用于获取Bedrock模型访问权限的AWS账户所在区域"""
aws_secret_key: Required[SecretStr]
[文档]
class AnthropicBedrockClientConfigurationConfigModel(AnthropicClientConfigurationConfigModel):
bedrock_info: BedrockInfoConfigModel | None = None