Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,163 +5,170 @@ from tools.final_answer import FinalAnswerTool
|
|
| 5 |
from Gradio_UI import GradioUI
|
| 6 |
|
| 7 |
@tool
|
| 8 |
-
def
|
| 9 |
-
"""Provides
|
| 10 |
|
| 11 |
Args:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
Returns:
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
if
|
| 20 |
-
return "Error:
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
valid_profiles = ["low", "medium", "high"]
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
"low": [
|
| 35 |
-
{"name": "KSM Tel Bond 20", "ticker": "TELBOND20", "type": "Bonds", "risk": "Low", "min_investment": 1000, "description": "ETF tracking Tel Aviv corporate bond index"},
|
| 36 |
-
{"name": "Psagot Government Shekel Bonds", "ticker": "PSAGOT-GOV", "type": "Gov Bonds", "risk": "Low", "min_investment": 500, "description": "Israeli government bonds fund"},
|
| 37 |
-
{"name": "Migdal Foreign Currency", "ticker": "MIGDAL-FOREX", "type": "Currency", "risk": "Low-medium", "min_investment": 1000, "description": "Fund investing in foreign currency and money market instruments"},
|
| 38 |
-
{"name": "Harel Deposits Basket", "ticker": "HAREL-PIKADON", "type": "Deposits", "risk": "Very low", "min_investment": 500, "description": "Fixed income bank deposits fund"}
|
| 39 |
-
],
|
| 40 |
-
"medium": [
|
| 41 |
-
{"name": "Tachlit Tel Aviv 35", "ticker": "TA35ETF", "type": "Index", "risk": "Medium", "min_investment": 1000, "description": "ETF tracking the 35 largest companies on the Tel Aviv Stock Exchange"},
|
| 42 |
-
{"name": "Meitav Dash 50/50", "ticker": "MEITAV-50", "type": "Mixed", "risk": "Medium", "min_investment": 2000, "description": "Balanced fund with 50% stocks and 50% bonds"},
|
| 43 |
-
{"name": "Altshuler Shaham Global", "ticker": "ALTSHULER-GLOBAL", "type": "Global", "risk": "Medium", "min_investment": 5000, "description": "Fund with diversified global investments"},
|
| 44 |
-
{"name": "Analyst Corporate AA and Above", "ticker": "ANALYST-AA", "type": "Corp Bonds", "risk": "Medium", "min_investment": 2000, "description": "High-quality corporate bonds fund with AA rating and above"}
|
| 45 |
-
],
|
| 46 |
-
"high": [
|
| 47 |
-
{"name": "Tachlit NASDAQ 100", "ticker": "TACHLIT-NDX", "type": "Technology", "risk": "High", "min_investment": 3000, "description": "ETF tracking the NASDAQ 100 index of largest non-financial companies"},
|
| 48 |
-
{"name": "KSM S&P 500", "ticker": "KSM-SP500", "type": "US", "risk": "High", "min_investment": 3000, "description": "ETF tracking the S&P 500 index"},
|
| 49 |
-
{"name": "Mor Technologies", "ticker": "MOR-TECH", "type": "Sector", "risk": "Very high", "min_investment": 5000, "description": "Fund of Israeli technology companies"},
|
| 50 |
-
{"name": "Harel Foreign Stocks", "ticker": "HAREL-GLOBAL", "type": "International", "risk": "High", "min_investment": 5000, "description": "Fund of international stocks with high growth potential"}
|
| 51 |
-
]
|
| 52 |
-
}
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
"
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
}
|
|
|
|
| 74 |
|
| 75 |
-
#
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
# Find suitable funds based on available amount and allocation
|
| 79 |
-
suitable_funds = []
|
| 80 |
-
funds_for_profile = israeli_funds[risk_profile]
|
| 81 |
-
|
| 82 |
-
# Distribute amount by asset class
|
| 83 |
-
stock_amount = amount * allocation["stocks"] / 100
|
| 84 |
-
bond_amount = amount * allocation["bonds"] / 100
|
| 85 |
-
cash_amount = amount * allocation["cash"] / 100
|
| 86 |
-
|
| 87 |
-
# Fund recommendations
|
| 88 |
-
stock_funds = [f for f in funds_for_profile if f["type"] in ["Index", "Technology", "US", "International", "Sector"]]
|
| 89 |
-
bond_funds = [f for f in funds_for_profile if f["type"] in ["Bonds", "Gov Bonds", "Corp Bonds"]]
|
| 90 |
-
cash_funds = [f for f in funds_for_profile if f["type"] in ["Deposits", "Currency"]]
|
| 91 |
-
|
| 92 |
-
# Build recommendations
|
| 93 |
-
recommendations = []
|
| 94 |
-
|
| 95 |
-
if stock_amount >= 1000 and stock_funds:
|
| 96 |
-
for fund in stock_funds:
|
| 97 |
-
if fund["min_investment"] <= stock_amount:
|
| 98 |
-
amount_to_invest = min(stock_amount * 0.8, stock_amount)
|
| 99 |
-
recommendations.append({
|
| 100 |
-
"fund": fund,
|
| 101 |
-
"amount": math.floor(amount_to_invest / 100) * 100,
|
| 102 |
-
"asset_class": "Stocks"
|
| 103 |
-
})
|
| 104 |
-
break
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
amount_to_invest = min(bond_amount * 0.8, bond_amount)
|
| 110 |
-
recommendations.append({
|
| 111 |
-
"fund": fund,
|
| 112 |
-
"amount": math.floor(amount_to_invest / 100) * 100,
|
| 113 |
-
"asset_class": "Bonds"
|
| 114 |
-
})
|
| 115 |
-
break
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
recommendations.append({
|
| 122 |
-
"fund": fund,
|
| 123 |
-
"amount": math.floor(amount_to_invest / 100) * 100,
|
| 124 |
-
"asset_class": "Cash"
|
| 125 |
-
})
|
| 126 |
-
break
|
| 127 |
|
| 128 |
# Format response
|
| 129 |
-
response = f"##
|
| 130 |
-
response += f"**
|
| 131 |
-
response += f"**
|
| 132 |
-
response += f"**
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
response += f"- Bonds: {allocation['bonds']}% ({int(bond_amount):,} ₪)\n"
|
| 137 |
-
response += f"- Cash: {allocation['cash']}% ({int(cash_amount):,} ₪)\n\n"
|
| 138 |
-
|
| 139 |
-
if recommendations:
|
| 140 |
-
response += "### Recommended Investments\n\n"
|
| 141 |
-
total_invested = 0
|
| 142 |
|
| 143 |
-
for
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
response += f"
|
| 149 |
-
response += f"- Type: {fund['type']} ({rec['asset_class']})\n"
|
| 150 |
-
response += f"- Risk: {fund['risk']}\n"
|
| 151 |
-
response += f"- Recommended amount: {amount_to_invest:,} ₪\n"
|
| 152 |
-
response += f"- Description: {fund['description']}\n\n"
|
| 153 |
-
|
| 154 |
-
remaining = amount - total_invested
|
| 155 |
-
if remaining > 0:
|
| 156 |
-
response += f"**Remaining funds:** {remaining:,} ₪ recommended to keep in a savings account for unexpected expenses.\n\n"
|
| 157 |
else:
|
| 158 |
-
response += "Unfortunately, we cannot provide specific
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
response += "### Important Information\n"
|
| 161 |
response += "- These are general recommendations based on the information provided.\n"
|
| 162 |
-
response += "- Before
|
| 163 |
-
response += "-
|
| 164 |
-
response += "-
|
| 165 |
|
| 166 |
return response
|
| 167 |
|
|
@@ -174,19 +181,19 @@ model = HfApiModel(
|
|
| 174 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct'
|
| 175 |
)
|
| 176 |
|
| 177 |
-
# Configure templates for the
|
| 178 |
-
|
| 179 |
-
"react-system": """You are
|
| 180 |
You have access to the following tools:
|
| 181 |
|
| 182 |
{tools_string}
|
| 183 |
|
| 184 |
-
You should help the user determine
|
| 185 |
-
1. The
|
| 186 |
-
2. The
|
| 187 |
-
3. The
|
| 188 |
|
| 189 |
-
Use the
|
| 190 |
|
| 191 |
To use a tool, output an action in this format:
|
| 192 |
```py
|
|
@@ -197,63 +204,92 @@ Always use Python syntax for calling tools. After using a tool, analyze the resu
|
|
| 197 |
""",
|
| 198 |
"react-human": "{input_string}",
|
| 199 |
"react-assistant": "{agent_response}",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
# Load prompt templates from file or use our templates
|
| 203 |
try:
|
| 204 |
with open("prompts.yaml", 'r') as stream:
|
| 205 |
prompt_templates = yaml.safe_load(stream)
|
| 206 |
-
prompt_templates.update(investment_prompt_templates)
|
| 207 |
except:
|
| 208 |
-
prompt_templates =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
# Create the agent
|
| 211 |
agent = CodeAgent(
|
| 212 |
model=model,
|
| 213 |
-
tools=[final_answer,
|
| 214 |
max_steps=3,
|
| 215 |
verbosity_level=1,
|
| 216 |
prompt_templates=prompt_templates
|
| 217 |
)
|
| 218 |
|
| 219 |
# Create a custom Gradio UI
|
| 220 |
-
class
|
| 221 |
def launch(self, **kwargs):
|
| 222 |
import gradio as gr
|
| 223 |
|
| 224 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 225 |
-
gr.Markdown("#
|
| 226 |
-
gr.Markdown("Get personalized
|
| 227 |
|
| 228 |
with gr.Row():
|
| 229 |
with gr.Column():
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
submit_btn = gr.Button("Get Recommendations", variant="primary")
|
| 234 |
|
| 235 |
with gr.Row():
|
| 236 |
with gr.Column():
|
| 237 |
-
recommendation_output = gr.Markdown(label="
|
| 238 |
|
| 239 |
-
def get_recommendations(
|
| 240 |
-
if not
|
| 241 |
-
return "Please
|
| 242 |
-
if not
|
| 243 |
-
return "Please
|
| 244 |
-
if not
|
| 245 |
-
return "Please
|
| 246 |
|
| 247 |
try:
|
| 248 |
-
recommendations =
|
| 249 |
return recommendations
|
| 250 |
except Exception as e:
|
| 251 |
return f"Error generating recommendations: {str(e)}"
|
| 252 |
|
| 253 |
-
submit_btn.click(get_recommendations, inputs=[
|
| 254 |
|
| 255 |
demo.launch(**kwargs)
|
| 256 |
|
| 257 |
# Launch the interface
|
| 258 |
-
|
| 259 |
-
|
|
|
|
| 5 |
from Gradio_UI import GradioUI
|
| 6 |
|
| 7 |
@tool
|
| 8 |
+
def udp_advisor(development_phase: str, team_size: int, project_complexity: str) -> str:
|
| 9 |
+
"""Provides UDP (Unified Development Platform) recommendations based on development phase, team size, and project complexity.
|
| 10 |
|
| 11 |
Args:
|
| 12 |
+
development_phase: Current phase of development (planning, development, testing, deployment, monitoring)
|
| 13 |
+
team_size: Number of team members
|
| 14 |
+
project_complexity: Project complexity level (low, medium, high)
|
| 15 |
|
| 16 |
Returns:
|
| 17 |
+
UDP recommendations as formatted text
|
| 18 |
"""
|
| 19 |
+
if team_size <= 0 or team_size > 1000:
|
| 20 |
+
return "Error: Please provide a valid team size (1-1000)."
|
| 21 |
|
| 22 |
+
# Normalize development phase
|
| 23 |
+
development_phase = development_phase.lower().strip()
|
| 24 |
+
valid_phases = ["planning", "development", "testing", "deployment", "monitoring"]
|
| 25 |
|
| 26 |
+
if development_phase not in valid_phases:
|
| 27 |
+
return "Error: Development phase must be one of: planning, development, testing, deployment, monitoring."
|
|
|
|
| 28 |
|
| 29 |
+
# Normalize complexity
|
| 30 |
+
project_complexity = project_complexity.lower().strip()
|
| 31 |
+
valid_complexity = ["low", "medium", "high"]
|
| 32 |
|
| 33 |
+
if project_complexity not in valid_complexity:
|
| 34 |
+
return "Error: Project complexity must be 'low', 'medium', or 'high'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# Database of UDP tools by development phase and complexity
|
| 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 |
+
}
|
| 109 |
|
| 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":
|
| 142 |
+
response += "### Planning Phase Tips\n"
|
| 143 |
+
response += "- Document your requirements clearly\n"
|
| 144 |
+
response += "- Set up communication channels\n"
|
| 145 |
+
response += "- Define team roles and responsibilities\n"
|
| 146 |
+
elif development_phase == "development":
|
| 147 |
+
response += "### Development Phase Tips\n"
|
| 148 |
+
response += "- Implement branch protection rules\n"
|
| 149 |
+
response += "- Use consistent code formatting\n"
|
| 150 |
+
response += "- Schedule regular code reviews\n"
|
| 151 |
+
elif development_phase == "testing":
|
| 152 |
+
response += "### Testing Phase Tips\n"
|
| 153 |
+
response += "- Automate unit and integration tests\n"
|
| 154 |
+
response += "- Establish QA processes\n"
|
| 155 |
+
response += "- Document test cases and expected outcomes\n"
|
| 156 |
+
elif development_phase == "deployment":
|
| 157 |
+
response += "### Deployment Phase Tips\n"
|
| 158 |
+
response += "- Use environment-specific configurations\n"
|
| 159 |
+
response += "- Implement rollback strategies\n"
|
| 160 |
+
response += "- Document deployment procedures\n"
|
| 161 |
+
elif development_phase == "monitoring":
|
| 162 |
+
response += "### Monitoring Phase Tips\n"
|
| 163 |
+
response += "- Set up alerts for critical metrics\n"
|
| 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 |
|
|
|
|
| 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:
|
| 188 |
|
| 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 |
|
| 198 |
To use a tool, output an action in this format:
|
| 199 |
```py
|
|
|
|
| 204 |
""",
|
| 205 |
"react-human": "{input_string}",
|
| 206 |
"react-assistant": "{agent_response}",
|
| 207 |
+
"final_answer": {
|
| 208 |
+
"pre_messages": "I'll provide you with UDP tool recommendations based on your project details.",
|
| 209 |
+
"template": "Final Answer: {answer}"
|
| 210 |
+
}
|
| 211 |
}
|
| 212 |
|
| 213 |
# Load prompt templates from file or use our templates
|
| 214 |
try:
|
| 215 |
with open("prompts.yaml", 'r') as stream:
|
| 216 |
prompt_templates = yaml.safe_load(stream)
|
|
|
|
| 217 |
except:
|
| 218 |
+
prompt_templates = {}
|
| 219 |
+
|
| 220 |
+
# Add our templates
|
| 221 |
+
prompt_templates["react-system"] = """You are a UDP (Unified Development Platform) advisor who helps users choose appropriate tools for their software development projects.
|
| 222 |
+
You have access to the following tools:
|
| 223 |
+
|
| 224 |
+
{tools_string}
|
| 225 |
+
|
| 226 |
+
You should help the user determine which UDP tools are best for their project based on:
|
| 227 |
+
1. The current development phase they are in (planning, development, testing, deployment, monitoring)
|
| 228 |
+
2. The size of their development team
|
| 229 |
+
3. The complexity of their project (low, medium, high)
|
| 230 |
+
|
| 231 |
+
Use the udp_advisor tool to analyze these factors and provide tool recommendations.
|
| 232 |
+
|
| 233 |
+
To use a tool, output an action in this format:
|
| 234 |
+
```py
|
| 235 |
+
action = tool_name(arg1=value1, arg2=value2, ...)
|
| 236 |
+
```
|
| 237 |
+
|
| 238 |
+
Always use Python syntax for calling tools. After using a tool, analyze the result to determine what to do next. Use final_answer to return your final answer.
|
| 239 |
+
"""
|
| 240 |
+
prompt_templates["react-human"] = "{input_string}"
|
| 241 |
+
prompt_templates["react-assistant"] = "{agent_response}"
|
| 242 |
+
prompt_templates["final_answer"] = {
|
| 243 |
+
"pre_messages": "I'll provide you with UDP tool recommendations based on your project details.",
|
| 244 |
+
"template": "Final Answer: {answer}"
|
| 245 |
+
}
|
| 246 |
|
| 247 |
# Create the agent
|
| 248 |
agent = CodeAgent(
|
| 249 |
model=model,
|
| 250 |
+
tools=[final_answer, udp_advisor],
|
| 251 |
max_steps=3,
|
| 252 |
verbosity_level=1,
|
| 253 |
prompt_templates=prompt_templates
|
| 254 |
)
|
| 255 |
|
| 256 |
# Create a custom Gradio UI
|
| 257 |
+
class UDPAdvisorUI(GradioUI):
|
| 258 |
def launch(self, **kwargs):
|
| 259 |
import gradio as gr
|
| 260 |
|
| 261 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 262 |
+
gr.Markdown("# UDP Advisor for Software Development")
|
| 263 |
+
gr.Markdown("Get personalized UDP tool recommendations based on your project profile")
|
| 264 |
|
| 265 |
with gr.Row():
|
| 266 |
with gr.Column():
|
| 267 |
+
phase_input = gr.Radio(["Planning", "Development", "Testing", "Deployment", "Monitoring"], label="Development Phase")
|
| 268 |
+
team_input = gr.Number(label="Team Size", minimum=1)
|
| 269 |
+
complexity_input = gr.Radio(["Low", "Medium", "High"], label="Project Complexity")
|
| 270 |
submit_btn = gr.Button("Get Recommendations", variant="primary")
|
| 271 |
|
| 272 |
with gr.Row():
|
| 273 |
with gr.Column():
|
| 274 |
+
recommendation_output = gr.Markdown(label="UDP Recommendations")
|
| 275 |
|
| 276 |
+
def get_recommendations(phase, team_size, complexity):
|
| 277 |
+
if not phase:
|
| 278 |
+
return "Please select a development phase."
|
| 279 |
+
if not team_size or team_size < 1:
|
| 280 |
+
return "Please provide a valid team size (at least 1)."
|
| 281 |
+
if not complexity:
|
| 282 |
+
return "Please select a project complexity level."
|
| 283 |
|
| 284 |
try:
|
| 285 |
+
recommendations = udp_advisor(phase.lower(), int(team_size), complexity.lower())
|
| 286 |
return recommendations
|
| 287 |
except Exception as e:
|
| 288 |
return f"Error generating recommendations: {str(e)}"
|
| 289 |
|
| 290 |
+
submit_btn.click(get_recommendations, inputs=[phase_input, team_input, complexity_input], outputs=recommendation_output)
|
| 291 |
|
| 292 |
demo.launch(**kwargs)
|
| 293 |
|
| 294 |
# Launch the interface
|
| 295 |
+
UDPAdvisorUI(agent).launch()
|
|
|