@@ -101,17 +101,11 @@ defmodule LangChain.ChatModels.ChatGoogleAI do
101101 # selected using temperature sampling.
102102 field :top_k , :float , default: 1.0
103103
104- # thinking models only
104+ # Configure thinking budget and whether to include thought summaries (content type `:thinking`).
105+ # See https://ai.google.dev/gemini-api/docs/thinking.
105106 #
106- # The number of thinking tokens it can use when generating a response.
107- # Model-specific behavior:
108- # - 2.5 Pro: Dynamic thinking by default (128-32768 range), cannot disable thinking
109- # - 2.5 Flash: Dynamic thinking by default (0-24576 range), set to 0 to disable
110- # - 2.5 Flash Lite: No thinking by default (512-24576 range), set to 0 to disable
111- # Set to -1 to enable dynamic thinking (model decides when and how much to think)
112- # Set to 0 to disable thinking (except for 2.5 Pro which uses minimum value)
113- # Set to specific value within model's range for fixed thinking budget
114- field :thinking_budget , :integer
107+ # Config reference: https://ai.google.dev/api/generate-content#ThinkingConfig.
108+ field :thinking_config , :map , default: nil
115109
116110 # Duration in seconds for the response to be received. When streaming a very
117111 # lengthy response, a longer time limit may be required. However, when it
@@ -150,7 +144,7 @@ defmodule LangChain.ChatModels.ChatGoogleAI do
150144 :temperature ,
151145 :top_p ,
152146 :top_k ,
153- :thinking_budget ,
147+ :thinking_config ,
154148 :receive_timeout ,
155149 :json_response ,
156150 :json_schema ,
@@ -238,32 +232,15 @@ defmodule LangChain.ChatModels.ChatGoogleAI do
238232 { nil , nil }
239233 end
240234
241- thinking_config =
242- case google_ai . thinking_budget do
243- # Disable thinking
244- nil ->
245- case google_ai . model do
246- "gemini-2.5-pro" ->
247- # Can't disable thinking, so use minimum value
248- % { "includeThoughts" => true , "thinkingBudget" => 128 }
249-
250- _ ->
251- % { "includeThoughts" => false , "thinkingBudget" => 0 }
252- end
253-
254- thinking_budget when is_integer ( thinking_budget ) ->
255- % { "includeThoughts" => true , "thinkingBudget" => thinking_budget }
256- end
257-
258235 generation_config_params =
259236 % {
260237 "temperature" => google_ai . temperature ,
261238 "topP" => google_ai . top_p ,
262239 "topK" => google_ai . top_k
263240 }
241+ |> Utils . conditionally_add_to_map ( "thinkingConfig" , google_ai . thinking_config )
264242 |> Utils . conditionally_add_to_map ( "response_mime_type" , response_mime_type )
265243 |> Utils . conditionally_add_to_map ( "response_schema" , response_schema )
266- |> Utils . conditionally_add_to_map ( "thinkingConfig" , thinking_config )
267244
268245 req =
269246 % {
@@ -903,8 +880,8 @@ defmodule LangChain.ChatModels.ChatGoogleAI do
903880 :temperature ,
904881 :top_p ,
905882 :top_k ,
883+ :thinking_config ,
906884 :receive_timeout ,
907- :thinking_budget ,
908885 :json_response ,
909886 :json_schema ,
910887 :stream ,
0 commit comments