RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix IDE warnings (#12085)
Jin Hai993bf7c2c87e
diff --git a/api/apps/__init__.py b/api/apps/__init__.pyindex 63de1fbf38..6934e7aed2 100644--- a/api/apps/__init__.py+++ b/api/apps/__init__.py@@ -108,7 +108,7 @@ def _load_user():authorization = request.headers.get("Authorization")g.user = Noneif not authorization:- return+ return Nonetry:access_token = str(jwt.loads(authorization))diff --git a/api/apps/mcp_server_app.py b/api/apps/mcp_server_app.pyindex 2c656df181..62ae2e3c06 100644--- a/api/apps/mcp_server_app.py+++ b/api/apps/mcp_server_app.py@@ -326,7 +326,6 @@ async def list_tools() -> Response:try:tools = await asyncio.to_thread(tool_call_session.get_tools, timeout)except Exception as e:- tools = []return get_data_error_result(message=f"MCP list tools error: {e}")results[server_key] = []@@ -428,7 +427,6 @@ async def test_mcp() -> Response:try:tools = await asyncio.to_thread(tool_call_session.get_tools, timeout)except Exception as e:- tools = []return get_data_error_result(message=f"Test MCP error: {e}")finally:# PERF: blocking call to close sessions — consider moving to background thread or task queuediff --git a/api/apps/sdk/chat.py b/api/apps/sdk/chat.pyindex fb426b0f01..1efb628f1b 100644--- a/api/apps/sdk/chat.py+++ b/api/apps/sdk/chat.py@@ -287,7 +287,7 @@ def list_chat(tenant_id):chats = DialogService.get_list(tenant_id, page_number, items_per_page, orderby, desc, id, name)if not chats:return get_result(data=[])- list_assts = []+ list_assistants = []key_mapping = {"parameters": "variables","prologue": "opener",@@ -321,5 +321,5 @@ def list_chat(tenant_id):del res["kb_ids"]res["datasets"] = kb_listres["avatar"] = res.pop("icon")- list_assts.append(res)- return get_result(data=list_assts)+ list_assistants.append(res)+ return get_result(data=list_assistants)diff --git a/api/apps/sdk/files.py b/api/apps/sdk/files.pyindex 9587d0f152..a618777884 100644--- a/api/apps/sdk/files.py+++ b/api/apps/sdk/files.py@@ -205,7 +205,8 @@ async def create(tenant_id):if not FileService.is_parent_folder_exist(pf_id):return get_json_result(data=False, message="Parent Folder Doesn't Exist!", code=RetCode.BAD_REQUEST)if FileService.query(name=req["name"], parent_id=pf_id):- return get_json_result(data=False, message="Duplicated folder name in the same folder.", code=409)+ return get_json_result(data=False, message="Duplicated folder name in the same folder.",+ code=RetCode.CONFLICT)if input_file_type == FileType.FOLDER.value:file_type = FileType.FOLDER.value@@ -565,11 +566,13 @@ async def rename(tenant_id):if file.type != FileType.FOLDER.value and pathlib.Path(req["name"].lower()).suffix != pathlib.Path(file.name.lower()).suffix:- return get_json_result(data=False, message="The extension of file can't be changed", code=RetCode.BAD_REQUEST)+ return get_json_result(data=False, message="The extension of file can't be changed",+ code=RetCode.BAD_REQUEST)for existing_file in FileService.query(name=req["name"], pf_id=file.parent_id):if existing_file.name == req["name"]:- return get_json_result(data=False, message="Duplicated file name in the same folder.", code=409)+ return get_json_result(data=False, message="Duplicated file name in the same folder.",+ code=RetCode.CONFLICT)if not FileService.update_by_id(req["file_id"], {"name": req["name"]}):return get_json_result(message="Database error (File rename)!", code=RetCode.SERVER_ERROR)@@ -631,9 +634,10 @@ async def get(tenant_id, file_id):except Exception as e:return server_error_response(e)+@manager.route("/file/download/<attachment_id>", methods=["GET"]) # noqa: F821@token_required-async def download_attachment(tenant_id,attachment_id):+async def download_attachment(tenant_id, attachment_id):try:ext = request.args.get("ext", "markdown")data = await asyncio.to_thread(settings.STORAGE_IMPL.get, tenant_id, attachment_id)@@ -645,6 +649,7 @@ async def download_attachment(tenant_id,attachment_id):except Exception as e:return server_error_response(e)+@manager.route('/file/mv', methods=['POST']) # noqa: F821@token_requiredasync def move(tenant_id):diff --git a/api/apps/sdk/session.py b/api/apps/sdk/session.pyindex e4db542162..ef83ad24eb 100644--- a/api/apps/sdk/session.py+++ b/api/apps/sdk/session.py@@ -448,7 +448,7 @@ async def chat_completion_openai_like(tenant_id, chat_id):@token_requiredasync def agents_completion_openai_compatibility(tenant_id, agent_id):req = await get_request_json()- tiktokenenc = tiktoken.get_encoding("cl100k_base")+ tiktoken_encode = tiktoken.get_encoding("cl100k_base")messages = req.get("messages", [])if not messages:return get_error_data_result("You must provide at least one message.")@@ -456,7 +456,7 @@ async def agents_completion_openai_compatibility(tenant_id, agent_id):return get_error_data_result(f"You don't own the agent {agent_id}")filtered_messages = [m for m in messages if m["role"] in ["user", "assistant"]]- prompt_tokens = sum(len(tiktokenenc.encode(m["content"])) for m in filtered_messages)+ prompt_tokens = sum(len(tiktoken_encode.encode(m["content"])) for m in filtered_messages)if not filtered_messages:return jsonify(get_data_openai(@@ -464,7 +464,7 @@ async def agents_completion_openai_compatibility(tenant_id, agent_id):content="No valid messages found (user or assistant).",finish_reason="stop",model=req.get("model", ""),- completion_tokens=len(tiktokenenc.encode("No valid messages found (user or assistant).")),+ completion_tokens=len(tiktoken_encode.encode("No valid messages found (user or assistant).")),prompt_tokens=prompt_tokens,))@@ -501,6 +501,8 @@ async def agents_completion_openai_compatibility(tenant_id, agent_id):):return jsonify(response)+ return None+@manager.route("/agents/<agent_id>/completions", methods=["POST"]) # noqa: F821@token_required@@ -920,6 +922,7 @@ async def chatbot_completions(dialog_id):async for answer in iframe_completion(dialog_id, **req):return get_result(data=answer)+ return None@manager.route("/chatbots/<dialog_id>/info", methods=["GET"]) # noqa: F821async def chatbots_inputs(dialog_id):@@ -967,6 +970,7 @@ async def agent_bot_completions(agent_id):async for answer in agent_completion(objs[0].tenant_id, agent_id, **req):return get_result(data=answer)+ return None@manager.route("/agentbots/<agent_id>/inputs", methods=["GET"]) # noqa: F821async def begin_inputs(agent_id):diff --git a/api/apps/user_app.py b/api/apps/user_app.pyindex 50c0b4d764..e1ad157bc7 100644--- a/api/apps/user_app.py+++ b/api/apps/user_app.py@@ -660,7 +660,7 @@ def user_register(user_id, user):tenant_llm = get_init_tenant_llm(user_id)if not UserService.save(**user):- return+ return NoneTenantService.insert(**tenant)UserTenantService.insert(**usr_tenant)TenantLLMService.insert_many(tenant_llm)diff --git a/common/constants.py b/common/constants.pyindex 490a5a4e3f..7bd00c3b04 100644--- a/common/constants.py+++ b/common/constants.py@@ -54,6 +54,7 @@ class RetCode(IntEnum, CustomEnum):SERVER_ERROR = 500FORBIDDEN = 403NOT_FOUND = 404+ CONFLICT = 409class StatusEnum(Enum):