@@ -114,7 +114,7 @@ def chat(
114114 self ,
115115 chats : tt .Thread | str ,
116116 model : Optional [str ] = None ,
117- max_tokens : int = 1024 ,
117+ max_tokens : int = 4096 ,
118118 temperature : float = 1 ,
119119 token : Optional [str ] = None ,
120120 timeout = None ,
@@ -150,7 +150,7 @@ def stream_chat(
150150 self ,
151151 chats : tt .Thread | str ,
152152 model : Optional [str ] = None ,
153- max_tokens : int = 1024 ,
153+ max_tokens : int = 4096 ,
154154 temperature : float = 1 ,
155155 token : Optional [str ] = None ,
156156 timeout = (5 , 60 ),
@@ -166,18 +166,12 @@ def stream_chat(
166166 extra_headers = extra_headers or self .extra_headers
167167 if extra_headers :
168168 headers .update (extra_headers )
169+
169170 data = {
170171 "systemInstruction" : {
171172 "parts" : [{"text" : system }],
172173 },
173174 "contents" : messages ,
174- "generationConfig" : {
175- "temperature" : temperature ,
176- "topK" : 0 ,
177- "topP" : 0.95 ,
178- "maxOutputTokens" : max_tokens ,
179- "stopSequences" : [],
180- },
181175 "safetySettings" : [
182176 {
183177 "category" : "HARM_CATEGORY_HARASSMENT" ,
@@ -197,6 +191,22 @@ def stream_chat(
197191 },
198192 ],
199193 }
194+
195+ generation_config = {
196+ "temperature" : temperature ,
197+ "maxOutputTokens" : max_tokens ,
198+ "stopSequences" : [],
199+ }
200+
201+ if chats .gen_schema :
202+ generation_config .update (
203+ {
204+ "response_mime_type" : "application/json" ,
205+ "response_schema" : chats .gen_schema ,
206+ }
207+ )
208+ data ["generationConfig" ] = generation_config
209+
200210 if tools :
201211 data ["tool_config" ] = {
202212 "function_calling_config" : {
@@ -285,6 +295,7 @@ def distributed_chat(
285295 max_threads : int = 10 ,
286296 retry : int = 3 ,
287297 pbar = True ,
298+ ** kwargs ,
288299 ):
289300 return distributed_chat (
290301 self ,
@@ -293,4 +304,5 @@ def distributed_chat(
293304 max_threads = max_threads ,
294305 retry = retry ,
295306 pbar = pbar ,
307+ ** kwargs ,
296308 )
0 commit comments