Skip to content

Commit 89457c5

Browse files
authored
docs: fix ChatResponse async aggregation example (#9518)
1 parent 74f3447 commit 89457c5

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • python/packages/core/agent_framework

‎python/packages/core/agent_framework/_types.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,13 +3294,16 @@ async def from_update_generator(
32943294
Example:
32953295
.. code-block:: python
32963296
3297-
from agent_framework import ChatResponse, ChatResponseUpdate, ChatClient
3297+
from agent_framework import ChatResponse, ChatResponseUpdate, Content
32983298
3299-
client = ChatClient() # should be a concrete implementation
3300-
response = await ChatResponse.from_update_generator(
3301-
client.get_streaming_response("Hello, how are you?")
3302-
)
3303-
print(response.text)
3299+
3300+
async def updates():
3301+
yield ChatResponseUpdate(contents=[Content.from_text(text="Hello")], role="assistant")
3302+
yield ChatResponseUpdate(contents=[Content.from_text(text=" How can I help you?")])
3303+
3304+
3305+
response = await ChatResponse.from_update_generator(updates())
3306+
print(response.text) # "Hello How can I help you?"
33043307
33053308
Args:
33063309
updates: An async iterable of ChatResponseUpdate objects to combine.

0 commit comments

Comments
 (0)