zhaoqingang
2024-11-25 8804c88450e4a1b6c8ab2ce1b433d073c4a9624d
app/service/difyService.py
@@ -5,6 +5,8 @@
from typing import Union, Dict, List
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
@@ -79,7 +81,7 @@
            "inputs": {},
            "query": message,
            "response_mode": "streaming",
            "conversation_id": conversation_id,
            "conversation_id": "",
            "user": str(user_id),
            "files": files
        }
@@ -93,7 +95,7 @@
                if response.status_code == 200:
                    try:
                        async for answer in response.aiter_text():
                            print(f"response of ragflow chat: {answer}")
                            # print(f"response of ragflow chat: {answer}")
                            yield answer
                    except GeneratorExit as e:
                        print(e)
@@ -128,6 +130,9 @@
        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