-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add Prompts API to Responses API #3514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add Prompts API to Responses API #3514
Conversation
ef753bc
to
fe6ea4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an api change unrelated to how prompts are used in /v1/responses
please review your code assistant output before posting as a PR.
Hi @mattf ! Could you please elaborate on how the prompts should be used in Responses API in your opinion. My understanding was that they should be propagated to Agent’s messages context as OpenAISystemMessageParam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @r3v5 it looks like you've suggested adding prompt_id
here where you need to add a Prompt
object with an id
, version
, and variables
, which would then be consistent with OpenAI's client usage, as outlined here:
response = client.responses.create(
prompt={
"id": "pmpt_68b0c29740048196bd3a6e6ac3c4d0e20ed9a13f0d15bf5e",
"version": "2",
"variables": {
"city": "San Francisco",
"age": 30,
}
}
)
So this is currently incorrect. As @mattf suggested, let's make sure we double check this. Thank you.
Oh yeah, this makes sense. I got it. I will adjust the implementation then |
fe6ea4c
to
a3cdf78
Compare
""" | ||
|
||
id: str | ||
version: str | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version has type string because OpenAI has it like string. Reference is here
@cdoern this is an enhancement to the /openai/v1/responses api, does it match the openai /v1/responses api spec? |
there seems to be some breaking changes, BUT these might have existed in main, let me check. |
a3cdf78
to
d76b15b
Compare
hey @cdoern any update on the main branch check here? |
d76b15b
to
fadf1d0
Compare
fadf1d0
to
f474e0c
Compare
What does this PR do?
The purpose of this PR is to integrate Prompts API to Responses API to achieve full OpenAI compatibility for current Responses API in Llama Stack.
Closes #3321
Test Plan
Manual API testing and running newly added unit tests.
Prerequisites:
uv run --with llama-stack llama stack build --distro starter --image-type venv --run
API Testing:
Output:
{"created_at":1758562266,"error":null,"id":"resp-f20d3abe-d3cf-416b-9060-e653134d51cf","model":"openai/gpt-4o","object":"response","output":[{"content":[{"text":"The capital of Ireland is Dublin.","type":"output_text","annotations":[]}],"role":"assistant","type":"message","id":"msg_67a2f184-ae00-4f49-b4d2-27dfd22623a6","status":"completed"}],"parallel_tool_calls":false,"previous_response_id":null,"prompt":{"prompt":"You are a helpful {{ area_name }} assistant in {{ company_name }}. Always provide accurate information.","version":2,"prompt_id":"pmpt_dc6c124c7f1393cd4ddb88ed707ffbfd3d937e644d10052c","variables":["area_name","company_name"],"is_default":false},"status":"completed","temperature":null,"text":{"format":{"type":"text"}},"top_p":null,"truncation":null,"user":null}%
Telemetry log:
Output:
{"created_at":1758562266,"error":null,"id":"resp-f20d3abe-d3cf-416b-9060-e653134d51cf","model":"openai/gpt-4o","object":"response","output":[{"content":[{"text":"The capital of Ireland is Dublin.","type":"output_text","annotations":[]}],"role":"assistant","type":"message","id":"msg_67a2f184-ae00-4f49-b4d2-27dfd22623a6","status":"completed"}],"parallel_tool_calls":false,"previous_response_id":null,"prompt":{"prompt":"You are a helpful {{ area_name }} assistant in {{ company_name }}. Always provide accurate information.","version":2,"prompt_id":"pmpt_dc6c124c7f1393cd4ddb88ed707ffbfd3d937e644d10052c","variables":["area_name","company_name"],"is_default":false},"status":"completed","temperature":null,"text":{"format":{"type":"text"}},"top_p":null,"truncation":null,"user":null}%