zhaoqingang
2025-02-14 74d286ea8e5be898d142f9ebed0d0c72dbdc5900
merge master
6个文件已修改
20 ■■■■■ 已修改文件
app/api/agent.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/auth.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/chat.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/user.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/service/difyService.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/service/ragflow.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/agent.py
@@ -231,6 +231,8 @@
            for i in session.log_to_json().get("message", []):
                if i.get("role") == "user":
                    tmp_data["question"] = i.get("content")
                    if "upload_filenames" in i:
                        tmp_data["upload_filenames"] = i.get("upload_filenames")
                elif i.get("role") == "assistant":
                    if isinstance(i.get("content"), dict):
                        content = i.get("content", {})
app/api/auth.py
@@ -126,16 +126,14 @@
            continue
        try:
            name = login_data.username
            email = ""
            app_password = login_data.password
            user_app = await UserAppDao(db).get_data_by_id(user.id, app["id"])
            if user_app:
                name  = user_app.username
                email  = user_app.email
                app_password = user_app.decrypted_password(user_app.password)
            else:
                await update_user_info(db, user.id)
            token = await service.login(name, app_password,email=email)
            token = await service.login(name, app_password)
            token_dict[app["id"]] = token
        except Exception as e:
            return Response(code=500, msg=f"Failed to login with {app['id']}: {str(e)}")
@@ -178,6 +176,8 @@
@router.post("/v2/register", response_model=Response)
async def register_v2(user: UserCreate, db=Depends(get_db)):
    if "@" in user.username:
        return Response(code=400, msg="Username cannot contain @")
    password = await password_rsa(user.password)
    if not is_valid_password(password):
        return Response(code=400, msg="The password must be at least 8 and contain both numbers and letters")
app/api/chat.py
@@ -435,6 +435,7 @@
                        receive_message = await websocket.receive_json()
                        print(f"Received from client {chat_id}: {receive_message}")
                        upload_files = receive_message.get('upload_files', [])
                        upload_filenames = receive_message.get('upload_filenames', [])
                        title = receive_message.get('title', "")
                        sub_titles = receive_message.get('sub_titles', "")
                        workflow_type = receive_message.get('workflow', 1)
@@ -458,7 +459,7 @@
                                AgentType.DIFY,
                                current_user.id,
                                {"role": "user", "content": title if title else title_query, "type": workflow_type,
                                 "is_clean": is_clean},
                                 "is_clean": is_clean, "upload_filenames":upload_filenames},
                                workflow_type
                            )
                            conversation_id = session.conversation_id
@@ -823,6 +824,7 @@
                        receive_message = await websocket.receive_json()
                        print(f"Received from client {chat_id}: {receive_message}")
                        upload_file_id = receive_message.get('upload_file_id', [])
                        upload_filenames = receive_message.get('upload_filenames', [])
                        question = receive_message.get('message', "")
                        if not question and not image_url:
                            await websocket.send_json({"message": "Invalid request", "type": "error"})
@@ -834,7 +836,7 @@
                                agent_id,
                                AgentType.DIFY,
                                current_user.id,
                                {"role": "user", "content": question}
                                {"role": "user", "content": question, "upload_filenames": upload_filenames}
                            )
                            conversation_id = session.conversation_id
                        except Exception as e:
app/api/user.py
@@ -23,6 +23,8 @@
async def add_user(user: UserInfo, current_user: UserModel = Depends(get_current_user), db=Depends(get_db)):
    if not user.userName:
        return Response(code=400, msg="The userName cannot be empty!")
    if "@" in user.userName:
        return Response(code=400, msg="Username cannot contain @")
    if user.pwd:
        if not is_valid_password(user.pwd):
            return Response(code=400, msg="The password must be at least 8 and contain both numbers and letters")
app/service/difyService.py
@@ -74,7 +74,7 @@
    async def login(self, username: str, password: str, remember_me=True, invite_token:str="", email="") -> str:
        # password = RagflowCrypto(settings.PUBLIC_KEY, settings.PRIVATE_KEY).encrypt(password)
        data = {"email":email if email else f"{username}@basic.com", "password": password, "remember_me": remember_me, "invite_token": invite_token,
        data = {"email":username if "@" in username else f"{username}@basic.com", "password": password, "remember_me": remember_me, "invite_token": invite_token,
         "language": "zh-Hans"}
        async with httpx.AsyncClient() as client:
app/service/ragflow.py
@@ -54,7 +54,7 @@
            response = await client.post(
                f"{self.base_url}/v1/user/login",
                headers={'Content-Type': 'application/json'},
                json={"email": email if email else 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}")