From ff512163de5a74e264787330c21251061241ce94 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Mon, 23 Mar 2026 21:18:49 +0800 Subject: [PATCH] docs(plugin): remove deprecated pipeline-scoped KB API docs (zh/en/ja) Remove list_pipeline_knowledge_bases and retrieve_knowledge from Request API section as they are fully superseded by the global Knowledge Base APIs. --- en/plugin/dev/apis/common.mdx | 62 +---------------------------------- ja/plugin/dev/apis/common.mdx | 62 +---------------------------------- zh/plugin/dev/apis/common.mdx | 62 +---------------------------------- 3 files changed, 3 insertions(+), 183 deletions(-) diff --git a/en/plugin/dev/apis/common.mdx b/en/plugin/dev/apis/common.mdx index b1d6174b1..71b6b4f96 100644 --- a/en/plugin/dev/apis/common.mdx +++ b/en/plugin/dev/apis/common.mdx @@ -82,66 +82,6 @@ async def get_query_vars(self) -> dict[str, Any]: query_vars = await event_context.get_query_vars() ``` -### List Knowledge Bases Configured for the Current Pipeline - -Get the knowledge bases configured in the pipeline used by the current request. - -```python -async def list_pipeline_knowledge_bases(self) -> list[dict[str, Any]]: - """List knowledge bases configured for the current pipeline""" - -# Usage example -knowledge_bases = await event_context.list_pipeline_knowledge_bases() - -# Return example -[ - { - "uuid": "kb_uuid", - "name": "Product Docs", - "description": "Internal product documentation", - } -] -``` - -This only returns knowledge bases bound in the current pipeline's `Local Agent` configuration. If the pipeline has no knowledge base configured, or is not using `Local Agent`, an empty list is returned. - -### Retrieve Knowledge from the Current Pipeline Scope - -Run retrieval against the knowledge bases that are allowed for the current request's pipeline. - -```python -async def retrieve_knowledge( - self, - kb_id: str, - query_text: str, - top_k: int = 5, - filters: dict[str, Any] | None = None, -) -> list[dict[str, Any]]: - """Retrieve relevant documents from a knowledge base""" - -# Usage example -knowledge_bases = await event_context.list_pipeline_knowledge_bases() -results = await event_context.retrieve_knowledge( - kb_id=knowledge_bases[0]["uuid"], - query_text="How do I configure the enterprise knowledge base?", - top_k=3, - filters={"document_type": {"$eq": "manual"}}, -) - -# Return example -[ - { - "id": "chunk_0", - "content": [{"type": "text", "text": "Knowledge base configuration guide"}], - "metadata": {"document_id": "doc_001"}, - "distance": 0.12, - "score": 0.88, - } -] -``` - -`kb_id` must come from `list_pipeline_knowledge_bases` and must belong to a knowledge base configured for the current pipeline. Otherwise, LangBot returns an error. - ## LangBot API These APIs can be called in any plugin component. Access methods: @@ -442,7 +382,7 @@ for entry in results: ``` :::tip -Unlike the query-based `list_pipeline_knowledge_bases()` and `retrieve_knowledge()` in the Request API, these APIs do not require a `query_id` and can be used in any component (including Tool components). They can access all knowledge bases without being restricted to the current pipeline's configuration. +These APIs do not require a `query_id` and can be used in any component (including Tool components). They can access all knowledge bases without being restricted to the current pipeline's configuration. ::: ## RAG API diff --git a/ja/plugin/dev/apis/common.mdx b/ja/plugin/dev/apis/common.mdx index dbe35f156..88eeaae72 100644 --- a/ja/plugin/dev/apis/common.mdx +++ b/ja/plugin/dev/apis/common.mdx @@ -82,66 +82,6 @@ async def get_query_vars(self) -> dict[str, Any]: query_vars = await event_context.get_query_vars() ``` -### 現在のパイプラインに設定されたナレッジベース一覧の取得 - -現在のリクエストで使用されているパイプラインに設定されたナレッジベース一覧を取得します。 - -```python -async def list_pipeline_knowledge_bases(self) -> list[dict[str, Any]]: - """List knowledge bases configured for the current pipeline""" - -# 使用例 -knowledge_bases = await event_context.list_pipeline_knowledge_bases() - -# 返却例 -[ - { - "uuid": "kb_uuid", - "name": "Product Docs", - "description": "社内製品ドキュメント", - } -] -``` - -返されるのは、現在のパイプラインの `Local Agent` 設定に紐づいたナレッジベースだけです。ナレッジベースが未設定、または `Local Agent` を使っていない場合は空配列になります。 - -### 現在のパイプライン範囲でナレッジを検索 - -現在のリクエストのパイプラインで許可されているナレッジベースの範囲内で検索を実行します。 - -```python -async def retrieve_knowledge( - self, - kb_id: str, - query_text: str, - top_k: int = 5, - filters: dict[str, Any] | None = None, -) -> list[dict[str, Any]]: - """Retrieve relevant documents from a knowledge base""" - -# 使用例 -knowledge_bases = await event_context.list_pipeline_knowledge_bases() -results = await event_context.retrieve_knowledge( - kb_id=knowledge_bases[0]["uuid"], - query_text="エンタープライズ向けナレッジベースの設定方法は?", - top_k=3, - filters={"document_type": {"$eq": "manual"}}, -) - -# 返却例 -[ - { - "id": "chunk_0", - "content": [{"type": "text", "text": "ナレッジベース設定ガイド"}], - "metadata": {"document_id": "doc_001"}, - "distance": 0.12, - "score": 0.88, - } -] -``` - -`kb_id` は `list_pipeline_knowledge_bases` の返却値から取得し、現在のパイプラインに設定されたナレッジベースである必要があります。そうでない場合、LangBot はエラーを返します。 - ## LangBot API これらのAPIは、任意のプラグインコンポーネントで呼び出すことができます。アクセス方法: @@ -442,7 +382,7 @@ for entry in results: ``` :::tip -リクエストAPIの`list_pipeline_knowledge_bases()`や`retrieve_knowledge()`とは異なり、これらのAPIは`query_id`を必要とせず、任意のコンポーネント(Toolコンポーネントを含む)で使用できます。現在のパイプライン設定に制限されることなく、すべてのナレッジベースにアクセスできます。 +これらのAPIは`query_id`を必要とせず、任意のコンポーネント(Toolコンポーネントを含む)で使用できます。現在のパイプライン設定に制限されることなく、すべてのナレッジベースにアクセスできます。 ::: ## RAG API diff --git a/zh/plugin/dev/apis/common.mdx b/zh/plugin/dev/apis/common.mdx index 2cd287bef..235cecc2d 100644 --- a/zh/plugin/dev/apis/common.mdx +++ b/zh/plugin/dev/apis/common.mdx @@ -82,66 +82,6 @@ async def get_query_vars(self) -> dict[str, Any]: query_vars = await event_context.get_query_vars() ``` -### 获取当前流水线配置的知识库列表 - -获取当前请求所使用流水线中配置的知识库列表。 - -```python -async def list_pipeline_knowledge_bases(self) -> list[dict[str, Any]]: - """List knowledge bases configured for the current pipeline""" - -# 调用示例 -knowledge_bases = await event_context.list_pipeline_knowledge_bases() - -# 返回示例 -[ - { - "uuid": "kb_uuid", - "name": "Product Docs", - "description": "内部产品文档", - } -] -``` - -仅返回当前请求对应流水线在 `Local Agent` 配置中绑定的知识库。若当前流水线未配置知识库,或未使用 `Local Agent`,则返回空列表。 - -### 检索当前流水线内的知识库 - -在当前请求所属流水线允许访问的知识库范围内执行检索。 - -```python -async def retrieve_knowledge( - self, - kb_id: str, - query_text: str, - top_k: int = 5, - filters: dict[str, Any] | None = None, -) -> list[dict[str, Any]]: - """Retrieve relevant documents from a knowledge base""" - -# 调用示例 -knowledge_bases = await event_context.list_pipeline_knowledge_bases() -results = await event_context.retrieve_knowledge( - kb_id=knowledge_bases[0]["uuid"], - query_text="如何配置企业知识库?", - top_k=3, - filters={"document_type": {"$eq": "manual"}}, -) - -# 返回示例 -[ - { - "id": "chunk_0", - "content": [{"type": "text", "text": "知识库配置说明"}], - "metadata": {"document_id": "doc_001"}, - "distance": 0.12, - "score": 0.88, - } -] -``` - -`kb_id` 必须来自 `list_pipeline_knowledge_bases` 的返回结果,且必须属于当前流水线已配置的知识库,否则 LangBot 会返回错误。 - ## LangBot API 这些 API 可在插件任何组件中调用。访问方式如下: @@ -442,7 +382,7 @@ for entry in results: ``` :::tip -与请求 API 中的 `list_pipeline_knowledge_bases()` 和 `retrieve_knowledge()` 不同,这些 API 不需要 `query_id`,可以在任何组件中使用(包括 Tool 组件),且可以访问所有知识库,不受当前流水线配置限制。 +这些 API 不需要 `query_id`,可以在任何组件中使用(包括 Tool 组件),且可以访问所有知识库,不受当前流水线配置限制。 ::: ## RAG API