Closed
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
I just updated to 1.4.0, and the client.chat.completions.create()
in python library is not taking logprobs
or top_logprobs
as arguments but these arguments are already enabled if I access them through http request.
To Reproduce
To reproduce:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
logprobs=True,
)
Then it will return:
TypeError: Completions.create() got an unexpected keyword argument 'logprobs'
But you can use:
import requests
url = "https://api.openai.com/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {OPENAI_API_KEY}"
}
data = {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
'logprobs': True,
}
response = requests.post(url, headers=headers, json=data)
And you will get a response with logprobs.
Code snippets
No response
OS
macOS
Python version
Python v3.11.5
Library version
openai v1.4.0