Download api/ask.py from dasomaru/gemma: direct link, hf CLI and curl.
- Browser
- Download file 476 Bytes
-
https://huggingface.co/spaces/dasomaru/gemma/resolve/main/api/ask.py
- Command line
-
hf download hf://spaces/dasomaru/gemma/api/ask.py
-
curl -L -o ask.py https://huggingface.co/spaces/dasomaru/gemma/resolve/main/api/ask.py
476 Bytes
| from fastapi import APIRouter | |
| from pydantic import BaseModel | |
| from services.rag_pipeline import rag_pipeline | |
| router = APIRouter() | |
| # 요청 스키마 | |
| class AskRequest(BaseModel): | |
| query: str | |
| top_k: int = 5 | |
| # 응답 스키마 | |
| class AskResponse(BaseModel): | |
| output: str | |
| async def ask(request: AskRequest): | |
| output = rag_pipeline(request.query, top_k=request.top_k) | |
| return {"output": output} | |