55import webbrowser
66from art import text2art
77from agentstack import log
8+ from agentstack .frameworks import SUPPORTED_FRAMEWORKS
89from agentstack .utils import open_json_file , is_snake_case
910from agentstack .cli import welcome_message , get_validated_input
11+ from agentstack .cli .cli import PREFERRED_MODELS
12+ from agentstack ._tools import get_all_tools , get_all_tool_names
1013from agentstack .proj_templates import TemplateConfig
1114
1215
13- def run_wizard (slug_name : str ) -> TemplateConfig :
14- raise NotImplementedError ("TODO wizard functionality needs to be migrated" )
16+ class WizardData (dict ):
17+ def to_template_config (self ) -> TemplateConfig :
18+ agents = []
19+ for agent in self ['design' ]['agents' ]:
20+ agents .append (TemplateConfig .Agent (** {
21+ 'name' : agent ['name' ],
22+ 'role' : agent ['role' ],
23+ 'goal' : agent ['goal' ],
24+ 'backstory' : agent ['backstory' ],
25+ 'llm' : agent ['model' ],
26+ }))
27+
28+ tasks = []
29+ for task in self ['design' ]['tasks' ]:
30+ tasks .append (TemplateConfig .Task (** {
31+ 'name' : task ['name' ],
32+ 'description' : task ['description' ],
33+ 'expected_output' : task ['expected_output' ],
34+ 'agent' : task ['agent' ],
35+ }))
36+
37+ tools = []
38+ for tool in self ['tools' ]:
39+ tools .append (TemplateConfig .Tool (** {
40+ 'name' : tool ,
41+ 'agents' : [agent .name for agent in agents ], # all agents
42+ }))
43+
44+ return TemplateConfig (
45+ name = self ['project' ]['name' ],
46+ description = self ['project' ]['description' ],
47+ template_version = 4 ,
48+ framework = self ['framework' ],
49+ method = 'sequential' ,
50+ manager_agent = None ,
51+ agents = agents ,
52+ tasks = tasks ,
53+ tools = tools ,
54+ graph = [],
55+ inputs = {},
56+ )
1557
58+
59+ def run_wizard (slug_name : str ) -> TemplateConfig :
1660 project_details = ask_project_details (slug_name )
1761 welcome_message ()
1862 framework = ask_framework ()
1963 design = ask_design ()
2064 tools = ask_tools ()
21- # TODO return TemplateConfig object
65+
66+ wizard_data = WizardData ({
67+ 'project' : project_details ,
68+ 'framework' : framework ,
69+ 'design' : design ,
70+ 'tools' : tools ,
71+ })
72+ return wizard_data .to_template_config ()
2273
2374
2475def ask_framework () -> str :
25- framework = "CrewAI"
26- # framework = inquirer.list_input(
27- # message="What agent framework do you want to use?",
28- # choices=["CrewAI", "Autogen", "LiteLLM", "Learn what these are (link)"],
29- # )
76+ framework = inquirer .list_input (
77+ message = "What agent framework do you want to use?" ,
78+ choices = SUPPORTED_FRAMEWORKS ,
79+ )
3080 #
3181 # if framework == "Learn what these are (link)":
3282 # webbrowser.open("https://youtu.be/xvFZjo5PgG0")
@@ -42,8 +92,7 @@ def ask_framework() -> str:
4292 # choices=["CrewAI", "Autogen", "LiteLLM"],
4393 # )
4494
45- log .success ("Congrats! Your project is ready to go! Quickly add features now or skip to do it later.\n \n " )
46-
95+ #log.success("Congrats! Your project is ready to go! Quickly add features now or skip to do it later.\n\n")
4796 return framework
4897
4998
@@ -157,20 +206,28 @@ def ask_tools() -> list:
157206 tools_to_add = []
158207
159208 adding_tools = True
160- script_dir = os .path .dirname (os .path .abspath (__file__ ))
161- tools_json_path = os .path .join (script_dir , '..' , 'tools' , 'tools.json' )
162-
163- # Load the JSON data
164- tools_data = open_json_file (tools_json_path )
209+ tool_configs = get_all_tools ()
165210
166211 while adding_tools :
212+ tool_categories = []
213+ for tool_config in tool_configs :
214+ if tool_config .category not in tool_categories :
215+ tool_categories .append (tool_config .category )
216+
167217 tool_type = inquirer .list_input (
168218 message = "What category tool do you want to add?" ,
169- choices = list ( tools_data . keys ()) + ["~~ Stop adding tools ~~" ],
219+ choices = tool_categories + ["~~ Stop adding tools ~~" ],
170220 )
171221
172- tools_in_cat = [f"{ t ['name' ]} - { t ['url' ]} " for t in tools_data [tool_type ] if t not in tools_to_add ]
173- tool_selection = inquirer .list_input (message = "Select your tool" , choices = tools_in_cat )
222+ tools_in_cat = []
223+ for tool_config in tool_configs :
224+ if tool_config .category == tool_type :
225+ tools_in_cat .append (tool_config )
226+
227+ tool_selection = inquirer .list_input (
228+ message = "Select your tool" ,
229+ choices = [f"{ t .name } - { t .url } " for t in tools_in_cat if t not in tools_to_add ],
230+ )
174231
175232 tools_to_add .append (tool_selection .split (' - ' )[0 ])
176233
0 commit comments