forked from agentstack-ai/AgentStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_generation.py
More file actions
39 lines (34 loc) · 1.25 KB
/
agent_generation.py
File metadata and controls
39 lines (34 loc) · 1.25 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
36
37
38
39
import sys
from typing import Optional
from pathlib import Path
from agentstack import ValidationError
from agentstack import frameworks
from agentstack.utils import verify_agentstack_project
from agentstack.agents import AgentConfig, AGENTS_FILENAME
from agentstack.generation.files import ConfigFile
def add_agent(
agent_name: str,
role: Optional[str] = None,
goal: Optional[str] = None,
backstory: Optional[str] = None,
llm: Optional[str] = None,
path: Optional[Path] = None,
):
if path is None:
path = Path()
verify_agentstack_project(path)
agentstack_config = ConfigFile(path)
framework = agentstack_config.framework
agent = AgentConfig(agent_name, path)
with agent as config:
config.role = role or "Add your role here"
config.goal = goal or "Add your goal here"
config.backstory = backstory or "Add your backstory here"
config.llm = llm or agentstack_config.default_model or ""
try:
frameworks.add_agent(framework, agent, path)
print(f" > Added to {AGENTS_FILENAME}")
except ValidationError as e:
print(f"Error adding agent to project:\n{e}")
sys.exit(1)
print(f"Added agent \"{agent_name}\" to your AgentStack project successfully!")