zhaoqingang
2024-11-25 c795d4b39ce86ad9b502044d96df9392c0c7dca7
app/service/difyService.py
@@ -17,6 +17,8 @@
    def _handle_response(self, response: httpx.Response) -> Union[Dict, List]:
        if response.status_code != 200:
            if response.status_code == 201:
                return response.json()
            return {}
        data = response.json()
@@ -35,7 +37,7 @@
        elif isinstance(data.get("data"), list):
            return data.get("data", [])
        else:
            return {}
            return data
    async def register(self, username: str, password: str):
        password = RagflowCrypto(settings.PUBLIC_KEY, settings.PRIVATE_KEY).encrypt(password)
@@ -81,7 +83,7 @@
            "inputs": {},
            "query": message,
            "response_mode": "streaming",
            "conversation_id": conversation_id,
            "conversation_id": "",
            "user": str(user_id),
            "files": files
        }
@@ -130,15 +132,8 @@
        async with httpx.AsyncClient() as client:
            response = await client.post(url, headers=headers, files=files, data=data)
            data = self._handle_response(response)
            logger.error("----------------------------ffff-------------------------------")
            logger.error(response.status_code)
            logger.error(response.text)
            # file_path = data.get("file_path", "")
            result = {
                "file_path": data
            }
            return result
            return data