mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
test: use public API for streaming structured output
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/f62076ef-558d-49e8-8fe2-f38d527c9639 Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
5d43f48a9d
commit
6d6b35d8b3
@@ -619,6 +619,9 @@ class RawOpenAIChatClient( # type: ignore[misc]
|
||||
response_format: Any | None = None
|
||||
|
||||
def _finalize_with_captured_format(updates: Sequence[ChatResponseUpdate]) -> ChatResponse[Any]:
|
||||
# ResponseStream only calls the finalizer after iterating or draining `_stream()`,
|
||||
# so `response_format` has already been populated from the validated request state
|
||||
# unless request setup failed before streaming began.
|
||||
return self._finalize_response_updates(updates, response_format=response_format)
|
||||
|
||||
async def _stream() -> AsyncIterable[ChatResponseUpdate]:
|
||||
|
||||
@@ -874,7 +874,11 @@ async def test_streaming_text_format_preserves_final_structured_output() -> None
|
||||
patch.object(client.client.responses, "stream", return_value=fake_stream_ctx),
|
||||
patch.object(client, "_get_metadata_from_response", return_value={}),
|
||||
):
|
||||
stream = client._inner_get_response(messages=[Message(role="user", contents=["Hi"])], options={}, stream=True)
|
||||
stream = client.get_response(
|
||||
messages=[Message(role="user", contents=["Hi"])],
|
||||
options={"response_format": OutputStruct},
|
||||
stream=True,
|
||||
)
|
||||
response = await stream.get_final_response()
|
||||
|
||||
assert response.model == "test-model"
|
||||
|
||||
Reference in New Issue
Block a user