-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathsimple.py
29 lines (22 loc) · 1014 Bytes
/
simple.py
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 sys
import traceback
from beeai_framework.agents.react import ReActAgent, ReActAgentRunOutput
from beeai_framework.backend import ChatModel
from beeai_framework.errors import FrameworkError
from beeai_framework.memory import UnconstrainedMemory
from beeai_framework.tools.search.duckduckgo import DuckDuckGoSearchTool
from beeai_framework.tools.weather import OpenMeteoTool
async def main() -> None:
llm = ChatModel.from_name("ollama:granite3.1-dense:8b")
agent = ReActAgent(llm=llm, tools=[DuckDuckGoSearchTool(), OpenMeteoTool()], memory=UnconstrainedMemory())
output: ReActAgentRunOutput = await agent.run("What's the current weather in Las Vegas?").on(
"update", lambda data, event: print(f"Agent({data.update.key}) 🤖 : ", data.update.parsed_value)
)
print("Agent 🤖 : ", output.result.text)
if __name__ == "__main__":
try:
asyncio.run(main())
except FrameworkError as e:
traceback.print_exc()
sys.exit(e.explain())