Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from pydantic import BaseModel, Field | |
| from typing import List, Literal, Dict, Optional | |
| from agency_swarm import Agent, Agency, set_openai_key, basetool | |
| class AnalyzeProjectRequirement(BaseTool): | |
| project_name: str= Field(..., description = " Name of Project") | |
| project_description: str= Field(..., description= "Project and Goals") | |
| project_type: Literal ["Web Application", "Mobile App", "API Developement", "Data Analytics", "AI/ML Solution", "Other"] = Field(..., description= "Type of project") | |
| budget_range: Literal["$10k-$25k", "$25k-$50k", "$100k+"] = Field(..., description= "Budget Range of the project") | |
| class ToolConfig: | |
| name= "analyze_project" | |
| description= "Analyze project requirement and feasibility" | |
| one_call_at_a_time= True | |
| def run(self) -> str: | |
| """Analyze project and store results in shared state""" | |
| if self._shared_state.get("project_analysis", None) is not None: | |
| raise ValueError("project Analysis already exists, you can move forward to technical specification.") | |
| analysis= { | |
| "name": self.project_name, | |
| "type": self.project_type, | |
| "complexity": "high", | |
| "timeline": "6 months", | |
| "budget_feasibility": "within range", | |
| "requirements": ["Scalable Architecture", "Security", "API Integration"] | |
| } | |
| self._shared_state.set("project_analysis", analysis) | |
| return "Project Analysis completed. Please proceed to technical specifications" | |
| class CreateTechnicalSPecification(BaseTool): | |
| core_technologies: str = Field(..., description= "Comma-separated list of main technologies") | |
| architecture_type: Literal["monolithic", "microservice", "serverless", "hybrid"] = Field(..., description= "Proposed Architecture") | |
| scalability_requirement: Literal("high","medium", "low") = Field(..., description= "Scalability Needs") | |
| class ToolConfig: | |
| name= "create_techinal_spec" | |
| description= "Creates technical specifications based on project analysis" | |
| one_call_at_a_time= True | |
| def run(self) -> str: | |
| """Create technical specification based on the analysis""" | |
| project_analysis= self._shared_state.get("project_analysis", None) | |
| if self._shared_state.get("project_analysis"): | |
| raise ValueError("Please analyze project requirements first using the AnalyzeProjectRequirement tool") | |
| spec= { | |
| "project_name": project_analysis["name"], | |
| "architecture": self.architecture_type, | |
| "technologies": self.core_technologies.split(","), | |
| "scalability": self.scalability_requirement | |
| } | |
| self._shared_state.set("techincal_specification", spec) | |
| return f"Technical Specifications created for {project_analysis['name']}" | |
| def init_session_state()-> None: | |
| """Initiate session state variable""" | |
| if "messages" not in st.session_state: | |
| st.session_state.message=[] | |
| if "api_key" not in st.session_state: | |
| st.session_state.api_key= None | |
| def main() -> None: | |
| st.set_page_config(page_title= "Greg.ai Place for innovation", layout= "wide") | |
| init_session_state() | |
| st.title("Greg.ai Services- Innovate Build, and Lighten up the future with AI") | |
| if __name__ == "__main__": | |
| main() | |