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

Add default value to the logprobs parameter #1044

Merged
merged 11 commits into from
Dec 25, 2023
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we remove "<1.5" if the PR is supposed to support openai>=1.5?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Somehow this might have been a merge error

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's probably due to merge. I'll run tests again against the latest 1.6.1 and create a new PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1071 has been created by @ekzhu and merged.

"diskcache",
"termcolor",
"flaml",
Expand Down
Loading