File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -351,18 +351,18 @@ def generate(self, messages):
351351 converted_messages = self .convert_messages (messages )
352352
353353 def api_call ():
354- return self .model .generate_content (
354+ response = self .model .generate_content (
355355 converted_messages ,
356356 generation_config = self .generation_config ,
357357 )
358+ # Attempt to extract completion immediately after API call
359+ completion = self .extract_completion (response )
360+ # Return both response and completion if successful
361+ return response , completion
358362
359- response = self .execute_with_retries (api_call )
363+ # Execute the API call and extraction together with retries
364+ response , completion = self .execute_with_retries (api_call )
360365
361- def extract_completion_call ():
362- return self .extract_completion (response )
363-
364- completion = self .execute_with_retries (extract_completion_call )
365-
366366 return LLMResponse (
367367 model_id = self .model_id ,
368368 completion = completion ,
You can’t perform that action at this time.
0 commit comments