Builder
public static class Builder
io/agentscope/extensions/model/gemini/GeminiChatModel.java:358–646构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.model.gemini 包。核心成员包括 apiKey、baseUrl、modelName、streamEnabled、project、location。
Builder for creating GeminiChatModel instances.
方法摘要Method Summary
方法详情Method Detail
apiKey
public Builder apiKey(String apiKey)
设置API 键。
Sets the API key (for Gemini API).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 键(类型 `String`)。the Gemini API key |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:381–384baseUrl
public Builder baseUrl(String baseUrl)
设置基类 URL。
Sets the custom base URL (for Gemini API).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。the custom Gemini API base URL |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:392–395modelName
public Builder modelName(String modelName)
设置模型名称。
Sets the model name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
modelName | String | 模型名称(默认:"gemini-2.5-flash")。the model name (default: "gemini-2.5-flash") |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:403–406streamEnabled
public Builder streamEnabled(boolean streamEnabled)
设置流已启用。
Sets whether streaming is enabled.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
streamEnabled | boolean | 流已启用(类型 `boolean`)。true to enable streaming (default: false) |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:414–417project
public Builder project(String project)
设置该配置项。
Sets the Google Cloud project ID (for Vertex AI).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
project | String | project(类型 `String`)。the project ID |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:425–428location
public Builder location(String location)
设置该配置项。
Sets the Google Cloud location (for Vertex AI).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
location | String | location(类型 `String`)。the location (e.g., "us-central1") |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:436–439vertexAI
public Builder vertexAI(boolean vertexAI)
设置该配置项。
Sets whether to use Vertex AI APIs.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
vertexAI | boolean | vertex AI(类型 `boolean`)。true to use Vertex AI, false for Gemini API |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:447–450httpOptions
public Builder httpOptions(HttpOptions httpOptions)
设置HTTP 选项用于客户端。
Sets the HTTP options for the client.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
httpOptions | HttpOptions | HTTP 选项。the HTTP options |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:458–461credentials
public Builder credentials(GoogleCredentials credentials)
设置凭证。
Sets the Google credentials (for Vertex AI).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
credentials | GoogleCredentials | 凭证(类型 `GoogleCredentials`)。the Google credentials |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:469–472clientOptions
public Builder clientOptions(ClientOptions clientOptions)
设置客户端选项。
Sets the client options.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
clientOptions | ClientOptions | 客户端选项。the client options |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:480–483defaultOptions
public Builder defaultOptions(GenerateOptions defaultOptions)
设置默认选项。
Sets the default generation options.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
defaultOptions | GenerateOptions | 默认选项。the default options |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:491–494formatter
public Builder formatter(Formatter<Content, GenerateContentResponse, GenerateContentConfig.Builder> formatter)
设置格式化器。
Sets the formatter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
formatter | Formatter<Content, GenerateContentResponse, GenerateContentConfig.Builder> | 格式化器到使用。the formatter to use |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:502–507proxy
public Builder proxy(ProxyConfig proxyConfig)
设置代理。
Sets the proxy configuration for HTTP traffic.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
proxyConfig | ProxyConfig | 代理配置(类型 `ProxyConfig`)。the proxy configuration (see `ProxyConfig`) |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:541–544contextWindowSize
public Builder contextWindowSize(int contextWindowSize)
构建GeminiChatModel 实例。
Builds the GeminiChatModel instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
contextWindowSize | int | 上下文 Window 大小(类型 `int`)。The context window size. |
Builderio/agentscope/extensions/model/gemini/GeminiChatModel.java:558–561build
public GeminiChatModel build()
构建并返回最终实例。
Creates and returns an instance.
GeminiChatModelio/agentscope/extensions/model/gemini/GeminiChatModel.java:563–584