mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix OpenAI Responses streaming to propagate created_at from final response.completed event (#5382)
* Fix streaming response losing created_at from response.completed event (#5347) The streaming path in _parse_chunk_from_openai did not extract created_at from the response.completed event, unlike the non-streaming path in _parse_responses_response. This caused durabletask persistence warnings when created_at was None. Extract created_at in the response.completed case and pass it to the returned ChatResponseUpdate. Also fix pre-existing pyright errors for optional orjson import in sample files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix orjson import suppression to use pyright instead of mypy (#5347) Replace `# type: ignore[import-not-found]` with `# pyright: ignore[reportMissingImports]` on optional orjson imports in conversation sample files, matching the repo's Pyright strict configuration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
9e915b36b6
commit
ea3320d39f
@@ -2028,6 +2028,7 @@ class RawOpenAIChatClient( # type: ignore[misc]
|
||||
local_shell_tool_name = self._get_local_shell_tool_name(options.get("tools"))
|
||||
conversation_id: str | None = None
|
||||
response_id: str | None = None
|
||||
created_at: str | None = None
|
||||
continuation_token: OpenAIContinuationToken | None = None
|
||||
model = self.model
|
||||
match event.type:
|
||||
@@ -2209,6 +2210,9 @@ class RawOpenAIChatClient( # type: ignore[misc]
|
||||
response_id = event.response.id
|
||||
conversation_id = self._get_conversation_id(event.response, options.get("store"))
|
||||
model = event.response.model
|
||||
created_at = datetime.fromtimestamp(event.response.created_at, tz=timezone.utc).strftime(
|
||||
"%Y-%m-%dT%H:%M:%S.%fZ"
|
||||
)
|
||||
if event.response.usage:
|
||||
usage = self._parse_usage_from_openai(event.response.usage)
|
||||
if usage:
|
||||
@@ -2589,6 +2593,7 @@ class RawOpenAIChatClient( # type: ignore[misc]
|
||||
response_id=response_id,
|
||||
role="assistant",
|
||||
model=model,
|
||||
created_at=created_at,
|
||||
continuation_token=continuation_token,
|
||||
additional_properties=metadata,
|
||||
raw_representation=event,
|
||||
|
||||
Reference in New Issue
Block a user