Aliancn 在 使用python接入dify 中发帖
今天用python请求Dify的流式输出的时候遇到点问题,希望有佬指点一下,具体情况是代码1使用requests可以正常输出,代码2使用httpx不行,会在连接建立后立即断开,没有输出。最后结果作为fastapi的结果返回。
代码1
try:
response = requests.post(
url, headers=headers, json=data, stream=True)
# 检查Dify平台的响应状态
if response.status_code != 200:
raise HTTPException(
status_code=response.status_code, detail="Dify API request failed")
...