-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: create application ui #3190
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 |
---|---|---|
|
@@ -121,11 +121,11 @@ const dialogVisible = ref<boolean>(false) | |
const applicationForm = ref<ApplicationFormType>({ | ||
name: '', | ||
desc: '', | ||
model_id: '', | ||
model_id: undefined, | ||
dialogue_number: 1, | ||
prologue: t('views.application.form.defaultPrologue'), | ||
dataset_id_list: [], | ||
dataset_setting: { | ||
knowledge_id_list: [], | ||
knowledge_setting: { | ||
top_n: 3, | ||
similarity: 0.6, | ||
max_paragraph_char_number: 5000, | ||
|
@@ -143,8 +143,8 @@ const applicationForm = ref<ApplicationFormType>({ | |
model_params_setting: {}, | ||
problem_optimization: false, | ||
problem_optimization_prompt: optimizationPrompt, | ||
stt_model_id: '', | ||
tts_model_id: '', | ||
stt_model_id: undefined, | ||
tts_model_id: undefined, | ||
stt_model_enable: false, | ||
tts_model_enable: false, | ||
tts_type: 'BROWSER', | ||
|
@@ -175,11 +175,11 @@ watch(dialogVisible, (bool) => { | |
applicationForm.value = { | ||
name: '', | ||
desc: '', | ||
model_id: '', | ||
model_id: undefined, | ||
dialogue_number: 1, | ||
prologue: t('views.application.form.defaultPrologue'), | ||
dataset_id_list: [], | ||
dataset_setting: { | ||
knowledge_id_list: [], | ||
knowledge_setting: { | ||
top_n: 3, | ||
similarity: 0.6, | ||
max_paragraph_char_number: 5000, | ||
|
@@ -197,8 +197,8 @@ watch(dialogVisible, (bool) => { | |
model_params_setting: {}, | ||
problem_optimization: false, | ||
problem_optimization_prompt: optimizationPrompt, | ||
stt_model_id: '', | ||
tts_model_id: '', | ||
stt_model_id: undefined, | ||
tts_model_id: undefined, | ||
stt_model_enable: false, | ||
tts_model_enable: false, | ||
tts_type: 'BROWSER', | ||
|
@@ -208,32 +208,39 @@ watch(dialogVisible, (bool) => { | |
} | ||
}) | ||
|
||
const open = (folder: string, type?: sting) => { | ||
const open = (folder: string, type?: string) => { | ||
currentFolder.value = folder | ||
applicationForm.value.type = type || 'SIMPLE' | ||
dialogVisible.value = true | ||
} | ||
|
||
const submitHandle = async (formEl: FormInstance | undefined) => { | ||
if (!formEl) return | ||
console.log(applicationForm.value.type) | ||
await formEl.validate((valid) => { | ||
if (valid) { | ||
applicationForm.value['folder_id'] = currentFolder.value | ||
if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') { | ||
workflowDefault.value.nodes[0].properties.node_data.desc = applicationForm.value.desc | ||
workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name | ||
applicationForm.value['work_flow'] = workflowDefault.value | ||
} | ||
applicationApi.postApplication('default', applicationForm.value, loading).then((res) => { | ||
MsgSuccess(t('common.createSuccess')) | ||
emit('refresh') | ||
if (isWorkFlow(applicationForm.value.type)) { | ||
router.push({ path: `/application/${res.data.id}/workflow` }) | ||
} else { | ||
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` }) | ||
} | ||
dialogVisible.value = false | ||
}) | ||
console.log(applicationForm.value.type) | ||
applicationApi | ||
.postApplication( | ||
'default', | ||
{ ...applicationForm.value, folder_id: currentFolder.value }, | ||
loading, | ||
) | ||
.then((res) => { | ||
MsgSuccess(t('common.createSuccess')) | ||
emit('refresh') | ||
if (isWorkFlow(applicationForm.value.type)) { | ||
router.push({ path: `/application/${res.data.id}/workflow` }) | ||
} else { | ||
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` }) | ||
} | ||
dialogVisible.value = false | ||
}) | ||
} | ||
}) | ||
} | ||
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 has the following issues:
To optimize the submitHandle function:
These modifications ensure robust error handling and better readability of the code. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ | |
</el-button> | ||
<template #dropdown> | ||
<el-dropdown-menu class="create-dropdown"> | ||
<el-dropdown-item @click="openCreateDialog"> | ||
<el-dropdown-item @click="openCreateDialog('SIMPLE')"> | ||
<div class="flex"> | ||
<el-avatar shape="square" class="avatar-blue mt-4" :size="36"> | ||
<img | ||
|
@@ -248,7 +248,7 @@ import useStore from '@/stores' | |
import { numberFormat } from '@/utils/common' | ||
import { t } from '@/locales' | ||
import { useRouter } from 'vue-router' | ||
|
||
import { isWorkFlow } from '@/utils/application' | ||
const router = useRouter() | ||
const { folder } = useStore() | ||
|
||
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 appears to be TypeScript/JavaScript code for a Vue component related to creating resources within an application. Here are some observations and potential improvements: Observations:
Improvement Suggestions:Add Missing
|
||
|
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.
The provided code appears to be TypeScript interfaces and classes related to a chat management system. Here are some observations and potential improvements:
Interface
ApplicationFormType
:dataset_id_list
andknowledge_setting
toknowledge_id_list
andknowledge_setting
, which might indicate that there's a change in the data model based on user feedback or new requirements.Class
ChatRecordManage
:writeNodeInfo
,findIndex
, and others need further review for their logic and potential errors.current_node.buffer.splice(...)
) with optional parameters should be carefully reviewed to ensure they operate correctly without causing unintended behavior.appendAnswer
and its usage seem consistent but could benefit from better comments explaining the purpose of each argument.General Improvements:
if...else
statements).map()
orreduce()
when applicable.Here is a brief summary of potential optimizations and fixes:
Error Handling: Add try-catch blocks around methods dealing with database operations or file I/O to catch unexpected errors gracefully.
Readability Enhancements: Use meaningful variable names, add comments explain complex logic, and refactor code to adhere to best practices.
By addressing these areas, you can create a more robust and efficient system.