Python: Refactor ag-ui to clean up some patterns (#2363)

* Refactor ag-ui to clean up some patterns

* Mypy fixes

* Fix imports, typing, tests, logging.

* Fix test import error

* Fix imports again

* Fix thread handling
This commit is contained in:
Evan Mattson
2025-11-27 11:13:03 +09:00
committed by GitHub
Unverified
parent 6c624319db
commit 8cf8b0f995
26 changed files with 1887 additions and 1415 deletions
@@ -876,7 +876,11 @@ class ChatAgent(BaseAgent):
)
# Filter chat_options from kwargs to prevent duplicate keyword argument
filtered_kwargs = {k: v for k, v in kwargs.items() if k != "chat_options"}
response = await self.chat_client.get_response(messages=thread_messages, chat_options=co, **filtered_kwargs)
response = await self.chat_client.get_response(
messages=thread_messages,
chat_options=co,
**filtered_kwargs,
)
await self._update_thread_with_type_and_conversation_id(thread, response.conversation_id)
@@ -1013,7 +1017,9 @@ class ChatAgent(BaseAgent):
filtered_kwargs = {k: v for k, v in kwargs.items() if k != "chat_options"}
response_updates: list[ChatResponseUpdate] = []
async for update in self.chat_client.get_streaming_response(
messages=thread_messages, chat_options=co, **filtered_kwargs
messages=thread_messages,
chat_options=co,
**filtered_kwargs,
):
response_updates.append(update)