XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

fix: api streaming TypeError: Object of type generator is not JSON serializable

ee5f2a4a
Giancarlo-Ma <65126107+Giancarlo-Ma@users.noreply.github.com>
提交于

代码差异

1 个文件 +2 -1
Modified g4f/api/__init__.py +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():