Spaces:
Runtime error
Runtime error
Download src/server.py from Ayush027/async-rust-rag: direct link, hf CLI and curl.
- Browser
- Download file 497 Bytes
-
https://huggingface.co/spaces/Ayush027/async-rust-rag/resolve/main/src/server.py
- Command line
-
hf download hf://spaces/Ayush027/async-rust-rag/src/server.py
-
curl -L -o server.py https://huggingface.co/spaces/Ayush027/async-rust-rag/resolve/main/src/server.py
497 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from query import query | |
| from fastapi.middleware.cors import CORSMiddleware | |
| app = FastAPI() | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["https://rustler.in"], | |
| allow_methods=["POST"], | |
| allow_headers=["*"] | |
| ) | |
| class QueryRequest(BaseModel): | |
| question:str | |
| def ask(req:QueryRequest): | |
| answer, sources, _ = query(req.question) | |
| return {"answer":answer, "sources":list(set(sources))} | |