/ ai_proxy_enhanced.py
ai_proxy_enhanced.py
 1  from fastapi import FastAPI
 2  import uvicorn
 3  
 4  app = FastAPI()
 5  
 6  @app.get("/")
 7  def root():
 8      return {
 9          "name": "AI Proxy v2.0",
10          "port": 8345,
11          "status": "running",
12          "apis": ["Google", "HuggingFace", "Groq"],
13          "endpoints": {
14              "/": "this info",
15              "/health": "health check",
16              "/query/{text}": "AI query endpoint",
17              "/status": "detailed status"
18          }
19      }
20  
21  @app.get("/health")
22  def health():
23      return {"status": "healthy", "service": "ai_proxy"}
24  
25  @app.get("/status")
26  def status():
27      return {
28          "port": 8345,
29          "process_id": "running",
30          "other_services": {
31              "pineapple": "http://localhost:8380",
32              "decentralized": "http://localhost:8390"
33          }
34      }
35  
36  @app.get("/query/{prompt}")
37  def query(prompt: str):
38      return {
39          "prompt": prompt,
40          "response": f"Processing: {prompt}",
41          "model": "AI Proxy",
42          "timestamp": "now"
43      }
44  
45  if __name__ == "__main__":
46      print("🤖 ENHANCED AI PROXY STARTING...")
47      print("=" * 50)
48      print("✅ Web Interface: http://localhost:8345")
49      print("✅ Health Check:  http://localhost:8345/health")
50      print("✅ Test Query:    http://localhost:8345/query/test")
51      print("")
52      print("🔗 Connected Systems:")
53      print("   • 🍍 Pineapple:     http://localhost:8380")
54      print("   • 🌐 Decentralized: http://localhost:8390")
55      print("=" * 50)
56      
57      uvicorn.run(app, host="0.0.0.0", port=8345, log_level="info")