From ee56f33aa17940dc6a019762dd155401be4d11a2 Mon Sep 17 00:00:00 2001 From: wangmeihua <13383952685@163.com> Date: Tue, 29 Jul 2025 18:31:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9rag/init.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rag/init.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/rag/init.py b/rag/init.py index 916e7eb..2f6046d 100644 --- a/rag/init.py +++ b/rag/init.py @@ -18,8 +18,7 @@ async def _make_connection_request(action: str, params: dict = None) -> dict: if params is None: params = {} - url = "http://localhost:8888/v1/connection" - payload = {"action": action, "params": params} + url = f"http://localhost:8888/v1/{action}" try: debug(f"发起 {action} 请求: params={params}") @@ -27,7 +26,7 @@ async def _make_connection_request(action: str, params: dict = None) -> dict: async with session.post( url, headers={"Content-Type": "application/json"}, - json=payload + json=params ) as response: response_text = await response.text() debug(f"收到 {action} 响应: status={response.status}, content={response_text}") @@ -53,14 +52,6 @@ async def _make_connection_request(action: str, params: dict = None) -> dict: "status_code": 500 } -async def initialize() -> dict: - """初始化 服务""" - return await _make_connection_request("initialize") - -async def get_params() -> dict: - """获取服务参数""" - return await _make_connection_request("get_params") - async def create_collection(db_type: str = "") -> dict: """创建 Milvus 集合""" return await _make_connection_request("create_collection", {"db_type": db_type}) @@ -138,6 +129,10 @@ async def list_all_knowledge_bases(db_type: str = "") -> dict: """列出所有用户的知识库及其文件""" return await _make_connection_request("list_all_knowledge_bases", {"db_type": db_type}) +async def docs() -> dict: + """列出所有用户的知识库及其文件""" + return await _make_connection_request("docs", {}) + def load_rag(): """ 初始化 ServerEnv,绑定 MilvusConnection 的所有功能。 @@ -154,5 +149,4 @@ def load_rag(): env.fused_search = fused_search env.list_user_files = list_user_files env.list_all_knowledge_bases = list_all_knowledge_bases - - + env.docs = docs \ No newline at end of file