mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-19 03:25:32 +00:00
Merge pull request #1221 from Giancarlo-Ma/main
fix: api streaming TypeError: Object of type generator is not JSON serializable
This commit is contained in:
commit
f7156766d4
@ -1,4 +1,5 @@
|
|||||||
from fastapi import FastAPI, Response, Request
|
from fastapi import FastAPI, Response, Request
|
||||||
|
from fastapi.responses import StreamingResponse
|
||||||
from typing import List, Union, Any, Dict, AnyStr
|
from typing import List, Union, Any, Dict, AnyStr
|
||||||
from ._tokenizer import tokenize
|
from ._tokenizer import tokenize
|
||||||
from .. import BaseProvider
|
from .. import BaseProvider
|
||||||
@ -151,7 +152,7 @@ class Api:
|
|||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return Response(content=json.dumps(streaming(), indent=4), media_type="application/json")
|
return StreamingResponse(streaming(), media_type="text/event-stream")
|
||||||
|
|
||||||
@self.app.post("/v1/completions")
|
@self.app.post("/v1/completions")
|
||||||
async def completions():
|
async def completions():
|
||||||
|
Loading…
Reference in New Issue
Block a user