From 28f41fceef54144cf87eaedd18d09a5a8b9cd5e1 Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期三, 27 十一月 2024 09:40:58 +0800 Subject: [PATCH] dify 多次对话问题 --- app/api/files.py | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/api/files.py b/app/api/files.py index 7df40e1..2189f94 100644 --- a/app/api/files.py +++ b/app/api/files.py @@ -75,7 +75,7 @@ if agent_id == "basic_excel_talk": # 澶勭悊鍗曚釜鏂囦欢鐨勬儏鍐� file_list = file - if len(file) == 1 and agent.agent_type != AgentType.BASIC: + if len(file) == 1: # and agent.agent_type != AgentType.BASIC file_list = [file[0]] # 濡傛灉鍙湁涓�涓枃浠讹紝纭繚瀹冩槸涓�涓垪琛� service = BasicService(base_url=settings.basic_base_url) # 閬嶅巻file_list锛屽瓨鍒癴iles 鍒楄〃涓� @@ -188,4 +188,19 @@ headers={"Content-Disposition": f"attachment; filename={filename}"} ) else: - return Response(code=400, msg="Unsupported file type") \ No newline at end of file + return Response(code=400, msg="Unsupported file type") + + +@router.get("/image/{imageId}", response_model=Response) +async def download_image_file(imageId: str, db=Depends(get_db)): + file_path = f"app/images/{imageId}.png" + + def generate(): + with open(file_path, "rb") as file: + while True: + data = file.read(1048576) # 璇诲彇1MB + if not data: + break + yield data + + return StreamingResponse(generate(), media_type="application/octet-stream") \ No newline at end of file -- Gitblit v1.8.0