Spaces:
Paused
Paused
Update backend/main.py
Browse files- backend/main.py +2 -6
backend/main.py
CHANGED
|
@@ -10,7 +10,7 @@ from model_router import route_chat, get_available_models
|
|
| 10 |
from agent import CodingAgent
|
| 11 |
from autocomplete import generate_autocomplete
|
| 12 |
|
| 13 |
-
# Lazy import for codebase index
|
| 14 |
CodebaseIndex = None
|
| 15 |
|
| 16 |
def get_codebase_index():
|
|
@@ -20,10 +20,9 @@ def get_codebase_index():
|
|
| 20 |
from codebase_index import CodebaseIndex as CBI
|
| 21 |
CodebaseIndex = CBI
|
| 22 |
except ImportError:
|
| 23 |
-
raise HTTPException(status_code=503, detail="Codebase indexing unavailable
|
| 24 |
return CodebaseIndex
|
| 25 |
|
| 26 |
-
# Auto-index sandbox on startup
|
| 27 |
async def startup_index():
|
| 28 |
try:
|
| 29 |
from codebase_index import CodebaseIndex
|
|
@@ -44,7 +43,6 @@ indexers = {}
|
|
| 44 |
agents = {}
|
| 45 |
STATIC_DIR = "static"
|
| 46 |
|
| 47 |
-
# ---------- API Models ----------
|
| 48 |
class ChatRequest(BaseModel):
|
| 49 |
model: str = "groq-llama-3.3-70b-versatile"
|
| 50 |
messages: List[Dict[str, str]]
|
|
@@ -82,7 +80,6 @@ class ApplyRequest(BaseModel):
|
|
| 82 |
task_id: str
|
| 83 |
approved_indices: List[int]
|
| 84 |
|
| 85 |
-
# ---------- API Routes ----------
|
| 86 |
@app.get("/api/models")
|
| 87 |
async def get_models():
|
| 88 |
return get_available_models()
|
|
@@ -259,7 +256,6 @@ async def list_files(project_path: str = "/app/sandbox"):
|
|
| 259 |
except Exception as e:
|
| 260 |
raise HTTPException(400, str(e))
|
| 261 |
|
| 262 |
-
# ---------- Serve Frontend (catch-all, must be last) ----------
|
| 263 |
@app.get("/{full_path:path}")
|
| 264 |
async def serve_frontend(full_path: str):
|
| 265 |
if full_path.startswith("api"):
|
|
|
|
| 10 |
from agent import CodingAgent
|
| 11 |
from autocomplete import generate_autocomplete
|
| 12 |
|
| 13 |
+
# Lazy import for codebase index
|
| 14 |
CodebaseIndex = None
|
| 15 |
|
| 16 |
def get_codebase_index():
|
|
|
|
| 20 |
from codebase_index import CodebaseIndex as CBI
|
| 21 |
CodebaseIndex = CBI
|
| 22 |
except ImportError:
|
| 23 |
+
raise HTTPException(status_code=503, detail="Codebase indexing unavailable")
|
| 24 |
return CodebaseIndex
|
| 25 |
|
|
|
|
| 26 |
async def startup_index():
|
| 27 |
try:
|
| 28 |
from codebase_index import CodebaseIndex
|
|
|
|
| 43 |
agents = {}
|
| 44 |
STATIC_DIR = "static"
|
| 45 |
|
|
|
|
| 46 |
class ChatRequest(BaseModel):
|
| 47 |
model: str = "groq-llama-3.3-70b-versatile"
|
| 48 |
messages: List[Dict[str, str]]
|
|
|
|
| 80 |
task_id: str
|
| 81 |
approved_indices: List[int]
|
| 82 |
|
|
|
|
| 83 |
@app.get("/api/models")
|
| 84 |
async def get_models():
|
| 85 |
return get_available_models()
|
|
|
|
| 256 |
except Exception as e:
|
| 257 |
raise HTTPException(400, str(e))
|
| 258 |
|
|
|
|
| 259 |
@app.get("/{full_path:path}")
|
| 260 |
async def serve_frontend(full_path: str):
|
| 261 |
if full_path.startswith("api"):
|