RozzaCreat commited on
Commit
df9e5de
·
verified ·
1 Parent(s): f1cb32a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +99 -103
app.py CHANGED
@@ -1,5 +1,8 @@
1
  from smolagents import CodeAgent, HfApiModel, tool
2
  import yaml
 
 
 
3
 
4
  @tool
5
  def udp_advisor(development_phase: str, team_size: int, project_complexity: str) -> str:
@@ -34,72 +37,72 @@ def udp_advisor(development_phase: str, team_size: int, project_complexity: str)
34
  udp_tools = {
35
  "planning": {
36
  "low": [
37
- {"name": "Trello", "category": "Project Management", "complexity": "Low", "description": "Simple kanban board for task tracking"},
38
- {"name": "GitHub Projects", "category": "Project Management", "complexity": "Low", "description": "Basic project management integrated with GitHub"}
39
  ],
40
  "medium": [
41
- {"name": "Jira", "category": "Project Management", "complexity": "Medium", "description": "Comprehensive agile project management tool"},
42
- {"name": "Azure DevOps Boards", "category": "Project Management", "complexity": "Medium", "description": "Project tracking with Azure integration"}
43
  ],
44
  "high": [
45
- {"name": "Monday.com", "category": "Project Management", "complexity": "High", "description": "Customizable workflow platform for complex projects"},
46
- {"name": "Rally", "category": "Project Management", "complexity": "High", "description": "Enterprise-scale agile management and portfolio planning"}
47
  ]
48
  },
49
  "development": {
50
  "low": [
51
- {"name": "GitHub", "category": "Version Control", "complexity": "Low", "description": "Popular code hosting platform with basic CI/CD"},
52
- {"name": "VS Code", "category": "IDE", "complexity": "Low", "description": "Lightweight, extensible code editor"}
53
  ],
54
  "medium": [
55
- {"name": "GitLab", "category": "DevOps Platform", "complexity": "Medium", "description": "Integrated DevOps platform with built-in CI/CD"},
56
- {"name": "JetBrains IDEs", "category": "IDE", "complexity": "Medium", "description": "Language-specific professional IDEs"}
57
  ],
58
  "high": [
59
- {"name": "Bitbucket + Bamboo", "category": "Enterprise DevOps", "complexity": "High", "description": "Atlassian's integrated code and CI/CD solution"},
60
- {"name": "GitHub Enterprise", "category": "Enterprise DevOps", "complexity": "High", "description": "Self-hosted, compliant GitHub with advanced security"}
61
  ]
62
  },
63
  "testing": {
64
  "low": [
65
- {"name": "Jest", "category": "Testing Framework", "complexity": "Low", "description": "JavaScript testing framework with minimal configuration"},
66
- {"name": "GitHub Actions", "category": "CI/CD", "complexity": "Low", "description": "Simple workflow automation integrated with GitHub"}
67
  ],
68
  "medium": [
69
- {"name": "Jenkins", "category": "CI/CD", "complexity": "Medium", "description": "Flexible automation server for building, testing, and deployment"},
70
- {"name": "Selenium", "category": "Testing", "complexity": "Medium", "description": "Browser automation for web application testing"}
71
  ],
72
  "high": [
73
- {"name": "Azure DevOps Pipelines", "category": "CI/CD", "complexity": "High", "description": "Enterprise-grade pipelines with extensive integration"},
74
- {"name": "SonarQube", "category": "Code Quality", "complexity": "High", "description": "Advanced code quality and security platform"}
75
  ]
76
  },
77
  "deployment": {
78
  "low": [
79
- {"name": "Netlify", "category": "Hosting", "complexity": "Low", "description": "Simple deployment platform for frontend applications"},
80
- {"name": "Heroku", "category": "PaaS", "complexity": "Low", "description": "Platform-as-a-Service with simplified deployment"}
81
  ],
82
  "medium": [
83
- {"name": "Docker", "category": "Containerization", "complexity": "Medium", "description": "Container platform for application packaging"},
84
- {"name": "AWS Elastic Beanstalk", "category": "PaaS", "complexity": "Medium", "description": "Easy-to-use service for deploying applications"}
85
  ],
86
  "high": [
87
- {"name": "Kubernetes", "category": "Container Orchestration", "complexity": "High", "description": "Production-grade container orchestration"},
88
- {"name": "Terraform", "category": "IaC", "complexity": "High", "description": "Infrastructure as Code for multi-cloud deployment"}
89
  ]
90
  },
91
  "monitoring": {
92
  "low": [
93
- {"name": "Uptime Robot", "category": "Monitoring", "complexity": "Low", "description": "Simple uptime monitoring for websites"},
94
- {"name": "Sentry", "category": "Error Tracking", "complexity": "Low", "description": "Application error monitoring"}
95
  ],
96
  "medium": [
97
- {"name": "Grafana", "category": "Observability", "complexity": "Medium", "description": "Metrics visualization and dashboards"},
98
- {"name": "New Relic", "category": "APM", "complexity": "Medium", "description": "Application performance monitoring"}
99
  ],
100
  "high": [
101
- {"name": "Prometheus", "category": "Monitoring", "complexity": "High", "description": "Advanced metrics collection and alerting system"},
102
- {"name": "Datadog", "category": "Observability", "complexity": "High", "description": "Full-stack observability platform"}
103
  ]
104
  }
105
  }
@@ -107,22 +110,32 @@ def udp_advisor(development_phase: str, team_size: int, project_complexity: str)
107
  # Team size categorization
108
  team_category = "small" if team_size < 10 else "medium" if team_size < 50 else "large"
109
 
110
- # Get tool recommendations
 
111
  tools_for_phase = udp_tools[development_phase][project_complexity]
112
 
 
 
 
 
 
113
  # Format response
114
  response = f"## UDP Tool Recommendations\n\n"
115
  response += f"**Development Phase:** {development_phase.capitalize()}\n"
116
  response += f"**Team Size:** {team_size} ({team_category} team)\n"
117
  response += f"**Project Complexity:** {project_complexity.capitalize()}\n\n"
118
 
119
- response += "### Recommended Tools\n\n"
120
-
121
- for tool in tools_for_phase:
122
- response += f"**{tool['name']}**\n"
123
- response += f"- Category: {tool['category']}\n"
124
- response += f"- Complexity: {tool['complexity']}\n"
125
- response += f"- Description: {tool['description']}\n\n"
 
 
 
 
126
 
127
  # Additional phase-specific advice
128
  if development_phase == "planning":
@@ -151,25 +164,24 @@ def udp_advisor(development_phase: str, team_size: int, project_complexity: str)
151
  response += "- Establish incident response processes\n"
152
  response += "- Regularly review logs and performance data\n"
153
 
154
- response += "\n### UDP Learning Resources\n"
155
- response += "- [Unified Development Platforms Study Guide](https://ds-an.github.io/udp-study-guide/)\n"
156
- response += "- [DevOps Roadmap](https://roadmap.sh/devops)\n"
157
- response += "- [GitHub Learning Lab](https://lab.github.com/)\n"
 
158
 
159
  return response
160
 
161
- # Import final answer tool
162
- from tools.final_answer import FinalAnswerTool
163
  final_answer = FinalAnswerTool()
164
 
165
- # Configure the language model
166
  model = HfApiModel(
167
- max_tokens=1024,
168
- temperature=0.7,
169
- model_id='Qwen/Qwen2.5-7B-Instruct' # Using a smaller model for educational purposes
170
  )
171
 
172
- # Define prompt templates
173
  udp_prompt_templates = {
174
  "react-system": """You are a UDP (Unified Development Platform) advisor who helps users choose appropriate tools for their software development projects.
175
  You have access to the following tools:
@@ -177,9 +189,9 @@ You have access to the following tools:
177
  {tools_string}
178
 
179
  You should help the user determine which UDP tools are best for their project based on:
180
- 1. The current development phase they are in
181
  2. The size of their development team
182
- 3. The complexity of their project
183
 
184
  Use the udp_advisor tool to analyze these factors and provide tool recommendations.
185
 
@@ -192,6 +204,7 @@ Always use Python syntax for calling tools. After using a tool, analyze the resu
192
  """,
193
  "react-human": "{input_string}",
194
  "react-assistant": "{agent_response}",
 
195
  }
196
 
197
  # Load prompt templates from file or use our templates
@@ -212,59 +225,42 @@ agent = CodeAgent(
212
  )
213
 
214
  # Create a custom Gradio UI
215
- def create_udp_advisor_ui():
216
- import gradio as gr
217
-
218
- with gr.Blocks(theme=gr.themes.Base()) as demo:
219
- gr.Markdown("# UDP Advisor for Software Development Projects")
220
- gr.Markdown("Get tool recommendations for your Unified Development Platform")
221
-
222
- with gr.Row():
223
- with gr.Column():
224
- phase_input = gr.Radio(
225
- ["Planning", "Development", "Testing", "Deployment", "Monitoring"],
226
- label="Development Phase"
227
- )
228
- team_input = gr.Slider(
229
- minimum=1,
230
- maximum=100,
231
- step=1,
232
- value=5,
233
- label="Team Size"
234
- )
235
- complexity_input = gr.Radio(
236
- ["Low", "Medium", "High"],
237
- label="Project Complexity"
238
- )
239
- submit_btn = gr.Button("Get Recommendations", variant="primary")
240
 
241
- with gr.Row():
242
- with gr.Column():
243
- recommendation_output = gr.Markdown(label="UDP Recommendations")
244
-
245
- def get_recommendations(phase, team_size, complexity):
246
- if not phase:
247
- return "Please select a development phase."
248
- if not team_size or team_size < 1:
249
- return "Please provide a valid team size (at least 1)."
250
- if not complexity:
251
- return "Please select a project complexity level."
252
 
253
- try:
254
- recommendations = udp_advisor(phase.lower(), int(team_size), complexity.lower())
255
- return recommendations
256
- except Exception as e:
257
- return f"Error generating recommendations: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
- submit_btn.click(
260
- get_recommendations,
261
- inputs=[phase_input, team_input, complexity_input],
262
- outputs=recommendation_output
263
- )
264
-
265
- return demo
266
 
267
- # Launch the application
268
- if __name__ == "__main__":
269
- demo = create_udp_advisor_ui()
270
- demo.launch()
 
1
  from smolagents import CodeAgent, HfApiModel, tool
2
  import yaml
3
+ import math
4
+ from tools.final_answer import FinalAnswerTool
5
+ from Gradio_UI import GradioUI
6
 
7
  @tool
8
  def udp_advisor(development_phase: str, team_size: int, project_complexity: str) -> str:
 
37
  udp_tools = {
38
  "planning": {
39
  "low": [
40
+ {"name": "Trello", "category": "Project Management", "complexity": "Low", "min_team_size": 1, "description": "Simple kanban board for task tracking"},
41
+ {"name": "GitHub Projects", "category": "Project Management", "complexity": "Low", "min_team_size": 1, "description": "Basic project management integrated with GitHub"}
42
  ],
43
  "medium": [
44
+ {"name": "Jira", "category": "Project Management", "complexity": "Medium", "min_team_size": 5, "description": "Comprehensive agile project management tool"},
45
+ {"name": "Azure DevOps Boards", "category": "Project Management", "complexity": "Medium", "min_team_size": 5, "description": "Project tracking with Azure integration"}
46
  ],
47
  "high": [
48
+ {"name": "Monday.com", "category": "Project Management", "complexity": "High", "min_team_size": 10, "description": "Customizable workflow platform for complex projects"},
49
+ {"name": "Rally", "category": "Project Management", "complexity": "High", "min_team_size": 20, "description": "Enterprise-scale agile management and portfolio planning"}
50
  ]
51
  },
52
  "development": {
53
  "low": [
54
+ {"name": "GitHub", "category": "Version Control", "complexity": "Low", "min_team_size": 1, "description": "Popular code hosting platform with basic CI/CD"},
55
+ {"name": "VS Code", "category": "IDE", "complexity": "Low", "min_team_size": 1, "description": "Lightweight, extensible code editor"}
56
  ],
57
  "medium": [
58
+ {"name": "GitLab", "category": "DevOps Platform", "complexity": "Medium", "min_team_size": 5, "description": "Integrated DevOps platform with built-in CI/CD"},
59
+ {"name": "JetBrains IDEs", "category": "IDE", "complexity": "Medium", "min_team_size": 1, "description": "Language-specific professional IDEs"}
60
  ],
61
  "high": [
62
+ {"name": "Bitbucket + Bamboo", "category": "Enterprise DevOps", "complexity": "High", "min_team_size": 10, "description": "Atlassian's integrated code and CI/CD solution"},
63
+ {"name": "GitHub Enterprise", "category": "Enterprise DevOps", "complexity": "High", "min_team_size": 20, "description": "Self-hosted, compliant GitHub with advanced security"}
64
  ]
65
  },
66
  "testing": {
67
  "low": [
68
+ {"name": "Jest", "category": "Testing Framework", "complexity": "Low", "min_team_size": 1, "description": "JavaScript testing framework with minimal configuration"},
69
+ {"name": "GitHub Actions", "category": "CI/CD", "complexity": "Low", "min_team_size": 1, "description": "Simple workflow automation integrated with GitHub"}
70
  ],
71
  "medium": [
72
+ {"name": "Jenkins", "category": "CI/CD", "complexity": "Medium", "min_team_size": 3, "description": "Flexible automation server for building, testing, and deployment"},
73
+ {"name": "Selenium", "category": "Testing", "complexity": "Medium", "min_team_size": 2, "description": "Browser automation for web application testing"}
74
  ],
75
  "high": [
76
+ {"name": "Azure DevOps Pipelines", "category": "CI/CD", "complexity": "High", "min_team_size": 5, "description": "Enterprise-grade pipelines with extensive integration"},
77
+ {"name": "SonarQube", "category": "Code Quality", "complexity": "High", "min_team_size": 5, "description": "Advanced code quality and security platform"}
78
  ]
79
  },
80
  "deployment": {
81
  "low": [
82
+ {"name": "Netlify", "category": "Hosting", "complexity": "Low", "min_team_size": 1, "description": "Simple deployment platform for frontend applications"},
83
+ {"name": "Heroku", "category": "PaaS", "complexity": "Low", "min_team_size": 1, "description": "Platform-as-a-Service with simplified deployment"}
84
  ],
85
  "medium": [
86
+ {"name": "Docker", "category": "Containerization", "complexity": "Medium", "min_team_size": 2, "description": "Container platform for application packaging"},
87
+ {"name": "AWS Elastic Beanstalk", "category": "PaaS", "complexity": "Medium", "min_team_size": 3, "description": "Easy-to-use service for deploying applications"}
88
  ],
89
  "high": [
90
+ {"name": "Kubernetes", "category": "Container Orchestration", "complexity": "High", "min_team_size": 5, "description": "Production-grade container orchestration"},
91
+ {"name": "Terraform", "category": "IaC", "complexity": "High", "min_team_size": 3, "description": "Infrastructure as Code for multi-cloud deployment"}
92
  ]
93
  },
94
  "monitoring": {
95
  "low": [
96
+ {"name": "Uptime Robot", "category": "Monitoring", "complexity": "Low", "min_team_size": 1, "description": "Simple uptime monitoring for websites"},
97
+ {"name": "Sentry", "category": "Error Tracking", "complexity": "Low", "min_team_size": 1, "description": "Application error monitoring"}
98
  ],
99
  "medium": [
100
+ {"name": "Grafana", "category": "Observability", "complexity": "Medium", "min_team_size": 2, "description": "Metrics visualization and dashboards"},
101
+ {"name": "New Relic", "category": "APM", "complexity": "Medium", "min_team_size": 3, "description": "Application performance monitoring"}
102
  ],
103
  "high": [
104
+ {"name": "Prometheus", "category": "Monitoring", "complexity": "High", "min_team_size": 3, "description": "Advanced metrics collection and alerting system"},
105
+ {"name": "Datadog", "category": "Observability", "complexity": "High", "min_team_size": 5, "description": "Full-stack observability platform"}
106
  ]
107
  }
108
  }
 
110
  # Team size categorization
111
  team_category = "small" if team_size < 10 else "medium" if team_size < 50 else "large"
112
 
113
+ # Find suitable tools based on team size and complexity
114
+ suitable_tools = []
115
  tools_for_phase = udp_tools[development_phase][project_complexity]
116
 
117
+ # Filter tools by team size
118
+ for tool in tools_for_phase:
119
+ if tool["min_team_size"] <= team_size:
120
+ suitable_tools.append(tool)
121
+
122
  # Format response
123
  response = f"## UDP Tool Recommendations\n\n"
124
  response += f"**Development Phase:** {development_phase.capitalize()}\n"
125
  response += f"**Team Size:** {team_size} ({team_category} team)\n"
126
  response += f"**Project Complexity:** {project_complexity.capitalize()}\n\n"
127
 
128
+ if suitable_tools:
129
+ response += "### Recommended Tools\n\n"
130
+
131
+ for tool in suitable_tools:
132
+ response += f"**{tool['name']}**\n"
133
+ response += f"- Category: {tool['category']}\n"
134
+ response += f"- Complexity: {tool['complexity']}\n"
135
+ response += f"- Min Team Size: {tool['min_team_size']}\n"
136
+ response += f"- Description: {tool['description']}\n\n"
137
+ else:
138
+ response += "Unfortunately, we cannot provide specific tool recommendations for your team size and complexity requirements. Consider reviewing tools for a different complexity level or adjusting your team size.\n\n"
139
 
140
  # Additional phase-specific advice
141
  if development_phase == "planning":
 
164
  response += "- Establish incident response processes\n"
165
  response += "- Regularly review logs and performance data\n"
166
 
167
+ response += "\n### Important Information\n"
168
+ response += "- These are general recommendations based on the information provided.\n"
169
+ response += "- Before adopting tools, assess your team's specific needs and skills.\n"
170
+ response += "- Consider integration capabilities with your existing toolchain.\n"
171
+ response += "- Training requirements should be factored into tool adoption decisions.\n"
172
 
173
  return response
174
 
175
+ # Setup agent
 
176
  final_answer = FinalAnswerTool()
177
 
 
178
  model = HfApiModel(
179
+ max_tokens=2096,
180
+ temperature=0.5,
181
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct'
182
  )
183
 
184
+ # Configure templates for the UDP advisor
185
  udp_prompt_templates = {
186
  "react-system": """You are a UDP (Unified Development Platform) advisor who helps users choose appropriate tools for their software development projects.
187
  You have access to the following tools:
 
189
  {tools_string}
190
 
191
  You should help the user determine which UDP tools are best for their project based on:
192
+ 1. The current development phase they are in (planning, development, testing, deployment, monitoring)
193
  2. The size of their development team
194
+ 3. The complexity of their project (low, medium, high)
195
 
196
  Use the udp_advisor tool to analyze these factors and provide tool recommendations.
197
 
 
204
  """,
205
  "react-human": "{input_string}",
206
  "react-assistant": "{agent_response}",
207
+ "final_answer": "Final Answer: {answer}"
208
  }
209
 
210
  # Load prompt templates from file or use our templates
 
225
  )
226
 
227
  # Create a custom Gradio UI
228
+ class UDPAdvisorUI(GradioUI):
229
+ def launch(self, **kwargs):
230
+ import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
233
+ gr.Markdown("# UDP Advisor for Software Development")
234
+ gr.Markdown("Get personalized UDP tool recommendations based on your project profile")
235
+
236
+ with gr.Row():
237
+ with gr.Column():
238
+ phase_input = gr.Radio(["Planning", "Development", "Testing", "Deployment", "Monitoring"], label="Development Phase")
239
+ team_input = gr.Number(label="Team Size", minimum=1)
240
+ complexity_input = gr.Radio(["Low", "Medium", "High"], label="Project Complexity")
241
+ submit_btn = gr.Button("Get Recommendations", variant="primary")
 
242
 
243
+ with gr.Row():
244
+ with gr.Column():
245
+ recommendation_output = gr.Markdown(label="UDP Recommendations")
246
+
247
+ def get_recommendations(phase, team_size, complexity):
248
+ if not phase:
249
+ return "Please select a development phase."
250
+ if not team_size or team_size < 1:
251
+ return "Please provide a valid team size (at least 1)."
252
+ if not complexity:
253
+ return "Please select a project complexity level."
254
+
255
+ try:
256
+ recommendations = udp_advisor(phase.lower(), int(team_size), complexity.lower())
257
+ return recommendations
258
+ except Exception as e:
259
+ return f"Error generating recommendations: {str(e)}"
260
+
261
+ submit_btn.click(get_recommendations, inputs=[phase_input, team_input, complexity_input], outputs=recommendation_output)
262
 
263
+ demo.launch(**kwargs)
 
 
 
 
 
 
264
 
265
+ # Launch the interface
266
+ UDPAdvisorUI(agent).launch()