forked from i-am-bee/beeai-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
29 lines (21 loc) · 643 Bytes
/
base.py
File metadata and controls
29 lines (21 loc) · 643 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
import asyncio
import json
import sys
import traceback
from beeai_framework.emitter import Emitter
from beeai_framework.errors import FrameworkError
async def main() -> None:
# Get the root emitter or create your own
root = Emitter.root()
cleanup = root.match(
"*.*", lambda data, event: print(f"Received event '{event.path}' with data {json.dumps(data)}")
)
await root.emit("start", {"id": 123})
await root.emit("end", {"id": 123})
cleanup()
if __name__ == "__main__":
try:
asyncio.run(main())
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())