File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -206,18 +206,20 @@ def __call_api(prompt):
206
206
}
207
207
response = litellm .completion (** kwargs )
208
208
text = response .choices [0 ].message .content
209
- if text is None :
209
+ if not text or response . failed :
210
210
kwargs ["caching" ] = False
211
211
response = litellm .completion (** kwargs )
212
212
text = response .choices [0 ].message .content
213
- if text is None :
213
+ if not text or response . failed :
214
214
# Just return an error response if the second attempt fails too
215
- return ModelResponse (text = "Failed to get response from the API." , model = self .model )
215
+ return ModelResponse (
216
+ text = "Failed to get response from the API." , model = self .model , failed = True
217
+ )
216
218
return text
217
219
except Exception as e :
218
220
logger .warning (f"{ type (e ), e } " )
219
221
time .sleep (self .API_RETRY_SLEEP )
220
- return ModelResponse (text = "Failed to get response from the API." , model = self .model )
222
+ return ModelResponse (text = "Failed to get response from the API." , model = self .model , failed = True )
221
223
222
224
results = []
223
225
with ThreadPoolExecutor (100 ) as executor :
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ class ModelResponse:
33
33
generated_tokens : list [int ] = field (default_factory = list ) # model generations
34
34
truncated_tokens_count : Optional [int ] = 0 # How many tokens truncated
35
35
padded_tokens_count : Optional [int ] = 0 # How many tokens of padding
36
+ failed : bool = False
36
37
37
38
def get_result_for_eval (self ):
38
39
raise NotImplementedError ()
You can’t perform that action at this time.
0 commit comments