mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-28 06:41:59 +00:00
fix: Responses API previous_response input items
This adds storing of input items with previous responses and then restores those input items to prepend to the user's messages list when using conversation state. I missed this in the initial implementation, but it makes sense that we have to store the input items from previous responses so that we can reconstruct the proper messages stack for multi-turn conversations - just the output from previous responses isn't enough context for the models to follow the turns and the original instructions. Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
parent
150b9a0834
commit
5b2e850754
2 changed files with 104 additions and 10 deletions
|
|
@ -131,3 +131,20 @@ OpenAIResponseInputTool = Annotated[
|
|||
Field(discriminator="type"),
|
||||
]
|
||||
register_schema(OpenAIResponseInputTool, name="OpenAIResponseInputTool")
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class OpenAIResponseInputItemMessage(OpenAIResponseInputMessage):
|
||||
id: str
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class OpenAIResponseInputItemList(BaseModel):
|
||||
data: list[OpenAIResponseInputItemMessage]
|
||||
object: Literal["list"] = "list"
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class OpenAIResponsePreviousResponseWithInputItems(BaseModel):
|
||||
input_items: OpenAIResponseInputItemList
|
||||
response: OpenAIResponseObject
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue