类 GeminiChatModel
java.lang.Object
io.agentscope.core.model.ChatModelBase
io.agentscope.core.model.GeminiChatModel
- 所有已实现的接口:
Model
Gemini Chat Model implementation using the official Google GenAI Java SDK.
This implementation provides complete integration with Gemini's Content Generation API, including tool calling and multi-agent conversation support.
Supported Features:
- Text generation with streaming and non-streaming modes
- Tool/function calling support
- Multi-agent conversation with history merging
- Vision capabilities (images, audio, video)
- Thinking mode (extended reasoning)
-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明GeminiChatModel(String apiKey, String modelName, boolean streamEnabled, String project, String location, Boolean vertexAI, com.google.genai.types.HttpOptions httpOptions, com.google.auth.oauth2.GoogleCredentials credentials, com.google.genai.types.ClientOptions clientOptions, GenerateOptions defaultOptions, Formatter<com.google.genai.types.Content, com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder> formatter) Creates a new Gemini chat model instance using the default endpoint configuration.GeminiChatModel(String apiKey, String baseUrl, String modelName, boolean streamEnabled, String project, String location, Boolean vertexAI, com.google.genai.types.HttpOptions httpOptions, com.google.auth.oauth2.GoogleCredentials credentials, com.google.genai.types.ClientOptions clientOptions, GenerateOptions defaultOptions, Formatter<com.google.genai.types.Content, com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder> formatter) Creates a new Gemini chat model instance. -
方法概要
修饰符和类型方法说明static GeminiChatModel.Builderbuilder()Creates a new builder for GeminiChatModel.voidclose()Close the Gemini client.protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from Gemini's API.Get model name for logging and identification.从类继承的方法 io.agentscope.core.model.ChatModelBase
stream
-
构造器详细资料
-
GeminiChatModel
public GeminiChatModel(String apiKey, String baseUrl, String modelName, boolean streamEnabled, String project, String location, Boolean vertexAI, com.google.genai.types.HttpOptions httpOptions, com.google.auth.oauth2.GoogleCredentials credentials, com.google.genai.types.ClientOptions clientOptions, GenerateOptions defaultOptions, Formatter<com.google.genai.types.Content, com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder> formatter) Creates a new Gemini chat model instance.- 参数:
apiKey- the API key for authentication (for Gemini API)baseUrl- the custom base URL for Gemini API (null for default)modelName- the model name to use (e.g., "gemini-2.0-flash", "gemini-1.5-pro")streamEnabled- whether streaming should be enabledproject- the Google Cloud project ID (for Vertex AI)location- the Google Cloud location (for Vertex AI, e.g., "us-central1")vertexAI- whether to use Vertex AI APIs (null for auto-detection)httpOptions- HTTP options for the clientcredentials- Google credentials (for Vertex AI)clientOptions- client options for the API clientdefaultOptions- default generation optionsformatter- the message formatter to use (null for default Gemini formatter)
-
GeminiChatModel
public GeminiChatModel(String apiKey, String modelName, boolean streamEnabled, String project, String location, Boolean vertexAI, com.google.genai.types.HttpOptions httpOptions, com.google.auth.oauth2.GoogleCredentials credentials, com.google.genai.types.ClientOptions clientOptions, GenerateOptions defaultOptions, Formatter<com.google.genai.types.Content, com.google.genai.types.GenerateContentResponse, com.google.genai.types.GenerateContentConfig.Builder> formatter) Creates a new Gemini chat model instance using the default endpoint configuration.This overload passes
nullforbaseUrl, allowing the SDK to use its default endpoint behavior for either Gemini API or Vertex AI, depending on the provided configuration.- 参数:
apiKey- the API key for authentication (for Gemini API)modelName- the model name to use (e.g., "gemini-2.0-flash", "gemini-1.5-pro")streamEnabled- whether streaming should be enabledproject- the Google Cloud project ID (for Vertex AI)location- the Google Cloud location (for Vertex AI, e.g., "us-central1")vertexAI- whether to use Vertex AI APIs (null for auto-detection)httpOptions- HTTP options for the clientcredentials- Google credentials (for Vertex AI)clientOptions- client options for the API clientdefaultOptions- default generation optionsformatter- the message formatter to use (null for default Gemini formatter)
-
-
方法详细资料
-
doStream
protected reactor.core.publisher.Flux<ChatResponse> doStream(List<Msg> messages, List<ToolSchema> tools, GenerateOptions options) Stream chat completion responses from Gemini's API.This method internally handles message formatting using the configured formatter. When streaming is enabled, it returns incremental responses as they arrive. When streaming is disabled, it returns a single complete response.
- 指定者:
doStream在类中ChatModelBase- 参数:
messages- AgentScope messages to send to the modeltools- Optional list of tool schemas (null or empty if no tools)options- Optional generation options (null to use defaults)- 返回:
- Flux stream of chat responses
-
getModelName
从接口复制的说明:ModelGet model name for logging and identification.- 返回:
- model name
-
close
public void close()Close the Gemini client. -
builder
Creates a new builder for GeminiChatModel.- 返回:
- a new Builder instance
-