feat(gemini): add baseUrl builder support#1174
Open
rrrjqy66 wants to merge 2 commits intoagentscope-ai:mainfrom
Open
feat(gemini): add baseUrl builder support#1174rrrjqy66 wants to merge 2 commits intoagentscope-ai:mainfrom
rrrjqy66 wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a higher-level baseUrl(...) builder option to GeminiChatModel so users can override the Gemini API endpoint without needing to construct HttpOptions manually, aligning Gemini’s ergonomics with other model builders in the codebase.
Changes:
- Added
GeminiChatModel.Builder.baseUrl(String)and merged it into effective Google GenAIHttpOptions. - Ensured
baseUrl(...)overrides only the base URL while preserving otherhttpOptions(...)settings. - Updated English/Chinese docs and added unit tests covering the new builder behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java |
Adds baseUrl builder field/method and merges it into effective HttpOptions used by the Google GenAI client. |
agentscope-core/src/test/java/io/agentscope/core/model/GeminiChatModelTest.java |
Adds unit tests validating baseUrl wiring and merge behavior with existing HttpOptions. |
docs/en/task/model.md |
Documents the new baseUrl option and provides an example. |
docs/zh/task/model.md |
Documents the new baseUrl option and provides an example (Chinese docs). |
Comments suppressed due to low confidence (1)
agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java:100
- Adding
baseUrlinto the publicGeminiChatModelconstructor signature is a source/binary breaking change for any callers usingnew GeminiChatModel(...). To keep backward compatibility, consider keeping the old constructor (withoutbaseUrl) and delegating it to the new one withbaseUrl = null(optionally deprecating the old overload).
public GeminiChatModel(
String apiKey,
String baseUrl,
String modelName,
boolean streamEnabled,
String project,
String location,
Boolean vertexAI,
HttpOptions httpOptions,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
1.0.12-SNAPSHOT
Description
Background
Issue #1127 requests a simpler way to configure a custom
baseUrlfor Gemini.The underlying Google GenAI SDK already supports endpoint override through
HttpOptions, but AgentScope-Java currently exposes that only through the lower-levelhttpOptions(...)builder method. As a result, Gemini is less ergonomic than the other model builders when users need to target a custom gateway, private endpoint, or mock server.Purpose
Add a first-class
baseUrlbuilder entrypoint for Gemini so custom endpoints can be configured more easily and consistently.Changes Made
GeminiChatModel.Builder.baseUrl(String)baseUrlto the effective Google GenAIHttpOptionshttpOptions(...)settings when bothhttpOptions(...)andbaseUrl(...)are providedbaseUrl(...)and the merge behavior with existinghttpOptions(...)Why this approach
This change is intentionally kept narrow and focused on the builder ergonomics requested in #1127.
The Google GenAI SDK already models endpoint override through
HttpOptions, so this PR adds a convenient high-level entrypoint without changing the underlying transport model. Advanced transport or proxy-related configuration remains available through the existing lower-level configuration methods.How to Test
GeminiChatModelwith.baseUrl(https://example.test)and verify construction succeeds.httpOptions(...)and.baseUrl(...)and verify the custom base URL is applied without losing the other HTTP settingsmvn -pl agentscope-core -Dtest=GeminiChatModelTest testmvn -pl agentscope-core testmvn -pl agentscope-core spotless:checkChecklist
mvn spotless:applymvn testfor the affected module)Closes #1127