mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
docs: remove EventHandler reference on docs
This commit is contained in:
@@ -677,18 +677,24 @@ CrewAI supports streaming responses from LLMs, allowing your application to rece
|
|||||||
CrewAI emits events for each chunk received during streaming:
|
CrewAI emits events for each chunk received during streaming:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from crewai import LLM
|
from crewai.utilities.events import (
|
||||||
from crewai.utilities.events import EventHandler, LLMStreamChunkEvent
|
LLMStreamChunkEvent
|
||||||
|
)
|
||||||
|
from crewai.utilities.events.base_event_listener import BaseEventListener
|
||||||
|
|
||||||
class MyEventHandler(EventHandler):
|
class MyCustomListener(BaseEventListener):
|
||||||
def on_llm_stream_chunk(self, event: LLMStreamChunkEvent):
|
def setup_listeners(self, crewai_event_bus):
|
||||||
# Process each chunk as it arrives
|
@crewai_event_bus.on(LLMStreamChunkEvent)
|
||||||
print(f"Received chunk: {event.chunk}")
|
def on_llm_stream_chunk(self, event: LLMStreamChunkEvent):
|
||||||
|
# Process each chunk as it arrives
|
||||||
|
print(f"Received chunk: {event.chunk}")
|
||||||
|
|
||||||
# Register the event handler
|
my_listener = MyCustomListener()
|
||||||
from crewai.utilities.events import crewai_event_bus
|
|
||||||
crewai_event_bus.register_handler(MyEventHandler())
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
[Click here](https://docs.crewai.com/concepts/event-listener#event-listeners) for more details
|
||||||
|
</Tip>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user