-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Intent node #4109
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
fix: Intent node #4109
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 |
|---|---|---|
|
|
@@ -341,6 +341,7 @@ export default { | |
| label: '意图识别', | ||
| text: '将用户问题与用户预设的意图分类进行匹配', | ||
| other: '其他', | ||
| error2: '意图重复', | ||
| placeholder: '请选择分类项', | ||
| classify: { | ||
| label: '意图分类', | ||
|
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 code looks mostly clean and well-structured. However, here are some minor improvements and points to consider:
Overall, the code is ready for production use without significant issues. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,10 +90,6 @@ | |
| /> | ||
| </el-form-item> | ||
| <el-form-item | ||
| :rules="{ | ||
| required: true, | ||
| trigger: 'change', | ||
| }" | ||
| > | ||
| <template #label> | ||
| <div class="flex-between"> | ||
|
|
@@ -113,6 +109,14 @@ | |
| v-for="(item, index) in form_data.branch" | ||
| v-resize="(wh: any) => resizeBranch(wh, item, index)" | ||
| :key="item.id" | ||
| > | ||
| <el-form-item | ||
| :prop="`branch.${index}.content`" | ||
| :rules="{ | ||
| message: $t('views.applicationWorkflow.nodes.intentNode.classify.placeholder'), | ||
| trigger: 'change', | ||
| required: true, | ||
| }" | ||
| > | ||
| <el-row class="mb-8" :gutter="12" align="middle"> | ||
| <el-col :span="21"> | ||
|
|
@@ -138,6 +142,7 @@ | |
| </el-button> | ||
| </el-col> | ||
| </el-row> | ||
| </el-form-item> | ||
| </div> | ||
| </div> | ||
| </el-form-item> | ||
|
|
@@ -326,10 +331,15 @@ const IntentClassifyNodeFormRef = ref<FormInstance>() | |
| const modelOptions = ref<any>(null) | ||
|
|
||
| const validate = () => { | ||
|
|
||
| return Promise.all([ | ||
| nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(''), | ||
| IntentClassifyNodeFormRef.value?.validate(), | ||
| ]).catch((err: any) => { | ||
| ]).then(() => { | ||
| if (form_data.value.branch.length != new Set(form_data.value.branch.map((item: any) => item.content)).size) { | ||
| throw t('views.applicationWorkflow.nodes.intentNode.error2') | ||
| } | ||
| }).catch((err: any) => { | ||
| return Promise.reject({ node: props.nodeModel, errMessage: err }) | ||
| }) | ||
| } | ||
|
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. Some areas for improvement:
const validate = async () => {
try {
await nodeCascaderRef.value.validate()
await intent_classify_form_ref.validate()
// Check for uniqueness
const unique_values = new Set(form_data.value.branch.map((item: any) =>
item.content || item.label // Handle cases where label exists but content doesn't
)
if (unique_values.size !== form_data.value.branch.length) {
throw new Error(t('views.applicationWorkflow.nodes.intentNode.error2'))
}
} catch (error) {
return Promise.reject({
node: props.nodeModel,
errorMessage: error.message || t('views.applicationWorkflow.common.validationFailed')
})
}
}
These changes aim to make the form validation process more efficient and user-friendly while maintaining clarity. |
||
|
|
||
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.
There appears to be an issue with the key name in
classify:labelis repeated, resulting in a warning due to duplicate keys when parsing JSON data. This can lead to inconsistent behavior and bugs if it isn't addressed properly.Recommendation:
Rename the
labelwithin theclassifyobject to avoid duplicates. Here's an updated version:Additional Suggestions:
Consistent Object Key Naming: Ensure that all objects in the array have consistent naming patterns for easy maintenance and readability.
Error Handling: Consider adding more detailed handling for potential errors, such as validation checks before submitting user input.
Dynamic UI Elements: If you plan to dynamically generate these options based on some logic (e.g., based on user roles), ensure those elements are managed correctly.
API Integration: If this code will integrate with an API, consider any specific requirements or best practices for sending structured data.
By addressing these points, you can improve the robustness and maintainability of your code.