返回提交历史
Modified
g4f/api/__init__.py
+2
-1
XFEstudio/gpt4free
fix: api streaming TypeError: Object of type generator is not JSON serializable
ee5f2a4a
代码差异
1 个文件
+2
-1
@@ -1,4 +1,5 @@
1
1
from fastapi import FastAPI, Response, Request
2
from fastapi.responses import StreamingResponse
2
3
from typing import List, Union, Any, Dict, AnyStr
3
4
from ._tokenizer import tokenize
4
5
from .. import BaseProvider
@@ -151,7 +152,7 @@ class Api:
151
152
except GeneratorExit:
152
153
pass
153
154
154
return Response(content=json.dumps(streaming(), indent=4), media_type="application/json")
155
return StreamingResponse(streaming(), media_type="text/event-stream")
155
156
156
157
@self.app.post("/v1/completions")
157
158
async def completions():