Skip to content

Commit ac4ebc4

Browse files
fix: execute with retries for gemini
1 parent e006561 commit ac4ebc4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

balrog/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)