Skip to content

Commit f272c0d

Browse files
committed
cookbook for manual task that is already planned without workers
1 parent fdd92f2 commit f272c0d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
File renamed without changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Manual Task Planned by User
2+
3+
## Using Mistral and Tavily
4+
5+
from openagi.planner.task_decomposer import TaskPlanner
6+
from openagi.actions.tools.tavilyqasearch import TavilyWebSearchQA
7+
from openagi.agent import Admin
8+
from openagi.llms.mistral import MistralModel
9+
10+
import os
11+
from getpass import getpass
12+
13+
# setup Gemini and Tavily API Key
14+
os.environ['TAVILY_API_KEY'] = getpass("Tavily API Key: ")
15+
os.environ['MISTRAL_API_KEY'] = getpass("Mistral API Key: ")
16+
17+
gemini_config = MistralModel.load_from_env_config()
18+
llm = MistralModel(config=gemini_config)
19+
20+
# define the planner
21+
plan = TaskPlanner(autonomous=True,human_intervene=True)
22+
23+
admin = Admin(
24+
actions = [TavilyWebSearchQA],
25+
planner = plan,
26+
llm = llm,
27+
)
28+
29+
already_planned = [{'worker_name': 'CricketNewsScraper', 'role': 'Cricket Data Extractor', 'instruction': 'Retrieve the latest cricket updates for the India vs Sri Lanka ODI series in 2024 from reliable sources.', 'task_id': '1', 'task_name': 'FetchCricketUpdates', 'description': "Use TavilyWebSearchQA to search for 'India vs Sri Lanka ODI series 2024 results' and extract the relevant information. Focus on finding the match scores, Man of the Match, and other key details. Handle any potential errors by retrying the search or providing a fallback message.", 'supported_actions': ['TavilyWebSearchQA']}, {'worker_name': 'CricketResultSummarizer', 'role': 'Data Processor', 'instruction': 'Analyze the retrieved cricket data and summarize the results for the user.', 'task_id': '2', 'task_name': 'SummarizeCricketResults', 'description': 'Use MemoryRagAction to access the results from the previous task. Extract the match scores, Man of the Match, and other key details. Format the information in a clear and concise manner for the user.', 'supported_actions': ['MemoryRagAction']}]
30+
31+
res = admin.run(
32+
query="I need cricket updates from India vs Sri lanka 2024 ODI match in Sri Lanka",
33+
description=f"give me the results of India vs Sri Lanka ODI and respective Man of the Match",
34+
planned_tasks = already_planned
35+
)
36+
print(res)

0 commit comments

Comments
 (0)