mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-16 20:42:38 +00:00
bug fix
This commit is contained in:
parent
4017d5a7b9
commit
a707d2aaa9
1 changed files with 17 additions and 11 deletions
|
|
@ -345,18 +345,24 @@ class OpenAIResponsesImpl:
|
||||||
failed_response = stream_chunk.response
|
failed_response = stream_chunk.response
|
||||||
yield stream_chunk
|
yield stream_chunk
|
||||||
|
|
||||||
# Store the response if requested
|
# Store and sync immediately after yielding terminal events
|
||||||
if store and final_response and failed_response is None:
|
# This ensures the storage/syncing happens even if the consumer breaks early
|
||||||
await self._store_response(
|
if (
|
||||||
response=final_response,
|
stream_chunk.type in {"response.completed", "response.incomplete"}
|
||||||
input=all_input,
|
and store
|
||||||
messages=orchestrator.final_messages,
|
and final_response
|
||||||
)
|
and failed_response is None
|
||||||
|
):
|
||||||
|
await self._store_response(
|
||||||
|
response=final_response,
|
||||||
|
input=all_input,
|
||||||
|
messages=orchestrator.final_messages,
|
||||||
|
)
|
||||||
|
|
||||||
if conversation and final_response:
|
if stream_chunk.type in {"response.completed", "response.incomplete"} and conversation and final_response:
|
||||||
# for Conversations, we need to use the original_input if it's available, otherwise use input
|
# for Conversations, we need to use the original_input if it's available, otherwise use input
|
||||||
sync_input = original_input if original_input is not None else input
|
sync_input = original_input if original_input is not None else input
|
||||||
await self._sync_response_to_conversation(conversation, sync_input, final_response)
|
await self._sync_response_to_conversation(conversation, sync_input, final_response)
|
||||||
|
|
||||||
async def delete_openai_response(self, response_id: str) -> OpenAIDeleteResponseObject:
|
async def delete_openai_response(self, response_id: str) -> OpenAIDeleteResponseObject:
|
||||||
return await self.responses_store.delete_response_object(response_id)
|
return await self.responses_store.delete_response_object(response_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue