forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_matchers.py
More file actions
32 lines (25 loc) · 894 Bytes
/
agent_matchers.py
File metadata and controls
32 lines (25 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import asyncio
import sys
import traceback
from beeai_framework.adapters.ollama import OllamaChatModel
from beeai_framework.agents.react import ReActAgent
from beeai_framework.errors import FrameworkError
from beeai_framework.memory import UnconstrainedMemory
async def main() -> None:
agent = ReActAgent(
llm=OllamaChatModel("llama3.1"),
memory=UnconstrainedMemory(),
tools=[],
)
# Matching events on the instance level
agent.emitter.match("*.*", lambda data, event: None)
# Matching events on the execution (run) level
await agent.run("Hello agent!").observe(
lambda emitter: emitter.match("*.*", lambda data, event: print(f"RUN LOG: received event '{event.path}'"))
)
if __name__ == "__main__":
try:
asyncio.run(main())
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())