| | |
| | | from fastapi import HTTPException |
| | | from starlette import status |
| | | |
| | | from Log import logger |
| | | from app.config.config import settings |
| | | from app.utils.rsa_crypto import RagflowCrypto |
| | | |
| | |
| | | "inputs": {}, |
| | | "query": message, |
| | | "response_mode": "streaming", |
| | | "conversation_id": "", |
| | | "conversation_id": conversation_id, |
| | | "user": str(user_id), |
| | | "files": files |
| | | } |
| | |
| | | |
| | | return data |
| | | |
| | | async def save_images(self, url: str, filename: str): |
| | | url = f"{self.base_url}{url}" |
| | | |
| | | async with httpx.AsyncClient() as client: |
| | | response = await client.get(url) |
| | | |
| | | response.raise_for_status() |
| | | |
| | | # 打开一个文件用于写入 |
| | | with open(f"app/images/{filename}", 'wb') as f: |
| | | # 写入请求的内容 |
| | | f.write(response.content) |
| | | |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | async def a(): |
| | | a = DifyService("http://192.168.20.119:11080") |
| | | b = await a.get_knowledge_list("ImY3ZTZlZWQwYTY2NTExZWY5ZmFiMDI0MmFjMTMwMDA2Ig.Zzxwmw.uI_HAWzOkipQuga1aeQtoeIc3IM", 1, |
| | | 10) |
| | | a = DifyService("http://192.168.20.116") |
| | | b = await a.get_session_history("app-YmOAMDsPpDDlqryMHnc9TzTO", "f94c6328-8ff0-4713-af3f-e823d547682d", |
| | | "63") |
| | | print(b) |
| | | |
| | | import asyncio |