Fix FastAPI route response_model for Response-returning endpoints
Browse files- tiny_vllm/server.py +7 -7
tiny_vllm/server.py
CHANGED
|
@@ -102,19 +102,19 @@ def build_app(config: EngineConfig, cors_allow_origins: Optional[list[str]] = No
|
|
| 102 |
# (which has no Python backend and just serves files from web/).
|
| 103 |
app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
|
| 104 |
|
| 105 |
-
@app.get("/")
|
| 106 |
async def root() -> FileResponse:
|
| 107 |
return FileResponse(str(static_dir / "index.html"))
|
| 108 |
|
| 109 |
-
@app.get("/style.css")
|
| 110 |
async def _css() -> FileResponse:
|
| 111 |
return FileResponse(str(static_dir / "style.css"))
|
| 112 |
|
| 113 |
-
@app.get("/app.js")
|
| 114 |
async def _js() -> FileResponse:
|
| 115 |
return FileResponse(str(static_dir / "app.js"))
|
| 116 |
|
| 117 |
-
@app.get("/events.jsonl")
|
| 118 |
async def _jsonl() -> FileResponse:
|
| 119 |
return FileResponse(str(static_dir / "events.jsonl"))
|
| 120 |
else:
|
|
@@ -137,7 +137,7 @@ def build_app(config: EngineConfig, cors_allow_origins: Optional[list[str]] = No
|
|
| 137 |
async def snapshot() -> dict:
|
| 138 |
return engine.snapshot()
|
| 139 |
|
| 140 |
-
@app.get("/engine/events")
|
| 141 |
async def events(request: Request) -> StreamingResponse:
|
| 142 |
q = engine.subscribe_events()
|
| 143 |
|
|
@@ -176,7 +176,7 @@ def build_app(config: EngineConfig, cors_allow_origins: Optional[list[str]] = No
|
|
| 176 |
ignore_eos=req.ignore_eos,
|
| 177 |
)
|
| 178 |
|
| 179 |
-
@app.post("/generate")
|
| 180 |
async def generate(req: GenerateRequest, request: Request) -> StreamingResponse | JSONResponse:
|
| 181 |
try:
|
| 182 |
rid = engine.add_request(req.prompt, _params(req))
|
|
@@ -218,7 +218,7 @@ def build_app(config: EngineConfig, cors_allow_origins: Optional[list[str]] = No
|
|
| 218 |
|
| 219 |
return StreamingResponse(gen(), media_type="text/event-stream")
|
| 220 |
|
| 221 |
-
@app.post("/v1/completions")
|
| 222 |
async def completions(req: CompletionsRequest, request: Request):
|
| 223 |
# Single-prompt only (n=1) for the minimal impl.
|
| 224 |
if isinstance(req.prompt, list):
|
|
|
|
| 102 |
# (which has no Python backend and just serves files from web/).
|
| 103 |
app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
|
| 104 |
|
| 105 |
+
@app.get("/", response_model=None)
|
| 106 |
async def root() -> FileResponse:
|
| 107 |
return FileResponse(str(static_dir / "index.html"))
|
| 108 |
|
| 109 |
+
@app.get("/style.css", response_model=None)
|
| 110 |
async def _css() -> FileResponse:
|
| 111 |
return FileResponse(str(static_dir / "style.css"))
|
| 112 |
|
| 113 |
+
@app.get("/app.js", response_model=None)
|
| 114 |
async def _js() -> FileResponse:
|
| 115 |
return FileResponse(str(static_dir / "app.js"))
|
| 116 |
|
| 117 |
+
@app.get("/events.jsonl", response_model=None)
|
| 118 |
async def _jsonl() -> FileResponse:
|
| 119 |
return FileResponse(str(static_dir / "events.jsonl"))
|
| 120 |
else:
|
|
|
|
| 137 |
async def snapshot() -> dict:
|
| 138 |
return engine.snapshot()
|
| 139 |
|
| 140 |
+
@app.get("/engine/events", response_model=None)
|
| 141 |
async def events(request: Request) -> StreamingResponse:
|
| 142 |
q = engine.subscribe_events()
|
| 143 |
|
|
|
|
| 176 |
ignore_eos=req.ignore_eos,
|
| 177 |
)
|
| 178 |
|
| 179 |
+
@app.post("/generate", response_model=None)
|
| 180 |
async def generate(req: GenerateRequest, request: Request) -> StreamingResponse | JSONResponse:
|
| 181 |
try:
|
| 182 |
rid = engine.add_request(req.prompt, _params(req))
|
|
|
|
| 218 |
|
| 219 |
return StreamingResponse(gen(), media_type="text/event-stream")
|
| 220 |
|
| 221 |
+
@app.post("/v1/completions", response_model=None)
|
| 222 |
async def completions(req: CompletionsRequest, request: Request):
|
| 223 |
# Single-prompt only (n=1) for the minimal impl.
|
| 224 |
if isinstance(req.prompt, list):
|