Skip to content

Commit a3cdf78

Browse files
committed
feat: add Prompts API to Responses API
1 parent 8422bd1 commit a3cdf78

File tree

11 files changed

+332
-80
lines changed

11 files changed

+332
-80
lines changed

docs/_static/llama-stack-spec.html

Lines changed: 95 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8868,6 +8868,51 @@
88688868
"title": "OpenAIResponseOutputMessageWebSearchToolCall",
88698869
"description": "Web search tool call output message for OpenAI responses."
88708870
},
8871+
"OpenAIResponsePromptParam": {
8872+
"type": "object",
8873+
"properties": {
8874+
"id": {
8875+
"type": "string",
8876+
"description": "Unique identifier of the prompt template"
8877+
},
8878+
"version": {
8879+
"type": "string",
8880+
"description": "Version number of the prompt to use (defaults to latest if not specified)"
8881+
},
8882+
"variables": {
8883+
"type": "object",
8884+
"additionalProperties": {
8885+
"oneOf": [
8886+
{
8887+
"type": "null"
8888+
},
8889+
{
8890+
"type": "boolean"
8891+
},
8892+
{
8893+
"type": "number"
8894+
},
8895+
{
8896+
"type": "string"
8897+
},
8898+
{
8899+
"type": "array"
8900+
},
8901+
{
8902+
"type": "object"
8903+
}
8904+
]
8905+
},
8906+
"description": "Dictionary of variable names to values for template substitution"
8907+
}
8908+
},
8909+
"additionalProperties": false,
8910+
"required": [
8911+
"id"
8912+
],
8913+
"title": "OpenAIResponsePromptParam",
8914+
"description": "Prompt object that is used for OpenAI responses."
8915+
},
88718916
"OpenAIResponseText": {
88728917
"type": "object",
88738918
"properties": {
@@ -8962,6 +9007,10 @@
89629007
"type": "string",
89639008
"description": "The underlying LLM used for completions."
89649009
},
9010+
"prompt": {
9011+
"$ref": "#/components/schemas/OpenAIResponsePromptParam",
9012+
"description": "Prompt object with ID, version, and variables."
9013+
},
89659014
"instructions": {
89669015
"type": "string"
89679016
},
@@ -9066,6 +9115,10 @@
90669115
"type": "string",
90679116
"description": "(Optional) ID of the previous response in a conversation"
90689117
},
9118+
"prompt": {
9119+
"$ref": "#/components/schemas/Prompt",
9120+
"description": "(Optional) Prompt object with ID, version, and variables"
9121+
},
90699122
"status": {
90709123
"type": "string",
90719124
"description": "Current status of the response generation"
@@ -9261,6 +9314,44 @@
92619314
"title": "OpenAIResponseOutputMessageMCPListTools",
92629315
"description": "MCP list tools output message containing available tools from an MCP server."
92639316
},
9317+
"Prompt": {
9318+
"type": "object",
9319+
"properties": {
9320+
"prompt": {
9321+
"type": "string",
9322+
"description": "The system prompt text with variable placeholders. Variables are only supported when using the Responses API."
9323+
},
9324+
"version": {
9325+
"type": "integer",
9326+
"description": "Version (integer starting at 1, incremented on save)"
9327+
},
9328+
"prompt_id": {
9329+
"type": "string",
9330+
"description": "Unique identifier formatted as 'pmpt_<48-digit-hash>'"
9331+
},
9332+
"variables": {
9333+
"type": "array",
9334+
"items": {
9335+
"type": "string"
9336+
},
9337+
"description": "List of prompt variable names that can be used in the prompt template"
9338+
},
9339+
"is_default": {
9340+
"type": "boolean",
9341+
"default": false,
9342+
"description": "Boolean indicating whether this version is the default version for this prompt"
9343+
}
9344+
},
9345+
"additionalProperties": false,
9346+
"required": [
9347+
"version",
9348+
"prompt_id",
9349+
"variables",
9350+
"is_default"
9351+
],
9352+
"title": "Prompt",
9353+
"description": "A prompt resource representing a stored OpenAI Compatible prompt template in Llama Stack."
9354+
},
92649355
"OpenAIResponseContentPart": {
92659356
"oneOf": [
92669357
{
@@ -10066,44 +10157,6 @@
1006610157
],
1006710158
"title": "CreatePromptRequest"
1006810159
},
10069-
"Prompt": {
10070-
"type": "object",
10071-
"properties": {
10072-
"prompt": {
10073-
"type": "string",
10074-
"description": "The system prompt text with variable placeholders. Variables are only supported when using the Responses API."
10075-
},
10076-
"version": {
10077-
"type": "integer",
10078-
"description": "Version (integer starting at 1, incremented on save)"
10079-
},
10080-
"prompt_id": {
10081-
"type": "string",
10082-
"description": "Unique identifier formatted as 'pmpt_<48-digit-hash>'"
10083-
},
10084-
"variables": {
10085-
"type": "array",
10086-
"items": {
10087-
"type": "string"
10088-
},
10089-
"description": "List of prompt variable names that can be used in the prompt template"
10090-
},
10091-
"is_default": {
10092-
"type": "boolean",
10093-
"default": false,
10094-
"description": "Boolean indicating whether this version is the default version for this prompt"
10095-
}
10096-
},
10097-
"additionalProperties": false,
10098-
"required": [
10099-
"version",
10100-
"prompt_id",
10101-
"variables",
10102-
"is_default"
10103-
],
10104-
"title": "Prompt",
10105-
"description": "A prompt resource representing a stored OpenAI Compatible prompt template in Llama Stack."
10106-
},
1010710160
"OpenAIDeleteResponseObject": {
1010810161
"type": "object",
1010910162
"properties": {
@@ -13277,6 +13330,10 @@
1327713330
"type": "string",
1327813331
"description": "(Optional) ID of the previous response in a conversation"
1327913332
},
13333+
"prompt": {
13334+
"$ref": "#/components/schemas/Prompt",
13335+
"description": "(Optional) Prompt object with ID, version, and variables"
13336+
},
1328013337
"status": {
1328113338
"type": "string",
1328213339
"description": "Current status of the response generation"

docs/_static/llama-stack-spec.yaml

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6444,6 +6444,34 @@ components:
64446444
OpenAIResponseOutputMessageWebSearchToolCall
64456445
description: >-
64466446
Web search tool call output message for OpenAI responses.
6447+
OpenAIResponsePromptParam:
6448+
type: object
6449+
properties:
6450+
id:
6451+
type: string
6452+
description: Unique identifier of the prompt template
6453+
version:
6454+
type: string
6455+
description: >-
6456+
Version number of the prompt to use (defaults to latest if not specified)
6457+
variables:
6458+
type: object
6459+
additionalProperties:
6460+
oneOf:
6461+
- type: 'null'
6462+
- type: boolean
6463+
- type: number
6464+
- type: string
6465+
- type: array
6466+
- type: object
6467+
description: >-
6468+
Dictionary of variable names to values for template substitution
6469+
additionalProperties: false
6470+
required:
6471+
- id
6472+
title: OpenAIResponsePromptParam
6473+
description: >-
6474+
Prompt object that is used for OpenAI responses.
64476475
OpenAIResponseText:
64486476
type: object
64496477
properties:
@@ -6509,6 +6537,10 @@ components:
65096537
model:
65106538
type: string
65116539
description: The underlying LLM used for completions.
6540+
prompt:
6541+
$ref: '#/components/schemas/OpenAIResponsePromptParam'
6542+
description: >-
6543+
Prompt object with ID, version, and variables.
65126544
instructions:
65136545
type: string
65146546
previous_response_id:
@@ -6598,6 +6630,10 @@ components:
65986630
type: string
65996631
description: >-
66006632
(Optional) ID of the previous response in a conversation
6633+
prompt:
6634+
$ref: '#/components/schemas/Prompt'
6635+
description: >-
6636+
(Optional) Prompt object with ID, version, and variables
66016637
status:
66026638
type: string
66036639
description: >-
@@ -6752,6 +6788,44 @@ components:
67526788
title: OpenAIResponseOutputMessageMCPListTools
67536789
description: >-
67546790
MCP list tools output message containing available tools from an MCP server.
6791+
Prompt:
6792+
type: object
6793+
properties:
6794+
prompt:
6795+
type: string
6796+
description: >-
6797+
The system prompt text with variable placeholders. Variables are only
6798+
supported when using the Responses API.
6799+
version:
6800+
type: integer
6801+
description: >-
6802+
Version (integer starting at 1, incremented on save)
6803+
prompt_id:
6804+
type: string
6805+
description: >-
6806+
Unique identifier formatted as 'pmpt_<48-digit-hash>'
6807+
variables:
6808+
type: array
6809+
items:
6810+
type: string
6811+
description: >-
6812+
List of prompt variable names that can be used in the prompt template
6813+
is_default:
6814+
type: boolean
6815+
default: false
6816+
description: >-
6817+
Boolean indicating whether this version is the default version for this
6818+
prompt
6819+
additionalProperties: false
6820+
required:
6821+
- version
6822+
- prompt_id
6823+
- variables
6824+
- is_default
6825+
title: Prompt
6826+
description: >-
6827+
A prompt resource representing a stored OpenAI Compatible prompt template
6828+
in Llama Stack.
67556829
OpenAIResponseContentPart:
67566830
oneOf:
67576831
- $ref: '#/components/schemas/OpenAIResponseContentPartOutputText'
@@ -7431,44 +7505,6 @@ components:
74317505
required:
74327506
- prompt
74337507
title: CreatePromptRequest
7434-
Prompt:
7435-
type: object
7436-
properties:
7437-
prompt:
7438-
type: string
7439-
description: >-
7440-
The system prompt text with variable placeholders. Variables are only
7441-
supported when using the Responses API.
7442-
version:
7443-
type: integer
7444-
description: >-
7445-
Version (integer starting at 1, incremented on save)
7446-
prompt_id:
7447-
type: string
7448-
description: >-
7449-
Unique identifier formatted as 'pmpt_<48-digit-hash>'
7450-
variables:
7451-
type: array
7452-
items:
7453-
type: string
7454-
description: >-
7455-
List of prompt variable names that can be used in the prompt template
7456-
is_default:
7457-
type: boolean
7458-
default: false
7459-
description: >-
7460-
Boolean indicating whether this version is the default version for this
7461-
prompt
7462-
additionalProperties: false
7463-
required:
7464-
- version
7465-
- prompt_id
7466-
- variables
7467-
- is_default
7468-
title: Prompt
7469-
description: >-
7470-
A prompt resource representing a stored OpenAI Compatible prompt template
7471-
in Llama Stack.
74727508
OpenAIDeleteResponseObject:
74737509
type: object
74747510
properties:
@@ -9862,6 +9898,10 @@ components:
98629898
type: string
98639899
description: >-
98649900
(Optional) ID of the previous response in a conversation
9901+
prompt:
9902+
$ref: '#/components/schemas/Prompt'
9903+
description: >-
9904+
(Optional) Prompt object with ID, version, and variables
98659905
status:
98669906
type: string
98679907
description: >-

llama_stack/apis/agents/agents.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
OpenAIResponseInputTool,
3838
OpenAIResponseObject,
3939
OpenAIResponseObjectStream,
40+
OpenAIResponsePromptParam,
4041
OpenAIResponseText,
4142
)
4243

@@ -699,6 +700,7 @@ async def create_openai_response(
699700
self,
700701
input: str | list[OpenAIResponseInput],
701702
model: str,
703+
prompt: OpenAIResponsePromptParam | None = None,
702704
instructions: str | None = None,
703705
previous_response_id: str | None = None,
704706
store: bool | None = True,
@@ -710,9 +712,9 @@ async def create_openai_response(
710712
max_infer_iters: int | None = 10, # this is an extension to the OpenAI API
711713
) -> OpenAIResponseObject | AsyncIterator[OpenAIResponseObjectStream]:
712714
"""Create a new OpenAI response.
713-
714715
:param input: Input message(s) to create the response.
715716
:param model: The underlying LLM used for completions.
717+
:param prompt: Prompt object with ID, version, and variables.
716718
:param previous_response_id: (Optional) if specified, the new response will be a continuation of the previous response. This can be used to easily fork-off new responses from existing responses.
717719
:param include: (Optional) Additional fields to include in the response.
718720
:returns: An OpenAIResponseObject.

0 commit comments

Comments
 (0)