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

[Logprobs] Support logprobs=1 #2612

Merged
merged 10 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix test cases
  • Loading branch information
merrymercy committed Nov 1, 2023
commit cd8c45f8ef4f15bfda458bdd4705ab1df4c45da8
12 changes: 9 additions & 3 deletions tests/test_openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def test_list_models():
return names


def test_completion(model):
def test_completion(model, logprob):
prompt = "Once upon a time"
completion = openai.Completion.create(
model=model, prompt=prompt, logprobs=1, max_tokens=64
model=model, prompt=prompt, logprobs=logprob, max_tokens=64
)
print(f"full text: {prompt + completion.choices[0].text}", flush=True)
if completion.choices[0].logprobs is not None:
Expand Down Expand Up @@ -108,7 +108,13 @@ def test_openai_curl():

for model in models:
print(f"===== Test {model} ======")
test_completion(model)

if model in ["fastchat-t5-3b-v1.0"]:
logprob = None
else:
logprob = 1

test_completion(model, logprob)
test_completion_stream(model)
test_chat_completion(model)
test_chat_completion_stream(model)
Expand Down