修改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:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
url = "http://localhost:8888/v1/connection"
|
url = f"http://localhost:8888/v1/{action}"
|
||||||
payload = {"action": action, "params": params}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
debug(f"发起 {action} 请求: params={params}")
|
debug(f"发起 {action} 请求: params={params}")
|
||||||
@ -27,7 +26,7 @@ async def _make_connection_request(action: str, params: dict = None) -> dict:
|
|||||||
async with session.post(
|
async with session.post(
|
||||||
url,
|
url,
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
json=payload
|
json=params
|
||||||
) as response:
|
) as response:
|
||||||
response_text = await response.text()
|
response_text = await response.text()
|
||||||
debug(f"收到 {action} 响应: status={response.status}, content={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
|
"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:
|
async def create_collection(db_type: str = "") -> dict:
|
||||||
"""创建 Milvus 集合"""
|
"""创建 Milvus 集合"""
|
||||||
return await _make_connection_request("create_collection", {"db_type": db_type})
|
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})
|
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():
|
def load_rag():
|
||||||
"""
|
"""
|
||||||
初始化 ServerEnv,绑定 MilvusConnection 的所有功能。
|
初始化 ServerEnv,绑定 MilvusConnection 的所有功能。
|
||||||
@ -154,5 +149,4 @@ def load_rag():
|
|||||||
env.fused_search = fused_search
|
env.fused_search = fused_search
|
||||||
env.list_user_files = list_user_files
|
env.list_user_files = list_user_files
|
||||||
env.list_all_knowledge_bases = list_all_knowledge_bases
|
env.list_all_knowledge_bases = list_all_knowledge_bases
|
||||||
|
env.docs = docs
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user