Skip to content

client.chat.completions.create() not taking logprobs and top_logprobs as arguments #975

Closed
@az-2os

Description

@az-2os

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions