jamesbright commited on
Commit
7f1f750
·
verified ·
1 Parent(s): 1f48496

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -44
app.py CHANGED
@@ -11,7 +11,6 @@ model = HfApiModel(
11
  )
12
 
13
  class ProjectScopingTool(Tool):
14
-
15
  name = "project_scoping_tool"
16
  description = """
17
  Handles project scoping by collecting key details such as type, domain, budget, and timeline.
@@ -26,36 +25,30 @@ class ProjectScopingTool(Tool):
26
  "type": "string",
27
  "description": "The industry or field related to the project (e.g., 'finance', 'healthcare').",
28
  },
29
- "budget_min"
30
- : {
31
- "type": "number",
32
  "description": "The minimum budget allocated for the project.",
33
  },
34
  "budget_max": {
35
- "type": "number",
36
  "description": "The maximum budget allocated for the project.",
37
  },
38
  "timeline_months": {
39
- "type": "number",
40
  "description": "The expected duration of the project in months.",
41
  },
42
  }
43
 
44
- output_type = "string"
45
 
46
  def forward(self, project_type: str, domain: str, budget_min: float, budget_max: float, timeline_months: int):
47
-
48
- """
49
- Collects and structures project details from user input.
50
- """
51
- self.project_details = {
52
  "type": project_type,
53
  "domain": domain,
54
-
55
  "budget_range": {"min": budget_min, "max": budget_max},
56
  "timeline": {"months": timeline_months}
57
  }
58
- return json.dumps(self.project_details, indent=2)
59
 
60
  class TechnicalArchitectureTool(Tool):
61
  name = "technical_architecture_tool"
@@ -70,10 +63,9 @@ class TechnicalArchitectureTool(Tool):
70
  }
71
  }
72
 
73
- output_type = "string"
74
 
75
  def forward(self, project_type: str):
76
-
77
  architectures = {
78
  "web": {
79
  "frontend": ["React", "Next.js", "Tailwind"],
@@ -101,19 +93,18 @@ class CostEstimationTool(Tool):
101
 
102
  inputs = {
103
  "architecture_size": {
104
- "type": "number",
105
  "description": "The estimated complexity of the architecture on a scale from 1 to 10.",
106
  },
107
  "timeline_months": {
108
- "type": "number",
109
  "description": "The project duration in months.",
110
  }
111
  }
112
 
113
- output_type = "string"
114
 
115
  def forward(self, architecture_size: int, timeline_months: int):
116
-
117
  base_costs = {
118
  "development": 5000 * (architecture_size * 0.5),
119
  "infrastructure": 500 * (architecture_size * 0.3),
@@ -130,10 +121,9 @@ class DeploymentTool(Tool):
130
 
131
  inputs = {}
132
 
133
- output_type = "string"
134
 
135
  def forward(self):
136
-
137
  return json.dumps({
138
  "container_strategy": "Docker + Kubernetes",
139
  "cloud_provider": "AWS",
@@ -154,10 +144,9 @@ class MeetingPreparationTool(Tool):
154
  }
155
  }
156
 
157
- output_type = "string"
158
 
159
  def forward(self, project_stage: str):
160
-
161
  agendas = {
162
  "initial_discovery": [
163
  "Project Vision Validation",
@@ -173,24 +162,18 @@ class MeetingPreparationTool(Tool):
173
  return json.dumps(agendas.get(project_stage, "No agenda found for this stage"), indent=2)
174
 
175
  # Instantiate tools
176
- scoping_tool = ProjectScopingTool()
177
- tech_arch_tool = TechnicalArchitectureTool()
178
- cost_tool = CostEstimationTool()
179
- deploy_tool = DeploymentTool()
180
- meeting_tool = MeetingPreparationTool()
181
-
182
- # Define the agent
183
  tools = [
184
- scoping_tool,
185
- tech_arch_tool,
186
- cost_tool,
187
- deploy_tool,
188
- meeting_tool
189
  ]
190
 
 
191
  agent = CodeAgent(
192
  model=model,
193
- tools=[tools], # add your tools here (don't remove final_answer)
194
  max_steps=6,
195
  verbosity_level=1,
196
  name="webchainai",
@@ -217,11 +200,11 @@ with gr.Blocks() as demo:
217
  meeting_output = gr.Textbox(label="Meeting Agenda", interactive=False)
218
 
219
  def process_inputs(p_type, dom, min_b, max_b, months):
220
- project_details = scoping_tool.collect_project_details(p_type, dom, min_b, max_b, months)
221
- architecture = tech_arch_tool.generate_architecture(p_type)
222
- estimated_cost = cost_tool.estimate_project_cost(len(architecture), months)
223
- deployment_strategy = deploy_tool.generate_deployment_strategy()
224
- meeting_agenda = meeting_tool.generate_meeting_agenda("initial_discovery")
225
  return project_details, architecture, estimated_cost, deployment_strategy, meeting_agenda
226
 
227
  process_button = gr.Button("Generate Estimates")
@@ -229,5 +212,4 @@ with gr.Blocks() as demo:
229
  outputs=[project_output, arch_output, cost_output, deploy_output, meeting_output])
230
 
231
  # Launch the Gradio App
232
- demo(agent).launch()
233
-
 
11
  )
12
 
13
  class ProjectScopingTool(Tool):
 
14
  name = "project_scoping_tool"
15
  description = """
16
  Handles project scoping by collecting key details such as type, domain, budget, and timeline.
 
25
  "type": "string",
26
  "description": "The industry or field related to the project (e.g., 'finance', 'healthcare').",
27
  },
28
+ "budget_min": {
29
+ "type": "float",
 
30
  "description": "The minimum budget allocated for the project.",
31
  },
32
  "budget_max": {
33
+ "type": "float",
34
  "description": "The maximum budget allocated for the project.",
35
  },
36
  "timeline_months": {
37
+ "type": "int",
38
  "description": "The expected duration of the project in months.",
39
  },
40
  }
41
 
42
+ output_type = "json"
43
 
44
  def forward(self, project_type: str, domain: str, budget_min: float, budget_max: float, timeline_months: int):
45
+ project_details = {
 
 
 
 
46
  "type": project_type,
47
  "domain": domain,
 
48
  "budget_range": {"min": budget_min, "max": budget_max},
49
  "timeline": {"months": timeline_months}
50
  }
51
+ return json.dumps(project_details, indent=2)
52
 
53
  class TechnicalArchitectureTool(Tool):
54
  name = "technical_architecture_tool"
 
63
  }
64
  }
65
 
66
+ output_type = "json"
67
 
68
  def forward(self, project_type: str):
 
69
  architectures = {
70
  "web": {
71
  "frontend": ["React", "Next.js", "Tailwind"],
 
93
 
94
  inputs = {
95
  "architecture_size": {
96
+ "type": "int",
97
  "description": "The estimated complexity of the architecture on a scale from 1 to 10.",
98
  },
99
  "timeline_months": {
100
+ "type": "int",
101
  "description": "The project duration in months.",
102
  }
103
  }
104
 
105
+ output_type = "json"
106
 
107
  def forward(self, architecture_size: int, timeline_months: int):
 
108
  base_costs = {
109
  "development": 5000 * (architecture_size * 0.5),
110
  "infrastructure": 500 * (architecture_size * 0.3),
 
121
 
122
  inputs = {}
123
 
124
+ output_type = "json"
125
 
126
  def forward(self):
 
127
  return json.dumps({
128
  "container_strategy": "Docker + Kubernetes",
129
  "cloud_provider": "AWS",
 
144
  }
145
  }
146
 
147
+ output_type = "json"
148
 
149
  def forward(self, project_stage: str):
 
150
  agendas = {
151
  "initial_discovery": [
152
  "Project Vision Validation",
 
162
  return json.dumps(agendas.get(project_stage, "No agenda found for this stage"), indent=2)
163
 
164
  # Instantiate tools
 
 
 
 
 
 
 
165
  tools = [
166
+ ProjectScopingTool(),
167
+ TechnicalArchitectureTool(),
168
+ CostEstimationTool(),
169
+ DeploymentTool(),
170
+ MeetingPreparationTool()
171
  ]
172
 
173
+ # Define the agent
174
  agent = CodeAgent(
175
  model=model,
176
+ tools=tools, # Fixed tools list format
177
  max_steps=6,
178
  verbosity_level=1,
179
  name="webchainai",
 
200
  meeting_output = gr.Textbox(label="Meeting Agenda", interactive=False)
201
 
202
  def process_inputs(p_type, dom, min_b, max_b, months):
203
+ project_details = tools[0].forward(p_type, dom, min_b, max_b, months)
204
+ architecture = tools[1].forward(p_type)
205
+ estimated_cost = tools[2].forward(5, months) # Example architecture size
206
+ deployment_strategy = tools[3].forward()
207
+ meeting_agenda = tools[4].forward("initial_discovery")
208
  return project_details, architecture, estimated_cost, deployment_strategy, meeting_agenda
209
 
210
  process_button = gr.Button("Generate Estimates")
 
212
  outputs=[project_output, arch_output, cost_output, deploy_output, meeting_output])
213
 
214
  # Launch the Gradio App
215
+ demo.launch()