destinyebuka commited on
Commit
0e7f494
·
1 Parent(s): e2099f4
Files changed (1) hide show
  1. main.py +15 -7
main.py CHANGED
@@ -37,9 +37,11 @@ logger = logging.getLogger(__name__)
37
  try:
38
  from app.ai.routes.chat import router as ai_chat_router
39
  AI_AVAILABLE = True
40
- except ImportError:
41
- logger.warning("⚠️ AI chat router not available - chat endpoint will be disabled")
 
42
  AI_AVAILABLE = False
 
43
 
44
  # ---------- Existing imports ----------
45
  try:
@@ -132,13 +134,14 @@ cors_origins = [
132
  "http://127.0.0.1:5000",
133
  "http://127.0.0.1:8080",
134
  "http://127.0.0.1:56205",
 
135
  ]
136
 
137
  app.add_middleware(
138
  CORSMiddleware,
139
  allow_origins=cors_origins,
140
  allow_credentials=True,
141
- allow_methods=["*"],
142
  allow_headers=["*"],
143
  expose_headers=["*"],
144
  max_age=600,
@@ -194,11 +197,11 @@ async def general_exception_handler(request: Request, exc: Exception):
194
  app.include_router(auth.router, prefix="/api/auth", tags=["Authentication"])
195
 
196
  # Aida AI Chat routes (NEW)
197
- if AI_AVAILABLE:
198
- app.include_router(ai_chat_router, prefix="/api/ai", tags=["Aida AI Chat"])
199
- logger.info("✅ Aida AI chat router loaded at /api/ai")
200
  else:
201
- logger.warning("⚠️ Aida AI chat router NOT loaded")
202
 
203
  # ====================================================================
204
  # Health & Status Endpoints
@@ -211,6 +214,7 @@ async def health_check():
211
  "service": "Lojiz Platform + Aida AI",
212
  "version": "1.0.0",
213
  "environment": environment,
 
214
  }
215
 
216
  @app.get("/", tags=["Root"])
@@ -221,6 +225,10 @@ async def root():
221
  "docs": "/docs",
222
  "health": "/health",
223
  "environment": environment,
 
 
 
 
224
  }
225
 
226
  @app.options("/{full_path:path}", include_in_schema=False)
 
37
  try:
38
  from app.ai.routes.chat import router as ai_chat_router
39
  AI_AVAILABLE = True
40
+ logger.info("✅ AI chat router imported successfully")
41
+ except ImportError as e:
42
+ logger.warning(f"⚠️ AI chat router not available: {e}")
43
  AI_AVAILABLE = False
44
+ ai_chat_router = None
45
 
46
  # ---------- Existing imports ----------
47
  try:
 
134
  "http://127.0.0.1:5000",
135
  "http://127.0.0.1:8080",
136
  "http://127.0.0.1:56205",
137
+ "https://destinyebuka-aida.hf.space", # Add for HF Spaces deployment
138
  ]
139
 
140
  app.add_middleware(
141
  CORSMiddleware,
142
  allow_origins=cors_origins,
143
  allow_credentials=True,
144
+ allow_methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
145
  allow_headers=["*"],
146
  expose_headers=["*"],
147
  max_age=600,
 
197
  app.include_router(auth.router, prefix="/api/auth", tags=["Authentication"])
198
 
199
  # Aida AI Chat routes (NEW)
200
+ if AI_AVAILABLE and ai_chat_router:
201
+ app.include_router(ai_chat_router, prefix="/ai", tags=["Aida AI Chat"])
202
+ logger.info("✅ Aida AI chat router loaded at /ai")
203
  else:
204
+ logger.warning("⚠️ Aida AI chat router NOT loaded - endpoint will not be available")
205
 
206
  # ====================================================================
207
  # Health & Status Endpoints
 
214
  "service": "Lojiz Platform + Aida AI",
215
  "version": "1.0.0",
216
  "environment": environment,
217
+ "ai_available": AI_AVAILABLE,
218
  }
219
 
220
  @app.get("/", tags=["Root"])
 
225
  "docs": "/docs",
226
  "health": "/health",
227
  "environment": environment,
228
+ "endpoints": {
229
+ "auth": "/api/auth",
230
+ "ai_chat": "/ai/ask" if AI_AVAILABLE else "NOT AVAILABLE",
231
+ }
232
  }
233
 
234
  @app.options("/{full_path:path}", include_in_schema=False)