zhaoqingang
2024-11-19 5ef590b70cc8e2de16083af2ee2d977daae5587c
app/service/ragflow.py
@@ -146,12 +146,15 @@
                }
            ] if data else []
    async def get_session_history(self, token: str, chat_id: str) -> list:
    async def get_session_history(self, token: str, chat_id: str, is_all: int=0):
        url = f"{self.base_url}/v1/conversation/get?conversation_id={chat_id}"
        headers = {"Authorization": token}
        async with httpx.AsyncClient() as client:
            response = await client.get(url, headers=headers)
            data = self._handle_response(response)
            # print("----------------data----------------------:", data)
            if is_all:
                return data
            return data.get("message", [])
    async def upload_and_parse(self, token: str, chat_id: str, filename: str, file: bytes) -> str:
@@ -172,6 +175,7 @@
        data = {"email": email, "user_id": user_id}
        async with httpx.AsyncClient(timeout=60) as client:
            response = await client.post(url, headers=headers, json=data)
            print(response)
            if response.status_code != 200:
                raise Exception(f"Ragflow add user to tenant failed: {response.text}")