fix(rag): align knowledge engine plugin actions

This commit is contained in:
huanghuoguoguo
2026-05-16 10:34:10 +08:00
parent ac3989d3ba
commit 948591d439
6 changed files with 18 additions and 20 deletions

View File

@@ -660,15 +660,6 @@ class PluginRuntimeConnector:
async for ret in gen: async for ret in gen:
yield ret yield ret
# KnowledgeRetriever methods
async def list_knowledge_retrievers(self, bound_plugins: list[str] | None = None) -> list[dict[str, Any]]:
"""List all available KnowledgeRetriever components."""
if not self.is_enable_plugin:
return []
retrievers_data = await self.handler.list_knowledge_retrievers(include_plugins=bound_plugins)
return retrievers_data
async def retrieve_knowledge( async def retrieve_knowledge(
self, self,
plugin_author: str, plugin_author: str,

View File

@@ -979,7 +979,7 @@ class RuntimeConnectionHandler(handler.Handler):
except Exception as e: except Exception as e:
return _make_rag_error_response(e, 'VectorStoreError', collection_id=collection_id) return _make_rag_error_response(e, 'VectorStoreError', collection_id=collection_id)
@self.action(PluginToRuntimeAction.GET_KNOWLEDEGE_FILE_STREAM) @self.action(PluginToRuntimeAction.GET_KNOWLEDGE_FILE_STREAM)
async def get_knowledge_file_stream(data: dict[str, Any]) -> handler.ActionResponse: async def get_knowledge_file_stream(data: dict[str, Any]) -> handler.ActionResponse:
storage_path = data['storage_path'] storage_path = data['storage_path']
try: try:

View File

@@ -107,7 +107,7 @@ class RAGRuntimeService:
) )
async def get_file_stream(self, storage_path: str) -> bytes: async def get_file_stream(self, storage_path: str) -> bytes:
"""Handle GET_KNOWLEDEGE_FILE_STREAM action. """Handle GET_KNOWLEDGE_FILE_STREAM action.
Uses the storage manager abstraction to load file content, Uses the storage manager abstraction to load file content,
regardless of the underlying storage provider. regardless of the underlying storage provider.

2
uv.lock generated
View File

@@ -2036,7 +2036,7 @@ dev = [
[[package]] [[package]]
name = "langbot-plugin" name = "langbot-plugin"
version = "0.3.10" version = "0.3.11"
source = { editable = "../langbot-plugin-sdk" } source = { editable = "../langbot-plugin-sdk" }
dependencies = [ dependencies = [
{ name = "aiofiles" }, { name = "aiofiles" },

View File

@@ -26,6 +26,7 @@ import { Button } from '@/components/ui/button';
import { Copy, Check, Globe, QrCode } from 'lucide-react'; import { Copy, Check, Globe, QrCode } from 'lucide-react';
import { copyToClipboard } from '@/app/utils/clipboard'; import { copyToClipboard } from '@/app/utils/clipboard';
import { systemInfo } from '@/app/infra/http'; import { systemInfo } from '@/app/infra/http';
import { parseDynamicFormItemType } from './DynamicFormItemConfig';
/** /**
* Resolve the value referenced by a `show_if.field` string. * Resolve the value referenced by a `show_if.field` string.
@@ -196,14 +197,8 @@ function WebhookUrlField({
/** /**
* Normalize plugin manifest type names to frontend-compatible types * Normalize plugin manifest type names to frontend-compatible types
*/ */
function normalizeItemType(type: string): string { function normalizeItemType(type: string): DynamicFormItemType {
const typeMap: Record<string, string> = { return parseDynamicFormItemType(type);
'select-llm-model': DynamicFormItemType.LLM_MODEL_SELECTOR,
'select-knowledge-bases': DynamicFormItemType.KNOWLEDGE_BASE_MULTI_SELECTOR,
number: DynamicFormItemType.FLOAT,
json: DynamicFormItemType.TEXT,
};
return typeMap[type] || type;
} }
export default function DynamicFormComponent({ export default function DynamicFormComponent({

View File

@@ -41,6 +41,18 @@ export function isDynamicFormItemType(
} }
export function parseDynamicFormItemType(value: string): DynamicFormItemType { export function parseDynamicFormItemType(value: string): DynamicFormItemType {
const typeMap: Record<string, DynamicFormItemType> = {
[DynamicFormItemType.SELECT_LLM_MODEL]:
DynamicFormItemType.LLM_MODEL_SELECTOR,
[DynamicFormItemType.SELECT_KNOWLEDGE_BASES]:
DynamicFormItemType.KNOWLEDGE_BASE_MULTI_SELECTOR,
[DynamicFormItemType.NUMBER]: DynamicFormItemType.FLOAT,
[DynamicFormItemType.JSON]: DynamicFormItemType.TEXT,
};
if (value in typeMap) {
return typeMap[value];
}
return isDynamicFormItemType(value) ? value : DynamicFormItemType.UNKNOWN; return isDynamicFormItemType(value) ? value : DynamicFormItemType.UNKNOWN;
} }