File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed
core/src/main/java/com/google/adk/models Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,6 @@ public Builder vertexCredentials(VertexCredentials vertexCredentials) {
193193 *
194194 * @return A new {@link Gemini} instance.
195195 * @throws NullPointerException if modelName is null.
196- * @throws IllegalStateException if none of apiKey, VertexCredentials, or an explicit apiClient
197- * is set.
198196 */
199197 public Gemini build () {
200198 Objects .requireNonNull (modelName , "modelName must be set." );
@@ -206,9 +204,11 @@ public Gemini build() {
206204 } else if (vertexCredentials != null ) {
207205 return new Gemini (modelName , vertexCredentials );
208206 } else {
209- throw new IllegalStateException (
210- "Authentication strategy not set: Either apiKey, VertexCredentials, or an explicit"
211- + " apiClient must be provided." );
207+ return new Gemini (
208+ modelName ,
209+ Client .builder ()
210+ .httpOptions (HttpOptions .builder ().headers (TRACKING_HEADERS ).build ())
211+ .build ());
212212 }
213213 }
214214 }
Original file line number Diff line number Diff line change @@ -32,22 +32,12 @@ public interface LlmFactory {
3232 BaseLlm create (String modelName );
3333 }
3434
35- /** API client for interacting with the Gemini model. */
36- private static final Client geminiApiClient = Client .builder ().build ();
37-
3835 /** Map of model name patterns regex to factories. */
3936 private static final Map <String , LlmFactory > llmFactories = new ConcurrentHashMap <>();
4037
41- /** Returns the singleton instance of the Gemini API client. */
42- private static Client getGeminiApiClient () {
43- return geminiApiClient ;
44- }
45-
4638 /** Registers default LLM factories, e.g. for Gemini models. */
4739 static {
48- registerLlm (
49- "gemini-.*" ,
50- modelName -> Gemini .builder ().modelName (modelName ).apiClient (getGeminiApiClient ()).build ());
40+ registerLlm ("gemini-.*" , modelName -> Gemini .builder ().modelName (modelName ).build ());
5141 }
5242
5343 /**
You can’t perform that action at this time.
0 commit comments