Procházet zdrojové kódy

fix preview and recommend plugins

tags/2.0.0-beta.1
jyong před 2 měsíci
rodič
revize
7ace7e65e1

+ 2
- 1
api/core/workflow/graph_engine/response_coordinator/session.py Zobrazit soubor

@@ -11,6 +11,7 @@ from core.workflow.nodes.answer.answer_node import AnswerNode
from core.workflow.nodes.base.node import Node
from core.workflow.nodes.base.template import Template
from core.workflow.nodes.end.end_node import EndNode
from core.workflow.nodes.knowledge_index import KnowledgeIndexNode


@dataclass
@@ -39,7 +40,7 @@ class ResponseSession:
Raises:
TypeError: If node is not an AnswerNode or EndNode
"""
if not isinstance(node, AnswerNode | EndNode):
if not isinstance(node, AnswerNode | EndNode | KnowledgeIndexNode):
raise TypeError
return cls(
node_id=node.id,

+ 13
- 1
api/core/workflow/nodes/knowledge_index/knowledge_index_node.py Zobrazit soubor

@@ -11,10 +11,11 @@ from core.rag.index_processor.index_processor_factory import IndexProcessorFacto
from core.rag.retrieval.retrieval_methods import RetrievalMethod
from core.workflow.entities.variable_pool import VariablePool
from core.workflow.entities.workflow_node_execution import WorkflowNodeExecutionStatus
from core.workflow.enums import ErrorStrategy, NodeType, SystemVariableKey
from core.workflow.enums import ErrorStrategy, NodeExecutionType, NodeType, SystemVariableKey
from core.workflow.node_events import NodeRunResult
from core.workflow.nodes.base.entities import BaseNodeData, RetryConfig
from core.workflow.nodes.base.node import Node
from core.workflow.nodes.base.template import Template
from extensions.ext_database import db
from models.dataset import Dataset, Document, DocumentSegment

@@ -37,6 +38,7 @@ default_retrieval_model = {
class KnowledgeIndexNode(Node):
_node_data: KnowledgeIndexNodeData
node_type = NodeType.KNOWLEDGE_INDEX
execution_type = NodeExecutionType.RESPONSE

def init_node_data(self, data: Mapping[str, Any]) -> None:
self._node_data = KnowledgeIndexNodeData.model_validate(data)
@@ -181,3 +183,13 @@ class KnowledgeIndexNode(Node):
@classmethod
def version(cls) -> str:
return "1"


def get_streaming_template(self) -> Template:
"""
Get the template for streaming.

Returns:
Template instance for this knowledge index node
"""
return Template(segments=[])

+ 32
- 18
api/services/rag_pipeline/rag_pipeline.py Zobrazit soubor

@@ -1244,7 +1244,7 @@ class RagPipelineService:
session.commit()
return workflow_node_execution_db_model

def get_recommended_plugins(self) -> list[dict]:
def get_recommended_plugins(self) -> dict:
# Query active recommended plugins
pipeline_recommended_plugins = (
db.session.query(PipelineRecommendedPlugin)
@@ -1254,26 +1254,40 @@ class RagPipelineService:
)
if not pipeline_recommended_plugins:
return []
return {
"installed_recommended_plugins": [],
"uninstalled_recommended_plugins": [],
}
# Batch fetch plugin manifests
plugin_ids = [plugin.plugin_id for plugin in pipeline_recommended_plugins]
providers = BuiltinToolManageService.list_builtin_tools(
user_id=current_user.id,
tenant_id=current_user.current_tenant_id,
)
providers_map = {provider.plugin_id: provider for provider in providers}

plugin_manifests = marketplace.batch_fetch_plugin_manifests(plugin_ids)
builtin_tools = BuiltinToolManageService.list_builtin_tools(
user_id=current_user.id,
tenant_id=current_user.current_tenant_id,
)
installed_plugin_ids = {tool.plugin_id for tool in builtin_tools}
plugin_manifests_map = {manifest.plugin_id: manifest for manifest in plugin_manifests}

installed_plugin_list = []
uninstalled_plugin_list = []
for plugin_id in plugin_ids:
if providers_map.get(plugin_id):
installed_plugin_list.append(providers_map.get(plugin_id))
else:
plugin_manifest = plugin_manifests_map.get(plugin_id)
if plugin_manifest:
uninstalled_plugin_list.append({
"plugin_id": plugin_id,
"name": plugin_manifest.name,
"icon": plugin_manifest.icon,
"plugin_unique_identifier": plugin_manifest.latest_package_identifier,
})

# Build recommended plugins list
return [
{
"plugin_id": manifest.plugin_id,
"name": manifest.name,
"icon": manifest.icon,
"plugin_unique_identifier": manifest.latest_package_identifier,
"installed": manifest.plugin_id in installed_plugin_ids,
}
for manifest in plugin_manifests
]
return {
"installed_recommended_plugins": installed_plugin_list,
"uninstalled_recommended_plugins": uninstalled_plugin_list,
}

Načítá se…
Zrušit
Uložit