Adedoyinjames commited on
Commit
0b52af4
·
verified ·
1 Parent(s): 54a881c

Create fastapi_server.py

Browse files
Files changed (1) hide show
  1. fastapi_server.py +107 -0
fastapi_server.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from pydantic import BaseModel
4
+ from typing import List, Dict, Optional
5
+ import uvicorn
6
+
7
+ # FastAPI server for internal API endpoints
8
+ app = FastAPI(title="YAH Tech Internal API", version="1.0.0")
9
+
10
+ # CORS middleware
11
+ app.add_middleware(
12
+ CORSMiddleware,
13
+ allow_origins=["*"],
14
+ allow_credentials=True,
15
+ allow_methods=["*"],
16
+ allow_headers=["*"],
17
+ )
18
+
19
+ # Pydantic models
20
+ class ChatRequest(BaseModel):
21
+ message: str
22
+ user_id: Optional[str] = None
23
+
24
+ class ChatResponse(BaseModel):
25
+ response: str
26
+ confidence: float
27
+ source: str
28
+
29
+ class CompanyInfoResponse(BaseModel):
30
+ name: str
31
+ type: str
32
+ purpose: str
33
+ philosophy: str
34
+
35
+ # Mock database
36
+ conversation_history = {}
37
+
38
+ @app.get("/")
39
+ async def root():
40
+ return {"message": "YAH Tech Internal API", "status": "active"}
41
+
42
+ @app.get("/company/info")
43
+ async def get_company_info():
44
+ """Get YAH Tech company information"""
45
+ return CompanyInfoResponse(
46
+ name="YAH Tech",
47
+ type="Venture studio / app development company",
48
+ purpose="Build and launch technology-driven ventures that generate profit and societal value",
49
+ philosophy="Learn, understand, create, and evaluate"
50
+ )
51
+
52
+ @app.post("/chat", response_model=ChatResponse)
53
+ async def chat_endpoint(request: ChatRequest):
54
+ """Chat endpoint for YAH Bot"""
55
+ user_message = request.message.lower()
56
+
57
+ # Simple response logic - in production, this would use your AI model
58
+ if "yah tech" in user_message:
59
+ return ChatResponse(
60
+ response="YAH Tech is a venture studio and app development company focused on building futuristic solutions that create both profit and societal value.",
61
+ confidence=0.9,
62
+ source="knowledge_base"
63
+ )
64
+ elif "adedoyin" in user_message:
65
+ return ChatResponse(
66
+ response="Adedoyin Ifeoluwa James is the Founder & CEO of YAH Tech, focused on building profitable systems that reshape the economic world.",
67
+ confidence=0.95,
68
+ source="knowledge_base"
69
+ )
70
+ elif "hello" in user_message or "hi" in user_message:
71
+ return ChatResponse(
72
+ response="Hello! I'm YAH Bot, how can I assist you with YAH Tech today?",
73
+ confidence=0.8,
74
+ source="greeting"
75
+ )
76
+ else:
77
+ return ChatResponse(
78
+ response="I understand you're interested in YAH Tech. We're a venture studio building scalable technology solutions. How can I help you specifically?",
79
+ confidence=0.7,
80
+ source="general"
81
+ )
82
+
83
+ @app.get("/projects")
84
+ async def get_projects():
85
+ """Get current YAH Tech projects"""
86
+ return {
87
+ "projects": [
88
+ {
89
+ "name": "AI Venture Builder",
90
+ "status": "planning",
91
+ "description": "Platform for rapidly building AI-powered startups"
92
+ },
93
+ {
94
+ "name": "Economic Analytics Suite",
95
+ "status": "development",
96
+ "description": "Tools for analyzing and predicting economic trends"
97
+ }
98
+ ]
99
+ }
100
+
101
+ @app.get("/health")
102
+ async def health_check():
103
+ """Health check endpoint"""
104
+ return {"status": "healthy", "service": "yah-tech-api"}
105
+
106
+ if __name__ == "__main__":
107
+ uvicorn.run(app, host="0.0.0.0", port=8000)