Unverified Commit be54f8e5 authored by Nicolas Frenay's avatar Nicolas Frenay Committed by GitHub
Browse files

[Fix] Change /generate response-type to json for non-streaming (#374)

parent b396cb49
...@@ -3,7 +3,7 @@ import json ...@@ -3,7 +3,7 @@ import json
from typing import AsyncGenerator from typing import AsyncGenerator
from fastapi import BackgroundTasks, FastAPI, Request from fastapi import BackgroundTasks, FastAPI, Request
from fastapi.responses import Response, StreamingResponse from fastapi.responses import JSONResponse, Response, StreamingResponse
import uvicorn import uvicorn
from vllm.engine.arg_utils import AsyncEngineArgs from vllm.engine.arg_utils import AsyncEngineArgs
...@@ -64,7 +64,7 @@ async def generate(request: Request) -> Response: ...@@ -64,7 +64,7 @@ async def generate(request: Request) -> Response:
prompt = final_output.prompt prompt = final_output.prompt
text_outputs = [prompt + output.text for output in final_output.outputs] text_outputs = [prompt + output.text for output in final_output.outputs]
ret = {"text": text_outputs} ret = {"text": text_outputs}
return Response(content=json.dumps(ret)) return JSONResponse(ret)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment