mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 05:25:00 +08:00
[Fix] Change /generate response-type to json for non-streaming (#374)
This commit is contained in:
parent
b396cb4998
commit
be54f8e5c4
@ -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:
|
|||||||
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__":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user