-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: Intent STT TTS node support model reference #4948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,15 @@ | |
| > | ||
| <el-form-item | ||
| :label="$t('workflow.nodes.speechToTextNode.stt_model.label')" | ||
| prop="stt_model_id" | ||
| :prop=" | ||
| form_data.stt_model_id_type === 'reference' ? 'stt_model_id_reference' : 'stt_model_id' | ||
| " | ||
| :rules="{ | ||
| required: true, | ||
| message: $t('views.application.form.voiceInput.placeholder'), | ||
| message: | ||
| form_data.stt_model_id_type === 'reference' | ||
| ? $t('workflow.variable.placeholder') | ||
| : $t('views.application.form.voiceInput.placeholder'), | ||
| trigger: 'change', | ||
| }" | ||
| > | ||
|
|
@@ -28,27 +33,45 @@ | |
| }}<span class="color-danger">*</span></span | ||
| > | ||
| </div> | ||
| <el-button | ||
| type="primary" | ||
| link | ||
| @click="openSTTParamSettingDialog" | ||
| :disabled="!form_data.stt_model_id" | ||
| class="mr-4" | ||
| <el-select | ||
| v-model="form_data.stt_model_id_type" | ||
| :teleported="false" | ||
| size="small" | ||
| style="width: 85px" | ||
| @change="form_data.stt_model_id_reference = []" | ||
| > | ||
| <AppIcon iconName="app-setting"></AppIcon> | ||
| </el-button> | ||
| <el-option :label="$t('workflow.variable.Referencing')" value="reference" /> | ||
| <el-option :label="$t('common.custom')" value="custom" /> | ||
| </el-select> | ||
| </div> | ||
| </template> | ||
| <ModelSelect | ||
| @wheel="wheel" | ||
| :teleported="false" | ||
| @change="sttModelChange" | ||
| v-model="form_data.stt_model_id" | ||
| :placeholder="$t('views.application.form.voiceInput.placeholder')" | ||
| :options="modelOptions" | ||
| showFooter | ||
| :model-type="'STT'" | ||
| ></ModelSelect> | ||
| <div class="flex-between w-full" v-if="form_data.stt_model_id_type !== 'reference'"> | ||
| <ModelSelect | ||
| @wheel="wheel" | ||
| :teleported="false" | ||
| @change="sttModelChange" | ||
| v-model="form_data.stt_model_id" | ||
| :placeholder="$t('views.application.form.voiceInput.placeholder')" | ||
| :options="modelOptions" | ||
| showFooter | ||
| :model-type="'STT'" | ||
| ></ModelSelect> | ||
| <div class="ml-8"> | ||
| <el-button @click="openSTTParamSettingDialog" :disabled="!form_data.stt_model_id"> | ||
| <el-icon> | ||
| <Operation /> | ||
| </el-icon> | ||
| </el-button> | ||
| </div> | ||
| </div> | ||
| <NodeCascader | ||
| v-else | ||
| ref="nodeCascaderRef" | ||
| :nodeModel="nodeModel" | ||
| class="w-full" | ||
| :placeholder="$t('workflow.variable.placeholder')" | ||
| v-model="form_data.stt_model_id_reference" | ||
| /> | ||
| </el-form-item> | ||
| <el-form-item | ||
| :label="$t('workflow.nodes.speechToTextNode.audio.label')" | ||
|
|
@@ -168,6 +191,8 @@ const wheel = (e: any) => { | |
|
|
||
| const form = { | ||
| stt_model_id: '', | ||
| stt_model_id_type: 'custom', | ||
| stt_model_id_reference: [], | ||
| is_result: true, | ||
| audio_list: [], | ||
| model_params_setting: {}, | ||
|
|
@@ -176,6 +201,12 @@ const form = { | |
| const form_data = computed({ | ||
| get: () => { | ||
| if (props.nodeModel.properties.node_data) { | ||
| if (!props.nodeModel.properties.node_data.stt_model_id_type) { | ||
| set(props.nodeModel.properties.node_data, 'stt_model_id_type', 'custom') | ||
| } | ||
| if (!props.nodeModel.properties.node_data.stt_model_id_reference) { | ||
| set(props.nodeModel.properties.node_data, 'stt_model_id_reference', []) | ||
| } | ||
| return props.nodeModel.properties.node_data | ||
| } else { | ||
| set(props.nodeModel.properties, 'node_data', form) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet contains several improvements and corrections:
These changes make the code more robust, intuitive, and maintainable while addressing potential bugs in input validation and layout adjustments. Note: Make sure translations ($t() calls) are correctly configured and available for the specified languages ('workflow.variable.label', etc.). |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some potential issues and suggestions from reviewing the given code:
Potential Issues
Variable Scope Issue:
modelChangeis declared within an inner function but not defined outside of it. This might indicate that there's an issue with its scope, possibly resulting in undefined behavior.Missing Function Definitions:
getSelectModel,resetModalSettings, and other functions used within Vue templates (v-ondirectives) need to be properly defined elsewhere in the component or passed down by parent components.Conditional Rendering Logic:
form_data.model_id_type. Consider simplifying the logic where possible.Component Interaction:
<NodeCascader>component references properties likenode_modelwhich aren't defined in the provided snippet. Ensure this component has access to necessary data.Translation Strings:
$tis called directly within templates without a context (like<lang:.../>) ensure translations are correctly loaded into the application.Optimization Suggestions
Reduce Repetitive Code:
Use Vuex Actions for Mutations:
Lazy Loading Components:
<ModelSelect>and<NodeCascader>are large or complex components, consider lazy loading them only when needed during runtime to improve initial app performance.Optimize Template Structure:
Avoid Inline Event Handlers:
Suggested Improvements
This suggested approach reduces redundancy, optimizes component interactions, enhances scalability, and improves overall code quality through proper separation of concerns within Vue instances via the Composition API pattern introduced in Vue 3.