Docs Updates (#2840)
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled

* docs: remove EventHandler reference on docs

* docs: add section explaining how to run a Crew from CrewBase
This commit is contained in:
Lucas Gomide
2025-05-15 10:17:21 -03:00
committed by GitHub
parent c566747d4a
commit 49bbf3f234
2 changed files with 26 additions and 9 deletions

View File

@@ -117,6 +117,12 @@ class YourCrewName:
) )
``` ```
How to run the above code:
```python code
YourCrewName().crew().kickoff(inputs={"any": "input here"})
```
<Note> <Note>
Tasks will be executed in the order they are defined. Tasks will be executed in the order they are defined.
</Note> </Note>
@@ -184,6 +190,11 @@ class YourCrewName:
verbose=True verbose=True
) )
``` ```
How to run the above code:
```python code
YourCrewName().crew().kickoff(inputs={})
```
In this example: In this example:

View File

@@ -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>