Skip to content

Commit a6c71ed

Browse files
extrasmall0lesebclaude
authored
fix: change logprobs type from bool to int in Completions endpoint (#5343)
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 | None` → `logprobs: int | None` with `ge=0, le=5` - `llama-stack-spec.yaml`: matching schema update (`boolean` → `integer` with min/max) The Chat Completions model (`OpenAIChatCompletionRequestWithExtraBody`) is unchanged — its `logprobs` is correctly a boolean there. --------- Signed-off-by: Extra Small <littleshuai.bot@gmail.com> Signed-off-by: Sébastien Han <seb@redhat.com> Co-authored-by: Sébastien Han <seb@redhat.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9ed901b commit a6c71ed

6 files changed

Lines changed: 27 additions & 11 deletions

File tree

client-sdks/stainless/openapi.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5008,9 +5008,11 @@ components:
50085008
description: The logit bias to use.
50095009
logprobs:
50105010
anyOf:
5011-
- type: boolean
5011+
- type: integer
5012+
maximum: 5.0
5013+
minimum: 0.0
50125014
- type: 'null'
5013-
description: The log probabilities to use.
5015+
description: Include the log probabilities on the logprobs most likely output tokens.
50145016
max_tokens:
50155017
anyOf:
50165018
- type: integer

docs/static/deprecated-ogx-spec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,9 +1311,11 @@ components:
13111311
description: The logit bias to use.
13121312
logprobs:
13131313
anyOf:
1314-
- type: boolean
1314+
- type: integer
1315+
maximum: 5.0
1316+
minimum: 0.0
13151317
- type: 'null'
1316-
description: The log probabilities to use.
1318+
description: Include the log probabilities on the logprobs most likely output tokens.
13171319
max_tokens:
13181320
anyOf:
13191321
- type: integer

docs/static/experimental-ogx-spec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,9 +1752,11 @@ components:
17521752
description: The logit bias to use.
17531753
logprobs:
17541754
anyOf:
1755-
- type: boolean
1755+
- type: integer
1756+
maximum: 5.0
1757+
minimum: 0.0
17561758
- type: 'null'
1757-
description: The log probabilities to use.
1759+
description: Include the log probabilities on the logprobs most likely output tokens.
17581760
max_tokens:
17591761
anyOf:
17601762
- type: integer

docs/static/ogx-spec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4565,9 +4565,11 @@ components:
45654565
description: The logit bias to use.
45664566
logprobs:
45674567
anyOf:
4568-
- type: boolean
4568+
- type: integer
4569+
maximum: 5.0
4570+
minimum: 0.0
45694571
- type: 'null'
4570-
description: The log probabilities to use.
4572+
description: Include the log probabilities on the logprobs most likely output tokens.
45714573
max_tokens:
45724574
anyOf:
45734575
- type: integer

docs/static/stainless-ogx-spec.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5008,9 +5008,11 @@ components:
50085008
description: The logit bias to use.
50095009
logprobs:
50105010
anyOf:
5011-
- type: boolean
5011+
- type: integer
5012+
maximum: 5.0
5013+
minimum: 0.0
50125014
- type: 'null'
5013-
description: The log probabilities to use.
5015+
description: Include the log probabilities on the logprobs most likely output tokens.
50145016
max_tokens:
50155017
anyOf:
50165018
- type: integer

src/ogx_api/inference/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,13 @@ class OpenAICompletionRequestWithExtraBody(BaseModel, extra="allow"):
948948
default=None, ge=-2.0, le=2.0, description="The penalty for repeated tokens."
949949
)
950950
logit_bias: dict[str, float] | None = Field(default=None, description="The logit bias to use.")
951-
logprobs: bool | None = Field(default=None, description="The log probabilities to use.")
951+
logprobs: int | None = Field(
952+
default=None,
953+
ge=0,
954+
le=5,
955+
strict=True,
956+
description="Include the log probabilities on the logprobs most likely output tokens.",
957+
)
952958
max_tokens: int | None = Field(default=None, ge=1, description="The maximum number of tokens to generate.")
953959
n: int | None = Field(default=None, ge=1, description="The number of completions to generate.")
954960
presence_penalty: float | None = Field(

0 commit comments

Comments
 (0)