类class
agentscope.modelGeminiChatModel
class GeminiChatModel(ChatModelBase)
源码Source
agentscope/model/_gemini/_model.py:143–608Gemini 聊天模型,与模型服务通信并返回生成或向量化结果。位于 agentscope.model 包,继承自 ChatModelBase。
The Google Gemini chat model. Declared in agentscope.model. Extends ChatModelBase.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Parameters | 类class | 参数,与模型服务通信并返回生成或向量化结果。 The parameters for the Gemini chat model. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(credential: GeminiCredential, model: str, parameters: 'GeminiChatModel.Parameters | None' = None, stream:… | 初始化 `GeminiChatModel` 实例。 Initialize the Gemini chat model. |
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
type | Literal['gemini_chat'] | 类型字段。 | 'gemini_chat' |
构造器详情Constructor Detail
GeminiChatModel
def __init__(credential: GeminiCredential, model: str, parameters: 'GeminiChatModel.Parameters | None' = None, stream: bool = True, max_retries: int = 3, retry_delay: float = 1.0, context_size: int = 1048576, formatter: FormatterBase | None = None, client_kwargs: dict[str, Any] | None = None) -> None
初始化 GeminiChatModel 实例。
Initialize the Gemini chat model.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
credential | GeminiCredential | 凭证对象(类型 `GeminiCredential`)。The Google Gemini credential used to authenticate API calls. |
model | str | 模型实例(类型 `str`)。The Gemini model name, e.g. `gemini-2.0-flash-exp`. |
parameters默认default None | 'GeminiChatModel.Parameters | None' | 参数(类型 `'GeminiChatModel.Parameters | None'`)。The Gemini API parameters. When `None`, the default parameters will be used. |
stream默认default True | bool | 判断是否到启用流式输出。Whether to enable streaming output. |
max_retries默认default 3 | int | 最大重试次数(类型 `int`)。The maximum number of retries for the Gemini API. |
retry_delay默认default 1.0 | float | 重试延迟(类型 `float`)。Seconds to sleep between retry attempts. |
context_size默认default 1048576 | int | 上下文大小(类型 `int`)。The model context size used for context compression. |
formatter默认default None | FormatterBase | None | 格式化器(类型 `FormatterBase | None`)。The formatter that converts `Msg` objects to the format required by the Gemini API. When `None`, a `GeminiChatFormatter` instance will be used. |
client_kwargs默认default None | dict[str, Any] | None | 客户端关键字参数(类型 `dict[str, Any] | None`)。Extra keyword arguments forwarded to `google.genai.Client` (e.g. `vertexai`, `project`, `location`, `credentials`, `http_options`). |
源码Source
agentscope/model/_gemini/_model.py:188–245属性详情Attribute Detail
type
Literal['gemini_chat'] = 'gemini_chat'类型字段。声明为 Literal['gemini_chat']。
The type field.
源码Source
agentscope/model/_gemini/_model.py:185嵌套类详情Nested Class Detail
Parameters
class Parameters参数,与模型服务通信并返回生成或向量化结果。位于 agentscope.model 包。
The parameters for the Gemini chat model. Declared in agentscope.model.