Skip to content

Commit 550d24d

Browse files
authored
Merge branch 'main' into feat/webzio-news-search-tool
2 parents 0cdbbe4 + 1f3e611 commit 550d24d

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

lib/crewai/src/crewai/types/streaming.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,15 @@ class CrewStreamingOutput(StreamingOutputBase["CrewOutput"]):
504504
505505
Example:
506506
```python
507-
# Single crew
507+
# Single crew — the crew must be constructed with stream=True
508+
crew = Crew(agents=[...], tasks=[...], stream=True)
508509
streaming = crew.kickoff(inputs={"topic": "AI"})
509510
for chunk in streaming:
510511
print(chunk.content, end="", flush=True)
511512
result = streaming.result
512513
513-
# Multiple crews (kickoff_for_each_async)
514+
# Multiple crews (kickoff_for_each_async) — also requires stream=True
515+
crew = Crew(agents=[...], tasks=[...], stream=True)
514516
streaming = await crew.kickoff_for_each_async(
515517
[{"topic": "AI"}, {"topic": "ML"}]
516518
)
@@ -580,22 +582,35 @@ class FlowStreamingOutput(StreamingOutputBase[Any]):
580582
"""Streaming output wrapper for flow execution.
581583
582584
Provides both sync and async iteration over stream chunks,
583-
with access to the final flow output via the .result property.
585+
with access to the final flow output via the ``.result`` property.
584586
585587
Example:
586588
```python
587-
# Sync usage
588-
streaming = flow.kickoff_streaming()
589-
for chunk in streaming:
590-
print(chunk.content, end="", flush=True)
589+
# Flow-level streaming returns a StreamSession from Flow.kickoff() —
590+
# NOT a FlowStreamingOutput. See
591+
# docs/edge/en/learn/streaming-flow-execution.mdx for the full guide.
592+
flow = MyFlow()
593+
flow.stream = True
594+
streaming = flow.kickoff() # -> StreamSession
595+
for frame in streaming:
596+
print(frame.content, end="", flush=True)
591597
result = streaming.result
592598
593-
# Async usage
594-
streaming = await flow.kickoff_streaming_async()
595-
async for chunk in streaming:
596-
print(chunk.content, end="", flush=True)
599+
# Async variant:
600+
flow = MyFlow()
601+
flow.stream = True
602+
streaming = await flow.kickoff_async() # -> AsyncStreamSession
603+
async for frame in streaming:
604+
print(frame.content, end="", flush=True)
597605
result = streaming.result
598606
```
607+
608+
Note:
609+
Flow-level streaming is exposed to users through
610+
:class:`StreamSession`; configure the Flow with ``stream=True``
611+
before calling ``Flow.kickoff()``. ``FlowStreamingOutput`` is
612+
retained for consumers that build a streaming wrapper directly
613+
from an existing iterator.
599614
"""
600615

601616
def _set_result(self, result: Any) -> None:

0 commit comments

Comments
 (0)