| | |
| | | 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,存到files 列表中 |
| | |
| | | headers={"Content-Disposition": f"attachment; filename={filename}"} |
| | | ) |
| | | else: |
| | | return Response(code=400, msg="Unsupported file type") |
| | | 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") |