Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address sporadic hanging of evals on certain samples #1482

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions evals/utils/api_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
This file defines various helper functions for interacting with the OpenAI API.
"""
import concurrent
import logging
import os

Expand Down Expand Up @@ -38,16 +37,14 @@ def openai_completion_create_retrying(client: OpenAI, *args, **kwargs):

def request_with_timeout(func, *args, timeout=EVALS_THREAD_TIMEOUT, **kwargs):
"""
Worker thread for making a single request within allotted time.
Function for making a single request within allotted time.
"""
while True:
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(func, *args, **kwargs)
try:
result = future.result(timeout=timeout)
return result
except concurrent.futures.TimeoutError:
continue
try:
result = func(*args, timeout=timeout, **kwargs)
return result
except openai.APITimeoutError as e:
continue


@backoff.on_exception(
Expand Down
Loading