Skip to content

feat: Support reference model in ai chat node#4896

Merged
zhanweizhang7 merged 2 commits intotool-workflowfrom
pr@tool-workflow@feat_reference_model_in_ai
Mar 18, 2026
Merged

feat: Support reference model in ai chat node#4896
zhanweizhang7 merged 2 commits intotool-workflowfrom
pr@tool-workflow@feat_reference_model_in_ai

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Tool workflow node result
feat: Support reference model in ai chat node

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 18, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 18, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

const nodeCascaderRef = ref()
const ReasoningParamSettingDialogRef = ref<InstanceType<typeof ReasoningParamSettingDialog>>()
const validate = () => {
return aiChatNodeFormRef.value?.validate().catch((err) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Replace set(appState.chat, "node_model_data.reasoning_info", {}); with appState.node_model_data.reasoning_info = {};.
  • Adjust the conditional logic in the AI Chat Mode Param Setting Dialog to handle different conditions as needed.

props.nodeModel.clear_next_node_field(true)
})
.catch(() => {
set(props.nodeModel.properties, 'status', 500)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several areas where improvements could be made in the provided code:

  1. Simplified config_field_list Creation: The current method of creating config_field_list uses nested ternary operators which can make it difficult to read and maintain. It's more readable to use plain JavaScript methods.

  2. Object Shallow Copying for Existing Fields: Instead of using JSON.parse(JSON.stringify(...)) when updating existing fields, we can directly modify them since they are arrays. However, this requires careful handling to ensure no unintended side effects.

  3. Clear Next Node Field Execution: Ensure that props.nodeModel.clear_next_node_field(true) is called consistently throughout the function.

Here’s an optimized version of the code with these considerations:

const update_field = () => {
    loadSharedApi({ type: 'tool', systemType: apiType.value })
        .getToolById(props.nodeModel.properties.node_data.tool_lib_id)
        .then((ok: any) => {
            const workflowNodes = ok.data?.work_flow?.nodes || [];
            const baseNode = workflowNodes.find((n: any) => n.type === 'tool-base-node');

            if (baseNode) {
                const new_input_list = baseNode.properties.user_input_field_list || [];
                const new_output_list = baseNode.properties.user_output_field_list || [];

                // Create config_fields list from new_output_list
                let config_field_list = new_output_list.map(item => ({ label: item.label, value: item.field }));

                // Update original node data with new lists
                const old_input_list = props.nodeModel.properties.node_data.input_field_list || [];
                const merged_input_list = new_input_list.map(item => {
                    const findField = old_input_list.find(oldItem => oldItem.field === item.field);
                    return findField || item;
                });
                set(props.nodeModel.properties.node_data, 'input_field_list', merged_input_list);

                // Handle merging config fields
                const oldConfigFields = props.nodeModel.properties.config.fields || [];
                config_field_list.forEach(newField => {
                    const existingIndex = oldConfigFields.findIndex(ocf => ocf.value === newField.value);
                    if (existingIndex !== -1) {
                        // If field already exists, do nothing or merge properties accordingly
                        config_field_list[existingIndex] = { ...oldConfigFields[existingIndex], ...newField };
                    } else {
                        // Add new field if not found
                        config_field_list.push(newField);
                    }
                });

                const input_title = baseNode.properties.user_input_config?.title;
                const output_title = baseNode.properties.user_output_config?.title;

                set(props.nodeModel.properties.node_data, 'input_title', input_title);
                set(props.nodeModel.properties.config, 'output_title', output_title);

                // Clear next node field(s), assuming clear_next_node_field accepts a boolean condition
                props.nodeModel.clear_next_node_field(true);
                
                set(props.nodeModel.properties, 'status', ok.data.is_active ? 200 : 500);
            }

            // Set fallback status on failure
        }).catch(() => {
            set(props.nodeModel.properties, 'status', 500);
        });
};

Key Changes:

  • Simplified config_field_list creation.
  • Directly updated non-existing fields in merge_input_list.
  • Merged existing config fields while preserving uniqueness.
  • Ensured clear_next_node_field execution without modification risk.

Make sure to test this revised version thoroughly in your application environment to validate its functionality.


if model_setting is None:
model_setting = {'reasoning_content_enable': False, 'reasoning_content_end': '</think>',
'reasoning_content_start': '<think>'}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code has several improvements and corrections to ensure its functionality:

  1. Model ID Type Handling: The logic to handle model_id_type and model_id_reference fields is enhanced. It checks if model_id_type is set to 'reference' and if model_id_reference is not empty before attempting to fetch reference data using the workflow manager.

  2. Default Model Parameters Setting Retrieval: If no model_params_setting is provided, it retrieves a default setting from the system for the given model_id. This addresses cases where a specific configuration might be required but was not explicitly passed.

  3. Comments and Consistency: A comment is added explaining that comments may need more context about what they represent after further development on this line.

These changes make the function more robust, cleaner, and adaptable based on various conditions encountered during execution.

@zhanweizhang7 zhanweizhang7 merged commit 2b94faa into tool-workflow Mar 18, 2026
3 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@tool-workflow@feat_reference_model_in_ai branch March 18, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants