forked from agentstack-ai/AgentStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_generation.py
More file actions
35 lines (30 loc) · 1.12 KB
/
task_generation.py
File metadata and controls
35 lines (30 loc) · 1.12 KB
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
33
34
35
import sys
from typing import Optional
from pathlib import Path
from agentstack.exceptions import ValidationError
from agentstack import frameworks
from agentstack.utils import verify_agentstack_project
from agentstack.tasks import TaskConfig, TASKS_FILENAME
def add_task(
task_name: str,
description: Optional[str] = None,
expected_output: Optional[str] = None,
agent: Optional[str] = None,
):
verify_agentstack_project()
agents = frameworks.get_agent_names()
if not agent and len(agents) == 1:
# if there's only one agent, use it by default
agent = agents[0]
task = TaskConfig(task_name)
with task as config:
config.description = description or "Add your description here"
config.expected_output = expected_output or "Add your expected_output here"
config.agent = agent or "agent_name"
try:
frameworks.add_task(task)
print(f" > Added to {TASKS_FILENAME}")
except ValidationError as e:
print(f"Error adding task to project:\n{e}")
sys.exit(1)
print(f"Added task \"{task_name}\" to your AgentStack project successfully!")