Skip to content

Commit 49bbf3f

Browse files
authored
Docs Updates (#2840)
* docs: remove EventHandler reference on docs * docs: add section explaining how to run a Crew from CrewBase
1 parent c566747 commit 49bbf3f

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

docs/concepts/crews.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ class YourCrewName:
117117
)
118118
```
119119

120+
How to run the above code:
121+
122+
```python code
123+
YourCrewName().crew().kickoff(inputs={"any": "input here"})
124+
```
125+
120126
<Note>
121127
Tasks will be executed in the order they are defined.
122128
</Note>
@@ -184,6 +190,11 @@ class YourCrewName:
184190
verbose=True
185191
)
186192
```
193+
How to run the above code:
194+
195+
```python code
196+
YourCrewName().crew().kickoff(inputs={})
197+
```
187198

188199
In this example:
189200

docs/concepts/llms.mdx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -677,18 +677,24 @@ CrewAI supports streaming responses from LLMs, allowing your application to rece
677677
CrewAI emits events for each chunk received during streaming:
678678

679679
```python
680-
from crewai import LLM
681-
from crewai.utilities.events import EventHandler, LLMStreamChunkEvent
680+
from crewai.utilities.events import (
681+
LLMStreamChunkEvent
682+
)
683+
from crewai.utilities.events.base_event_listener import BaseEventListener
682684

683-
class MyEventHandler(EventHandler):
684-
def on_llm_stream_chunk(self, event: LLMStreamChunkEvent):
685-
# Process each chunk as it arrives
686-
print(f"Received chunk: {event.chunk}")
685+
class MyCustomListener(BaseEventListener):
686+
def setup_listeners(self, crewai_event_bus):
687+
@crewai_event_bus.on(LLMStreamChunkEvent)
688+
def on_llm_stream_chunk(self, event: LLMStreamChunkEvent):
689+
# Process each chunk as it arrives
690+
print(f"Received chunk: {event.chunk}")
687691

688-
# Register the event handler
689-
from crewai.utilities.events import crewai_event_bus
690-
crewai_event_bus.register_handler(MyEventHandler())
692+
my_listener = MyCustomListener()
691693
```
694+
695+
<Tip>
696+
[Click here](https://docs.crewai.com/concepts/event-listener#event-listeners) for more details
697+
</Tip>
692698
</Tab>
693699
</Tabs>
694700

0 commit comments

Comments
 (0)