zhaoqingang
2025-01-03 b7ad7ae90cd832281afe6d743776ad87f1e56e07
app/service/difyService.py
@@ -65,28 +65,22 @@
                raise Exception("Authorization header not found in response")
            return authorization
    async def chat(self, token: str, user_id: int,  message: str, upload_file_id: str, conversation_id: str):
    async def chat(self, token: str, user_id: int,  message: str, files: list, conversation_id: str, inputs:dict):
        target_url = f"{self.base_url}/v1/chat-messages"
        files = []
        if upload_file_id:
            files = [
                {
                    "type": "image",
                    "transfer_method": "local_file",
                    "url": "",
                    "upload_file_id": upload_file_id
                }
            ]
        data = {
            "inputs": {},
            "inputs": inputs,
            "query": message,
            "response_mode": "streaming",
            "conversation_id": conversation_id,
            "user": str(user_id),
            "files": files
        }
        # if parent_message_id:
        # data["parent_message_id"] = parent_message_id
        # print("----------------------------------------------")
        # print(data)
        # print("-----------------------------------------------")
        async with httpx.AsyncClient(timeout=300.0) as client:
            headers = {
                'Content-Type': 'application/json',