Commit b8510001 authored by baberabb's avatar baberabb
Browse files

fixed error handling

parent 3a3655d6
......@@ -41,12 +41,6 @@ def anthropic_completion(
)
time.sleep(backoff_time)
backoff_time *= 1.5
except anthropic.APIConnectionError as e:
eval_logger.critical(f"Server unreachable: {e.__cause__}")
break
except anthropic.APIStatusError as e:
eval_logger.critical(f"API error {e.status_code}: {e.message}")
break
@register_model("anthropic")
......@@ -122,6 +116,7 @@ class AnthropicLM(LM):
res = []
for request in tqdm(requests):
try:
inp = request[0]
request_args = request[1]
until = request_args["until"]
......@@ -137,6 +132,12 @@ class AnthropicLM(LM):
res.append(response)
self.cache_hook.add_partial("greedy_until", request, response)
except anthropic.APIConnectionError as e:
eval_logger.critical(f"Server unreachable: {e.__cause__}")
break
except anthropic.APIStatusError as e:
eval_logger.critical(f"API error {e.status_code}: {e.message}")
break
return res
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment