From 6bac1630e5af5890a6922bdc624e591eb19a12eb Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 13 三月 2025 18:36:07 +0800
Subject: [PATCH] 知识库对接rg

---
 app/service/ragflow.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/service/ragflow.py b/app/service/ragflow.py
index f10902f..45961a6 100644
--- a/app/service/ragflow.py
+++ b/app/service/ragflow.py
@@ -19,7 +19,7 @@
             return {}
 
         data = response.json()
-        ret_code = data.get("retcode")
+        ret_code = data.get("retcode", data.get("code"))
         if ret_code == 401:
             raise HTTPException(
                 status_code=status.HTTP_401_UNAUTHORIZED,
@@ -48,13 +48,13 @@
                 raise Exception(f"Ragflow registration failed: {response.text}")
             return self._handle_response(response)
 
-    async def login(self, username: str, password: str) -> str:
+    async def login(self, username: str, password: str, email="") -> str:
         password = RagflowCrypto(settings.PUBLIC_KEY, settings.PRIVATE_KEY).encrypt(password)
         async with httpx.AsyncClient() as client:
             response = await client.post(
                 f"{self.base_url}/v1/user/login",
                 headers={'Content-Type': 'application/json'},
-                json={"email": f"{username}@example.com", "password": password}
+                json={"email": username if "@" in username else f"{username}@example.com", "password": password}
             )
             if response.status_code != 200:
                 raise Exception(f"Ragflow login failed: {response.text}")
@@ -136,6 +136,8 @@
         }
         async with httpx.AsyncClient() as client:
             response = await client.post(url, headers=headers, json=data)
+            print(response.status_code)
+            print(response.text)
             data = self._handle_response(response)
             return [
                 {

--
Gitblit v1.8.0