22 <el-dialog
33 align-center
44 v-model =" dialogVisible"
5- style =" width : 600 px "
5+ style =" width : 800 px "
66 append-to-body
77 :close-on-click-modal =" true"
88 :close-on-press-escape =" true"
99 :before-close =" handleDialogClose"
1010 >
1111 <template #title >
1212 <div class =" flex-between" >
13- <div class = " flex " >生成Python代码</ div >
14- <div class =" flex" >
15- <div >{{ $t('views.application.form.aiModel.label') }}</div >
13+ <h4 >{{ $t('views.tool.generateCodeDialog.generatePrompt') }}</ h4 >
14+ <div class =" flex align-center " >
15+ <div class = " mr-4 lighter " >{{ $t('views.application.form.aiModel.label') }}</div >
1616 <ModelSelect
1717 v-model =" model_id"
1818 :placeholder =" $t('views.application.form.aiModel.placeholder')"
2121 @submitModel =" getSelectModel"
2222 showFooter
2323 :model-type =" 'LLM'"
24- style =" width : 200px ; "
24+ style =" width : 200px "
2525 >
2626 </ModelSelect >
27- <el-button
28- class =" ml-8"
29- @click =" openAIParamSettingDialog"
30- :disabled =" !model_id"
31- >
27+ <el-button class =" ml-8" @click =" openAIParamSettingDialog" :disabled =" !model_id" >
3228 <el-icon >
3329 <Operation />
3430 </el-icon >
5147 </div >
5248 <p v-else-if =" loading" shadow =" always" style =" margin : 0.5rem 0 " >
5349 <el-icon class =" is-loading color-primary mr-4" >
54- <Loading />
50+ <Loading />
5551 </el-icon >
5652 {{ $t('views.application.generateDialog.loading') }}
5753 <span class =" dotting" ></span >
5854 </p >
5955 <p v-else class =" flex align-center" >
6056 <AppIcon iconName =" app-generate-star" class =" color-primary mr-4" ></AppIcon >
61- {{ $t('生成python代码 ') }}
57+ {{ $t('views.tool.generateCodeDialog.title ') }}
6258 </p >
6359 </el-scrollbar >
6460
9389 v-model =" inputValue"
9490 :autosize =" { minRows: 1, maxRows: 10 }"
9591 type =" textarea"
96- :placeholder =" $t('views.application.generateDialog .placeholder')"
92+ :placeholder =" $t('views.tool.generateCodeDialog .placeholder')"
9793 :maxlength =" 100000"
9894 class =" chat-operate-textarea"
9995 @keydown.enter =" handleSubmit($event)"
120116 </div >
121117 </div >
122118 </div >
123- <AIModeParamSettingDialog ref =" AIModeParamSettingDialogRef" @refresh =" refreshForm" />
119+ <AIModeParamSettingDialog ref =" AIModeParamSettingDialogRef" @refresh =" refreshForm" />
124120 </el-dialog >
125121</template >
126122
@@ -131,13 +127,13 @@ import { MsgConfirm } from '@/utils/message'
131127import { t } from ' @/locales'
132128import useStore from ' @/stores'
133129import { copyClick } from ' @/utils/clipboard'
134- import { loadSharedApi } from " @/utils/dynamics-api/shared-api.ts" ;
135- import { groupBy } from " lodash" ;
136- import AIModeParamSettingDialog from " @/views/application/component/AIModeParamSettingDialog.vue" ;
137- import SendIcon from " @/components/logo/SendIcon.vue" ;
130+ import { loadSharedApi } from ' @/utils/dynamics-api/shared-api.ts'
131+ import { groupBy } from ' lodash'
132+ import AIModeParamSettingDialog from ' @/views/application/component/AIModeParamSettingDialog.vue'
133+ import SendIcon from ' @/components/logo/SendIcon.vue'
138134
139135const emit = defineEmits ([' replace' ])
140- const {user} = useStore ()
136+ const { user } = useStore ()
141137const route = useRoute ()
142138
143139const chatMessages = ref <Array <any >>([])
@@ -261,7 +257,7 @@ const continueStreaming = () => {
261257 */
262258const getWrite = (reader : any ) => {
263259 let tempResult = ' '
264- const middleAnswer = reactive ({content: ' ' , role: ' ai' })
260+ const middleAnswer = reactive ({ content: ' ' , role: ' ai' })
265261 chatMessages .value .push (middleAnswer )
266262
267263 // 初始化状态并
@@ -276,7 +272,7 @@ const getWrite = (reader: any) => {
276272 * @param done 是否结束
277273 * @param value 值
278274 */
279- const write_stream = ({done , value }: { done: boolean ; value: any }) => {
275+ const write_stream = ({ done , value }: { done: boolean ; value: any }) => {
280276 try {
281277 if (done ) {
282278 // 流数据接收完成,但定时器继续运行直到显示完所有内容
@@ -285,7 +281,7 @@ const getWrite = (reader: any) => {
285281 return
286282 }
287283 const decoder = new TextDecoder (' utf-8' )
288- let str = decoder .decode (value , {stream: true })
284+ let str = decoder .decode (value , { stream: true })
289285 // 这里解释一下 start 因为数据流返回流并不是按照后端chunk返回 我们希望得到的chunk是data:{xxx}\n\n 但是它获取到的可能是 data:{ -> xxx}\n\n 总而言之就是 fetch不能保证每个chunk都说以data:开始 \n\n结束
290286 tempResult += str
291287 const split = tempResult .match (/ data:. * }\n\n / g )
@@ -351,7 +347,7 @@ function generatePrompt(inputValue: any) {
351347 isApiComplete .value = false
352348 loading .value = true
353349 const workspaceId = user .getWorkspaceId () || ' default'
354- chatMessages .value .push ({content: inputValue , role: ' user' })
350+ chatMessages .value .push ({ content: inputValue , role: ' user' })
355351 const requestData = {
356352 messages: chatMessages .value ,
357353 prompt: promptTemplates .INIT_TEMPLATE ,
@@ -361,7 +357,7 @@ function generatePrompt(inputValue: any) {
361357 model_params_setting: model_params_setting .value ,
362358 }
363359
364- loadSharedApi ({type: ' tool' , systemType: apiType .value })
360+ loadSharedApi ({ type: ' tool' , systemType: apiType .value })
365361 .generateCode (requestData )
366362 .then ((response : any ) => {
367363 nextTick (() => {
@@ -423,21 +419,20 @@ const insertNewlineAtCursor = (event?: any) => {
423419 })
424420}
425421
426-
427422function getSelectModel() {
428423 loading .value = true
429424
430425 const obj =
431426 apiType .value === ' systemManage'
432427 ? {
433- model_type: ' LLM' ,
434- // todo workspace_id
435- workspace_id: ' '
436- }
428+ model_type: ' LLM' ,
429+ // todo workspace_id
430+ workspace_id: ' ' ,
431+ }
437432 : {
438- model_type: ' LLM' ,
439- }
440- loadSharedApi ({type: ' model' , systemType: apiType .value })
433+ model_type: ' LLM' ,
434+ }
435+ loadSharedApi ({ type: ' model' , systemType: apiType .value })
441436 .getSelectModelList (obj )
442437 .then ((res : any ) => {
443438 modelOptions .value = groupBy (res ?.data , ' provider' )
@@ -459,11 +454,7 @@ const model_change = (modelId: string) => {
459454
460455const openAIParamSettingDialog = () => {
461456 if (model_id .value ) {
462- AIModeParamSettingDialogRef .value ?.open (
463- model_id .value ,
464- ' ' ,
465- model_params_setting .value ,
466- )
457+ AIModeParamSettingDialogRef .value ?.open (model_id .value , ' ' , model_params_setting .value )
467458 }
468459}
469460
@@ -534,7 +525,7 @@ watch(
534525 () => {
535526 handleScroll ()
536527 },
537- {deep: true , immediate: true },
528+ { deep: true , immediate: true },
538529)
539530
540531onMounted (() => {
0 commit comments