Kashish commited on
Commit ·
5d3d3bd
1
Parent(s): bfc6f8c
Redirect root to FastAPI docs (/docs)
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from fastapi import FastAPI, HTTPException
|
|
|
|
| 4 |
from pydantic import BaseModel, Field
|
| 5 |
|
| 6 |
from rag.chain import aanswer
|
|
@@ -30,6 +31,12 @@ async def health() -> dict[str, str]:
|
|
| 30 |
return {"status": "ok"}
|
| 31 |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
@app.post("/chat", response_model=ChatResponse)
|
| 34 |
async def chat(payload: ChatRequest) -> ChatResponse:
|
| 35 |
try:
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
from fastapi import FastAPI, HTTPException
|
| 4 |
+
from fastapi.responses import RedirectResponse
|
| 5 |
from pydantic import BaseModel, Field
|
| 6 |
|
| 7 |
from rag.chain import aanswer
|
|
|
|
| 31 |
return {"status": "ok"}
|
| 32 |
|
| 33 |
|
| 34 |
+
@app.get("/", include_in_schema=False)
|
| 35 |
+
async def root() -> RedirectResponse:
|
| 36 |
+
"""Redirect root to the Swagger UI so Spaces shows the API docs at '/'."""
|
| 37 |
+
return RedirectResponse(url="/docs")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
@app.post("/chat", response_model=ChatResponse)
|
| 41 |
async def chat(payload: ChatRequest) -> ChatResponse:
|
| 42 |
try:
|