Skip to content

Commit 82e6aa8

Browse files
authored
Merge branch 'openai:main' into feature/theory_of_mind
2 parents eb49d08 + a06a07b commit 82e6aa8

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

evals/cli/oaieval.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import sys
88
from typing import Any, Mapping, Optional, Union, cast
99

10-
import openai
11-
1210
import evals
1311
import evals.api
1412
import evals.base
@@ -268,9 +266,6 @@ def main() -> None:
268266
filename=args.log_to_file if args.log_to_file else None,
269267
)
270268
logging.getLogger("openai").setLevel(logging.WARN)
271-
272-
if hasattr(openai.error, "set_display_cause"): # type: ignore
273-
openai.error.set_display_cause() # type: ignore
274269
run(args)
275270

276271

evals/elsuite/make_me_say/autoeval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Callable, Optional, Union
33

44
import backoff
5-
from openai.error import InvalidRequestError
5+
from openai import BadRequestError
66

77
from evals.api import CompletionFn, CompletionResult
88
from evals.elsuite.make_me_say.core import Game, Message, Player
@@ -17,7 +17,7 @@
1717
)
1818

1919

20-
@backoff.on_exception(backoff.constant, InvalidRequestError, max_tries=3)
20+
@backoff.on_exception(backoff.constant, BadRequestError, max_tries=3)
2121
def run(
2222
codeword: str,
2323
manipulator_completion_fn: CompletionFn,

evals/elsuite/make_me_say/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import backoff
55
import openai
6-
import openai.error
76
import urllib3.exceptions
87

98
from evals.api import CompletionResult
@@ -12,9 +11,12 @@
1211
@backoff.on_exception(
1312
backoff.expo,
1413
(
15-
openai.error.RateLimitError,
16-
openai.error.ServiceUnavailableError,
17-
openai.error.TryAgain,
14+
openai.APIError,
15+
openai.APIStatusError,
16+
openai.RateLimitError,
17+
openai.APITimeoutError,
18+
openai.APIConnectionError,
19+
openai.InternalServerError,
1820
urllib3.exceptions.TimeoutError,
1921
),
2022
)

evals/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def add_registry_paths(self, paths: Sequence[Union[str, Path]]) -> None:
9999
def api_model_ids(self) -> list[str]:
100100
try:
101101
return [m["id"] for m in openai.Model.list()["data"]]
102-
except openai.error.OpenAIError as err: # type: ignore
102+
except openai.OpenAIError as err: # type: ignore
103103
# Errors can happen when running eval with completion function that uses custom
104104
# API endpoints and authentication mechanisms.
105105
logger.warning(f"Could not fetch API model IDs from OpenAI API: {err}")

evals/utils/api_utils.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
@backoff.on_exception(
1515
wait_gen=backoff.expo,
1616
exception=(
17-
openai.error.ServiceUnavailableError,
18-
openai.error.APIError,
19-
openai.error.RateLimitError,
20-
openai.error.APIConnectionError,
21-
openai.error.Timeout,
17+
openai.APIError,
18+
openai.APIStatusError,
19+
openai.RateLimitError,
20+
openai.APITimeoutError,
21+
openai.APIConnectionError,
22+
openai.InternalServerError,
2223
),
2324
max_value=60,
2425
factor=1.5,
@@ -31,7 +32,7 @@ def openai_completion_create_retrying(*args, **kwargs):
3132
result = openai.Completion.create(*args, **kwargs)
3233
if "error" in result:
3334
logging.warning(result)
34-
raise openai.error.APIError(result["error"])
35+
raise openai.APIError(result["error"])
3536
return result
3637

3738

@@ -52,11 +53,12 @@ def request_with_timeout(func, *args, timeout=EVALS_THREAD_TIMEOUT, **kwargs):
5253
@backoff.on_exception(
5354
wait_gen=backoff.expo,
5455
exception=(
55-
openai.error.ServiceUnavailableError,
56-
openai.error.APIError,
57-
openai.error.RateLimitError,
58-
openai.error.APIConnectionError,
59-
openai.error.Timeout,
56+
openai.APIError,
57+
openai.APIStatusError,
58+
openai.RateLimitError,
59+
openai.APITimeoutError,
60+
openai.APIConnectionError,
61+
openai.InternalServerError,
6062
),
6163
max_value=60,
6264
factor=1.5,
@@ -69,5 +71,5 @@ def openai_chat_completion_create_retrying(*args, **kwargs):
6971
result = request_with_timeout(openai.ChatCompletion.create, *args, **kwargs)
7072
if "error" in result:
7173
logging.warning(result)
72-
raise openai.error.APIError(result["error"])
74+
raise openai.APIError(result["error"])
7375
return result

0 commit comments

Comments
 (0)