Skip to content

fix: change logprobs type from bool to int in Completions endpoint#5343

Open
extrasmall0 wants to merge 1 commit intollamastack:mainfrom
extrasmall0:fix/completions-logprobs-type
Open

fix: change logprobs type from bool to int in Completions endpoint#5343
extrasmall0 wants to merge 1 commit intollamastack:mainfrom
extrasmall0:fix/completions-logprobs-type

Conversation

@extrasmall0
Copy link
Copy Markdown

Fixes #5253

The logprobs field in OpenAICompletionRequestWithExtraBody was typed as bool but the OpenAI Completions API expects an integer (0–5) indicating how many top log probabilities to include per output token. This caused a 400 error when callers passed an int:

openai.BadRequestError: ... 'Input should be a valid boolean, unable to interpret input'

Changes:

  • models.py: logprobs: bool | Nonelogprobs: int | None with ge=0, le=5
  • llama-stack-spec.yaml: matching schema update (booleaninteger with min/max)

The Chat Completions model (OpenAIChatCompletionRequestWithExtraBody) is unchanged — its logprobs is correctly a boolean there.

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Mar 27, 2026

Hi @extrasmall0!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@nathan-weinberg
Copy link
Copy Markdown
Contributor

@extrasmall0 can you sign the CLA?

@extrasmall0
Copy link
Copy Markdown
Author

@extrasmall0 can you sign the CLA?

Hi Nathan, I just signed it. Thanks for your reminder!

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 15, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 15, 2026
@nathan-weinberg
Copy link
Copy Markdown
Contributor

awesome, can you rebase the PR? and you can raise it for review in #prs in our Discord 😄

The OpenAI Completions API expects logprobs as an integer (0-5)
specifying how many top log probabilities to return per token.
The Chat Completions endpoint correctly uses bool, but the legacy
Completions model had the wrong type, causing 400 errors when
passing an integer value.

Fixes llamastack#5253
@extrasmall0 extrasmall0 force-pushed the fix/completions-logprobs-type branch from 3f65c71 to e5f13e2 Compare April 20, 2026 19:10
@extrasmall0
Copy link
Copy Markdown
Author

Rebased onto the current main and force-pushed the branch just now. Thanks for the nudge. If it helps, I can also post this in #prs on Discord.

@nathan-weinberg
Copy link
Copy Markdown
Contributor

Yes please do - you'll need a Maintainer to run PR checks (I am just a community member)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI Completions endpoint logprobs should be int, not bool

2 participants