diff --git a/apps/application/flow/step_node/ai_chat_step_node/i_chat_node.py b/apps/application/flow/step_node/ai_chat_step_node/i_chat_node.py index c9a348c6bd0..994fda75df6 100644 --- a/apps/application/flow/step_node/ai_chat_step_node/i_chat_node.py +++ b/apps/application/flow/step_node/ai_chat_step_node/i_chat_node.py @@ -16,7 +16,10 @@ class ChatNodeSerializer(serializers.Serializer): - model_id = serializers.CharField(required=True, label=_("Model id")) + model_id = serializers.CharField(required=False, allow_blank=True, allow_null=True, label=_("Model id")) + model_id_type = serializers.CharField(required=False, default='custom', label=_("Model id type")) + model_id_reference = serializers.ListField(required=False, child=serializers.CharField(), allow_empty=True, + label=_("Reference Field")) system = serializers.CharField(required=False, allow_blank=True, allow_null=True, label=_("Role Setting")) prompt = serializers.CharField(required=True, label=_("Prompt word")) @@ -58,7 +61,7 @@ def get_node_params_serializer_class(self) -> Type[serializers.Serializer]: def _run(self): if [WorkflowMode.KNOWLEDGE, WorkflowMode.KNOWLEDGE_LOOP, WorkflowMode.TOOL, WorkflowMode.TOOL_LOOP].__contains__( - self.workflow_manage.flow.workflow_mode): + self.workflow_manage.flow.workflow_mode): return self.execute(**self.node_params_serializer.data, **self.flow_params_serializer.data, **{'history_chat_record': [], 'stream': True, 'chat_id': None, 'chat_record_id': None}) else: @@ -67,6 +70,8 @@ def _run(self): def execute(self, model_id, system, prompt, dialogue_number, history_chat_record, stream, chat_id, chat_record_id, model_params_setting=None, + model_id_type=None, + model_id_reference=None, dialogue_type=None, model_setting=None, mcp_servers=None, diff --git a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py index 4fdd9680194..ec42376e91e 100644 --- a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py +++ b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py @@ -151,6 +151,8 @@ def save_context(self, details, workflow_manage): def execute(self, model_id, system, prompt, dialogue_number, history_chat_record, stream, chat_id, chat_record_id, model_params_setting=None, + model_id_type=None, + model_id_reference=None, dialogue_type=None, model_setting=None, mcp_servers=None, @@ -165,8 +167,20 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record if dialogue_type is None: dialogue_type = 'WORKFLOW' - if model_params_setting is None: + if model_id_type == 'reference' and model_id_reference: + + reference_data = self.workflow_manage.get_reference_field( + model_id_reference[0], + model_id_reference[1:], + ) + + if reference_data and isinstance(reference_data, dict): + model_id = reference_data.get('model_id', model_id) + model_params_setting = reference_data.get('model_params_setting') + + if model_params_setting is None and model_id: model_params_setting = get_default_model_params_setting(model_id) + if model_setting is None: model_setting = {'reasoning_content_enable': False, 'reasoning_content_end': '', 'reasoning_content_start': ''} diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index e8365e2b825..ea80cb8860a 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -1050,10 +1050,6 @@ export const toolWorkflowLibNode = { stepName: t('workflow.nodes.toolWorlflowNode.label','工作流工具'), config: { fields: [ - { - label: t('common.result'), - value: 'result', - }, ], }, }, diff --git a/ui/src/workflow/nodes/ai-chat-node/index.vue b/ui/src/workflow/nodes/ai-chat-node/index.vue index 460b5f8e8ee..90effb0a944 100644 --- a/ui/src/workflow/nodes/ai-chat-node/index.vue +++ b/ui/src/workflow/nodes/ai-chat-node/index.vue @@ -13,10 +13,10 @@ > @@ -28,7 +28,27 @@ }}* - + + + + + + +
+
+ +
+
- - +
+
@@ -71,7 +88,7 @@ type="primary" link @click="openGeneratePromptDialog(chat_data.model_id)" - :disabled="!chat_data.model_id" + :disabled="chat_data.model_id_type === 'reference' || !chat_data.model_id" > @@ -458,6 +475,7 @@