mirror of https://github.com/langgenius/dify.git
variable assigner node
This commit is contained in:
parent
d92d952e76
commit
5013ea09d5
|
|
@ -44,6 +44,9 @@ class KnowledgeRetrievalNodeData(BaseNodeData):
|
|||
"""
|
||||
Knowledge retrieval Node Data.
|
||||
"""
|
||||
title: str
|
||||
desc: str
|
||||
type: str = 'knowledge-retrieval'
|
||||
query_variable_selector: list[str]
|
||||
dataset_ids: list[str]
|
||||
retrieval_mode: Literal['single', 'multiple']
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class KnowledgeRetrievalNode(BaseNode):
|
|||
# extract variables
|
||||
query = variable_pool.get_variable_value(variable_selector=node_data.query_variable_selector)
|
||||
variables = {
|
||||
'query': query
|
||||
'_query': query
|
||||
}
|
||||
# retrieve knowledge
|
||||
try:
|
||||
|
|
@ -163,9 +163,9 @@ class KnowledgeRetrievalNode(BaseNode):
|
|||
def _extract_variable_selector_to_variable_mapping(cls, node_data: BaseNodeData) -> dict[str, list[str]]:
|
||||
node_data = node_data
|
||||
node_data = cast(cls._node_data_cls, node_data)
|
||||
return {
|
||||
variable_selector.variable: variable_selector.value_selector for variable_selector in node_data.variables
|
||||
}
|
||||
variable_mapping = {}
|
||||
variable_mapping['_query'] = node_data.query_variable_selector
|
||||
return variable_mapping
|
||||
|
||||
def _single_retrieve(self, available_datasets, node_data, query):
|
||||
tools = []
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ class QuestionClassifierNodeData(BaseNodeData):
|
|||
"""
|
||||
query_variable_selector: list[str]
|
||||
title: str
|
||||
description: str
|
||||
desc: str
|
||||
type: str = 'question-classifier'
|
||||
model: ModelConfig
|
||||
classes: list[ClassConfig]
|
||||
instruction: str
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class QuestionClassifierNode(BaseNode):
|
|||
# extract variables
|
||||
query = variable_pool.get_variable_value(variable_selector=node_data.query_variable_selector)
|
||||
variables = {
|
||||
'query': query
|
||||
'_query': query
|
||||
}
|
||||
# fetch model config
|
||||
model_instance, model_config = self._fetch_model_config(node_data)
|
||||
|
|
@ -95,13 +95,12 @@ class QuestionClassifierNode(BaseNode):
|
|||
error=str(e)
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _extract_variable_selector_to_variable_mapping(cls, node_data: BaseNodeData) -> dict[str, list[str]]:
|
||||
node_data = node_data
|
||||
node_data = cast(cls._node_data_cls, node_data)
|
||||
return {
|
||||
variable_selector.variable: variable_selector.value_selector for variable_selector in node_data.variables
|
||||
}
|
||||
variable_mapping = {'_query': node_data.query_variable_selector}
|
||||
return variable_mapping
|
||||
|
||||
@classmethod
|
||||
def get_default_config(cls, filters: Optional[dict] = None) -> dict:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
from typing import Any, Literal, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.variable_entities import VariableSelector
|
||||
|
||||
|
||||
class VariableAssignerNodeData(BaseNodeData):
|
||||
"""
|
||||
Knowledge retrieval Node Data.
|
||||
"""
|
||||
title: str
|
||||
desc: str
|
||||
type: str = 'variable-assigner'
|
||||
output_type: str
|
||||
variables: list[str]
|
||||
|
|
@ -1,5 +1,15 @@
|
|||
from typing import cast
|
||||
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.node_entities import NodeRunResult
|
||||
from core.workflow.entities.variable_pool import VariablePool
|
||||
from core.workflow.nodes.base_node import BaseNode
|
||||
|
||||
|
||||
class VariableAssignerNode(BaseNode):
|
||||
pass
|
||||
def _run(self, variable_pool: VariablePool) -> NodeRunResult:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def _extract_variable_selector_to_variable_mapping(cls, node_data: BaseNodeData) -> dict[str, list[str]]:
|
||||
return {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue