File size: 3,379 Bytes
e28d40b
 
 
e8f4376
e28d40b
 
 
454d18f
 
cfdbe14
 
e28d40b
 
 
 
 
 
 
 
e4eccb4
 
e28d40b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454d18f
cfdbe14
 
e28d40b
 
 
 
 
 
 
 
 
 
7392c95
 
 
e28d40b
 
 
 
 
 
 
 
7392c95
d9f1a67
e28d40b
 
 
 
 
e8f4376
7392c95
 
 
 
 
 
 
 
 
 
e8f4376
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
79
80
81
82
83
84
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()