From 09746f2d79a8c37903633b3e6ada4aeba3e719f4 Mon Sep 17 00:00:00 2001 From: zxstty Date: Tue, 25 Feb 2025 21:02:58 +0800 Subject: [PATCH] =?UTF-8?q?rag=20call=E9=80=82=E9=85=8D;flow=E7=BC=96?= =?UTF-8?q?=E6=8E=92=E5=B7=A6=E4=BE=A7service=E5=B1=95=E7=A4=BA=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/manager/flow.py | 2 +- apps/scheduler/call/rag.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/manager/flow.py b/apps/manager/flow.py index b76589357..c2966d2ac 100644 --- a/apps/manager/flow.py +++ b/apps/manager/flow.py @@ -102,7 +102,7 @@ class FlowManager: service_collection = MongoDB.get_collection("service") try: match_conditions = [ - {"name": "系统"}, + {"author": "system"}, {"author": user_sub}, { "$and": [ diff --git a/apps/scheduler/call/rag.py b/apps/scheduler/call/rag.py index 3cace0fd2..96248e75e 100644 --- a/apps/scheduler/call/rag.py +++ b/apps/scheduler/call/rag.py @@ -16,9 +16,9 @@ from apps.scheduler.call.core import CoreCall class _RAGParams(BaseModel): """RAG工具的参数""" - knowledge_base: str = Field(description="知识库的id", alias="kb_sn") + knowledge_base: str = Field(description="知识库的id", alias="kb_sn", default=None) top_k: int = Field(description="返回的答案数量(经过整合以及上下文关联)", default=5) - methods: Optional[list[str]] = Field(description="rag检索方法") + retrieval_mode: str = Field(description="检索模式", default="chunk", choices=['chunk', 'full_text']) class _RAGOutputList(BaseModel): @@ -45,8 +45,7 @@ class RAG(metaclass=CoreCall, param_cls=_RAGParams, output_cls=_RAGOutput): params: _RAGParams = getattr(self, "_params") params_dict = params.model_dump(exclude_none=True, by_alias=True) - params_dict["question"] = syscall_vars.question - + params_dict["content"] = syscall_vars.question url = config["RAG_HOST"].rstrip("/") + "/chunk/get" headers = { "Content-Type": "application/json", @@ -59,6 +58,8 @@ class RAG(metaclass=CoreCall, param_cls=_RAGParams, output_cls=_RAGOutput): if response.status == status.HTTP_200_OK: result = await response.json() chunk_list = result["data"] + for chunk in chunk_list: + chunk=chunk.replace("\n", " ") return _RAGOutput( output=_RAGOutputList(corpus=chunk_list), ) -- Gitee