修改rag/init.py
This commit is contained in:
parent
5eeaa77e22
commit
ee56f33aa1
20
rag/init.py
20
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
|
||||
Loading…
x
Reference in New Issue
Block a user