feat!: Implement include parameter specifically for adding logprobs in the output message (#4261)
Some checks failed
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 0s
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Integration Tests (Replay) / generate-matrix (push) Successful in 3s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 3s
API Conformance Tests / check-schema-compatibility (push) Successful in 15s
Python Package Build Test / build (3.12) (push) Successful in 17s
Python Package Build Test / build (3.13) (push) Successful in 18s
Test External API and Providers / test-external (venv) (push) Failing after 28s
Vector IO Integration Tests / test-matrix (push) Failing after 43s
UI Tests / ui-tests (22) (push) Successful in 52s
Unit Tests / unit-tests (3.13) (push) Failing after 1m45s
Unit Tests / unit-tests (3.12) (push) Failing after 1m58s
Pre-commit / pre-commit (22) (push) Successful in 3m9s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 4m5s

# Problem
As an Application Developer, I want to use the include parameter with
the value message.output_text.logprobs, so that I can receive log
probabilities for output tokens to assess the model's confidence in its
response.

# What does this PR do?

- Updates the include parameter in various resource definitions
- Updates the inline provider to return logprobs when
"message.output_text.logprobs" is passed in the include parameter
- Converts the logprobs returned by the inference provider from chat
completion format to responses format

Closes #[4260](https://github.com/llamastack/llama-stack/issues/4260)

## Test Plan

- Created a script to explore OpenAI behavior:
https://github.com/s-akhtar-baig/llama-stack-examples/blob/main/responses/src/include.py
- Added integration tests and new recordings

---------

Co-authored-by: Matthew Farrellee <matt@cs.wisc.edu>
Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
This commit is contained in:
Shabana Baig 2025-12-11 14:11:21 -05:00 committed by GitHub
parent 76e47d811a
commit 805abf573f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 13524 additions and 161 deletions

View file

@ -3277,15 +3277,15 @@ components:
type: number
title: Logprob
top_logprobs:
items:
$ref: '#/components/schemas/OpenAITopLogProb'
type: array
title: Top Logprobs
anyOf:
- items:
$ref: '#/components/schemas/OpenAITopLogProb'
type: array
- type: 'null'
type: object
required:
- token
- logprob
- top_logprobs
title: OpenAITokenLogProb
description: |-
The log probability for a token from an OpenAI-compatible chat completion response.
@ -4373,15 +4373,22 @@ components:
OpenAIResponseOutputMessageContentOutputText:
properties:
text:
type: string
title: Text
type:
type: string
type:
const: output_text
title: Type
default: output_text
title: Type
type: string
annotations:
items:
discriminator:
mapping:
container_file_citation: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
file_citation: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
file_path: '#/components/schemas/OpenAIResponseAnnotationFilePath'
url_citation: '#/components/schemas/OpenAIResponseAnnotationCitation'
propertyName: type
oneOf:
- $ref: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
title: OpenAIResponseAnnotationFileCitation
@ -4391,20 +4398,20 @@ components:
title: OpenAIResponseAnnotationContainerFileCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationFilePath'
title: OpenAIResponseAnnotationFilePath
discriminator:
propertyName: type
mapping:
container_file_citation: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
file_citation: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
file_path: '#/components/schemas/OpenAIResponseAnnotationFilePath'
url_citation: '#/components/schemas/OpenAIResponseAnnotationCitation'
title: OpenAIResponseAnnotationFileCitation | ... (4 variants)
type: array
title: Annotations
type: object
type: array
logprobs:
anyOf:
- items:
$ref: '#/components/schemas/OpenAITokenLogProb'
type: array
- type: 'null'
nullable: true
required:
- text
title: OpenAIResponseOutputMessageContentOutputText
type: object
OpenAIResponseOutputMessageFileSearchToolCall:
properties:
id:
@ -6020,7 +6027,7 @@ components:
include:
anyOf:
- items:
type: string
$ref: '#/components/schemas/ResponseItemInclude'
type: array
- type: 'null'
max_infer_iters:
@ -6219,8 +6226,7 @@ components:
logprobs:
anyOf:
- items:
additionalProperties: true
type: object
$ref: '#/components/schemas/OpenAITokenLogProb'
type: array
- type: 'null'
nullable: true
@ -6982,6 +6988,13 @@ components:
item_id:
title: Item Id
type: string
logprobs:
anyOf:
- items:
$ref: '#/components/schemas/OpenAITokenLogProb'
type: array
- type: 'null'
nullable: true
output_index:
title: Output Index
type: integer
@ -10407,19 +10420,19 @@ components:
title: list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile]
- items:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
title: OpenAIResponseOutputMessageContentOutputText
- $ref: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText-Input'
title: OpenAIResponseOutputMessageContentOutputText-Input
- $ref: '#/components/schemas/OpenAIResponseContentPartRefusal'
title: OpenAIResponseContentPartRefusal
discriminator:
propertyName: type
mapping:
output_text: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
output_text: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText-Input'
refusal: '#/components/schemas/OpenAIResponseContentPartRefusal'
title: OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal
title: OpenAIResponseOutputMessageContentOutputText-Input | OpenAIResponseContentPartRefusal
type: array
title: list[OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal]
title: string | list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile] | list[OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal]
title: list[OpenAIResponseOutputMessageContentOutputText-Input | OpenAIResponseContentPartRefusal]
title: string | list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile] | list[OpenAIResponseOutputMessageContentOutputText-Input | OpenAIResponseContentPartRefusal]
role:
title: Role
type: string
@ -10476,19 +10489,19 @@ components:
title: list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile]
- items:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
title: OpenAIResponseOutputMessageContentOutputText
- $ref: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText-Output'
title: OpenAIResponseOutputMessageContentOutputText-Output
- $ref: '#/components/schemas/OpenAIResponseContentPartRefusal'
title: OpenAIResponseContentPartRefusal
discriminator:
propertyName: type
mapping:
output_text: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText'
output_text: '#/components/schemas/OpenAIResponseOutputMessageContentOutputText-Output'
refusal: '#/components/schemas/OpenAIResponseContentPartRefusal'
title: OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal
title: OpenAIResponseOutputMessageContentOutputText-Output | OpenAIResponseContentPartRefusal
type: array
title: list[OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal]
title: string | list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile] | list[OpenAIResponseOutputMessageContentOutputText | OpenAIResponseContentPartRefusal]
title: list[OpenAIResponseOutputMessageContentOutputText-Output | OpenAIResponseContentPartRefusal]
title: string | list[OpenAIResponseInputMessageContentText | OpenAIResponseInputMessageContentImage | OpenAIResponseInputMessageContentFile] | list[OpenAIResponseOutputMessageContentOutputText-Output | OpenAIResponseContentPartRefusal]
role:
title: Role
type: string
@ -10521,6 +10534,88 @@ components:
They are all under one type because the Responses API gives them all
the same "type" value, and there is no way to tell them apart in certain
scenarios.
OpenAIResponseOutputMessageContentOutputText-Input:
properties:
text:
type: string
title: Text
type:
type: string
const: output_text
title: Type
default: output_text
annotations:
items:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
title: OpenAIResponseAnnotationFileCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationCitation'
title: OpenAIResponseAnnotationCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
title: OpenAIResponseAnnotationContainerFileCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationFilePath'
title: OpenAIResponseAnnotationFilePath
discriminator:
propertyName: type
mapping:
container_file_citation: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
file_citation: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
file_path: '#/components/schemas/OpenAIResponseAnnotationFilePath'
url_citation: '#/components/schemas/OpenAIResponseAnnotationCitation'
title: OpenAIResponseAnnotationFileCitation | ... (4 variants)
type: array
title: Annotations
logprobs:
anyOf:
- items:
$ref: '#/components/schemas/OpenAITokenLogProb'
type: array
- type: 'null'
type: object
required:
- text
title: OpenAIResponseOutputMessageContentOutputText
OpenAIResponseOutputMessageContentOutputText-Output:
properties:
text:
type: string
title: Text
type:
type: string
const: output_text
title: Type
default: output_text
annotations:
items:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
title: OpenAIResponseAnnotationFileCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationCitation'
title: OpenAIResponseAnnotationCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
title: OpenAIResponseAnnotationContainerFileCitation
- $ref: '#/components/schemas/OpenAIResponseAnnotationFilePath'
title: OpenAIResponseAnnotationFilePath
discriminator:
propertyName: type
mapping:
container_file_citation: '#/components/schemas/OpenAIResponseAnnotationContainerFileCitation'
file_citation: '#/components/schemas/OpenAIResponseAnnotationFileCitation'
file_path: '#/components/schemas/OpenAIResponseAnnotationFilePath'
url_citation: '#/components/schemas/OpenAIResponseAnnotationCitation'
title: OpenAIResponseAnnotationFileCitation | ... (4 variants)
type: array
title: Annotations
logprobs:
anyOf:
- items:
$ref: '#/components/schemas/OpenAITokenLogProb'
type: array
- type: 'null'
type: object
required:
- text
title: OpenAIResponseOutputMessageContentOutputText
OpenAIResponseOutputMessageFileSearchToolCallResults:
properties:
attributes:
@ -10680,6 +10775,18 @@ components:
required:
- reasoning_tokens
title: OutputTokensDetails
ResponseItemInclude:
type: string
enum:
- web_search_call.action.sources
- code_interpreter_call.outputs
- computer_call_output.output.image_url
- file_search_call.results
- message.input_image.image_url
- message.output_text.logprobs
- reasoning.encrypted_content
title: ResponseItemInclude
description: Specify additional output data to include in the model response.
SearchRankingOptions:
properties:
ranker: