Skip to content

Commit

Permalink
Add default value to the logprobs parameter (#1044)
Browse files Browse the repository at this point in the history
* added default value to logprobs param

* fixed to work withversions of openai below 1.5.0

* rebase

* fixed openai version in comments

* polishing

* limit openai version to below 1.5.0

---------

Co-authored-by: Eric Zhu <[email protected]>
  • Loading branch information
davorrunje and ekzhu authored Dec 25, 2023
1 parent 4b5ec5a commit cb6512d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
TOOL_ENABLED = False
try:
import openai
from openai import OpenAI, APIError
from openai import OpenAI, APIError, __version__ as OPENAIVERSION
from openai.types.chat import ChatCompletion
from openai.types.chat.chat_completion import ChatCompletionMessage, Choice
from openai.types.completion import Completion
Expand Down Expand Up @@ -330,8 +330,8 @@ def _completions_create(self, client, params):
),
)
for i in range(len(response_contents)):
try:
# OpenAI versions 0.1.5 and above
if OPENAIVERSION >= "1.5": # pragma: no cover
# OpenAI versions 1.5.0 and above
choice = Choice(
index=i,
finish_reason=finish_reasons[i],
Expand All @@ -340,8 +340,8 @@ def _completions_create(self, client, params):
),
logprobs=None,
)
except ValidationError:
# OpenAI version up to 0.1.4
else:
# OpenAI versions below 1.5.0
choice = Choice(
index=i,
finish_reason=finish_reasons[i],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
__version__ = version["__version__"]

install_requires = [
"openai>=1,<1.5", # a temporary fix for breaking changes in 1.5
"openai>=1.3,<1.5",
"diskcache",
"termcolor",
"flaml",
Expand Down

0 comments on commit cb6512d

Please sign in to comment.