Update app.py
Browse files
app.py
CHANGED
|
@@ -5,11 +5,14 @@ import requests
|
|
| 5 |
|
| 6 |
# Default model used internally; the client only sends plain text
|
| 7 |
DEFAULT_MODEL = "kwaipilot/kat-coder-pro:free"
|
|
|
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
| 11 |
@app.get("/")
|
| 12 |
def health():
|
|
|
|
|
|
|
| 13 |
return {"status": "ok"}
|
| 14 |
|
| 15 |
@app.post("/chat")
|
|
@@ -26,7 +29,6 @@ async def chat(request: Request):
|
|
| 26 |
if not text:
|
| 27 |
raise HTTPException(status_code=400, detail="Send plain text body or JSON {'text': '...'}")
|
| 28 |
|
| 29 |
-
api_key = os.getenv("OPENROUTER_API_KEY")
|
| 30 |
if not api_key:
|
| 31 |
raise HTTPException(status_code=500, detail="OPENROUTER_API_KEY not set")
|
| 32 |
|
|
|
|
| 5 |
|
| 6 |
# Default model used internally; the client only sends plain text
|
| 7 |
DEFAULT_MODEL = "kwaipilot/kat-coder-pro:free"
|
| 8 |
+
api_key = os.getenv("OPENROUTER_API_KEY")
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
@app.get("/")
|
| 13 |
def health():
|
| 14 |
+
if not api_key:
|
| 15 |
+
return {"status": "no key"}
|
| 16 |
return {"status": "ok"}
|
| 17 |
|
| 18 |
@app.post("/chat")
|
|
|
|
| 29 |
if not text:
|
| 30 |
raise HTTPException(status_code=400, detail="Send plain text body or JSON {'text': '...'}")
|
| 31 |
|
|
|
|
| 32 |
if not api_key:
|
| 33 |
raise HTTPException(status_code=500, detail="OPENROUTER_API_KEY not set")
|
| 34 |
|