最近在写大模型的流式输出调用,发现一些小错误进行修改。
报错:requests.exceptions.ChunkedEncodingError: Response ended prematurely
原因:
1. 流式输出没有加stream=True
修改:
2. 如果使用的是openai的接口,那就是用client.chat.completions.create
3. 使用fastapi异步需要在函数前使用async,且后面用yield
async def get_problem_ways(problem:str,level:str):
xxxxxxxxxx
yield f"{choice}\n\n"
暂时是这三,其他还有会不定时更新