2020 </div >
2121 <div class =" ml-12 lighter" >
2222 <p >提示词中的 {data} 为分段内容的占位符,执行时替换为分段内容发送给 AI 模型;</p >
23- <p >AI 模型根据分段内容生成相关问题,请将生成的问题放至< ; question> ;< ; /question> ; 标签中,系统会自动关联标签中的问题;</p >
23+ <p >
24+ AI
25+ 模型根据分段内容生成相关问题,请将生成的问题放至< ; question> ;< ; /question> ; 标签中,系统会自动关联标签中的问题;
26+ </p >
2427 <p >生成效果依赖于所选模型和提示词,用户可自行调整至最佳效果。</p >
2528 </div >
2629 </div >
4548 class =" flex-between"
4649 >
4750 <div class =" flex align-center" >
48- <span
49- v-html =" relatedObject(providerOptions, label, 'provider')?.icon"
50- class =" model-icon mr-8"
51- ></span >
51+ <span
52+ v-html =" relatedObject(providerOptions, label, 'provider')?.icon"
53+ class =" model-icon mr-8"
54+ ></span >
5255 <span >{{ item.name }}</span >
53- <el-tag
54- v-if =" item.permission_type === 'PUBLIC'"
55- type =" info"
56- class =" info-tag ml-8"
57- >公用
56+ <el-tag v-if =" item.permission_type === 'PUBLIC'" type =" info" class =" info-tag ml-8"
57+ >公用
5858 </el-tag >
5959 </div >
6060 <el-icon class =" check-icon" v-if =" item.id === form.model_id" >
7171 disabled
7272 >
7373 <div class =" flex" >
74- <span
75- v-html =" relatedObject(providerOptions, label, 'provider')?.icon"
76- class =" model-icon mr-8"
77- ></span >
74+ <span
75+ v-html =" relatedObject(providerOptions, label, 'provider')?.icon"
76+ class =" model-icon mr-8"
77+ ></span >
7878 <span >{{ item.name }}</span >
7979 <span class =" danger" >{{
80- $t('views.application.applicationForm.form.aiModel.unavailable')
81- }}</span >
80+ $t('views.application.applicationForm.form.aiModel.unavailable')
81+ }}</span >
8282 </div >
8383 <el-icon class =" check-icon" v-if =" item.id === form.model_id" >
8484 <Check />
8888 </el-select >
8989 </el-form-item >
9090 <el-form-item label =" 提示词" prop =" prompt" >
91- <el-input
92- v-model =" form.prompt"
93- placeholder =" 请输入提示词"
94- :rows =" 7"
95- type =" textarea"
96- />
91+ <el-input v-model =" form.prompt" placeholder =" 请输入提示词" :rows =" 7" type =" textarea" />
9792 </el-form-item >
9893 </el-form >
99-
100-
10194 </div >
10295 <template #footer >
10396 <span class =" dialog-footer" >
113106import { reactive , ref , watch } from ' vue'
114107import { useRoute } from ' vue-router'
115108import documentApi from ' @/api/document'
116-
109+ import paragraphApi from ' @/api/paragraph'
110+ import datasetApi from ' @/api/dataset'
117111import useStore from ' @/stores'
118112import { relatedObject } from ' @/utils/utils'
119113import type { Provider } from ' @/api/type/model'
120- import datasetApi from ' @/api/dataset'
121114import { groupBy } from ' lodash'
122115import { MsgSuccess } from ' @/utils/message'
123116import { t } from ' @/locales'
124117import type { FormInstance } from ' element-plus'
125118
126119const route = useRoute ()
127120const {
128- params : { id } // id为datasetID
121+ params : { id, documentId } // id为datasetID
129122} = route as any
130123
131124const { model, prompt, user } = useStore ()
132125
133-
134126const emit = defineEmits ([' refresh' ])
135127
136128const loading = ref <boolean >(false )
137129
138130const dialogVisible = ref <boolean >(false )
139131const modelOptions = ref <any >(null )
140132const providerOptions = ref <Array <Provider >>([])
141- const documentIdList = ref <string []>([])
133+ const idList = ref <string []>([])
134+ const apiType = ref (' ' ) // 文档document或段落paragraph
142135
143136const FormRef = ref ()
144137const userId = user .userInfo ?.id as string
145138const form = ref (prompt .get (userId ))
146139
147-
148140const rules = reactive ({
149141 model_id: [{ required: true , message: ' 请选择AI 模型' , trigger: ' blur' }],
150142 prompt: [{ required: true , message: ' 请输入提示词' , trigger: ' blur' }]
151143})
152144
153-
154- const open = (document_ids : string []) => {
145+ const open = (ids : string [], type : string ) => {
155146 getProvider ()
156147 getModel ()
157- documentIdList .value = document_ids
148+ idList .value = ids
149+ apiType .value = type
158150 dialogVisible .value = true
159151}
160152
@@ -166,17 +158,25 @@ const submitHandle = async (formEl: FormInstance) => {
166158 if (valid ) {
167159 // 保存提示词
168160 prompt .save (user .userInfo ?.id as string , form .value )
169- const data = { ... form .value , document_id_list: documentIdList .value }
170- documentApi .batchGenerateRelated (id , data ).then (() => {
171- MsgSuccess (' 生成问题成功' )
172- emit (' refresh' )
173- dialogVisible .value = false
174- })
161+ if (apiType .value === ' paragraph' ) {
162+ const data = { ... form .value , paragraph_id_list: idList .value }
163+ paragraphApi .batchGenerateRelated (id , documentId , data ).then (() => {
164+ MsgSuccess (' 生成问题成功' )
165+ emit (' refresh' )
166+ dialogVisible .value = false
167+ })
168+ } else if (apiType .value === ' document' ) {
169+ const data = { ... form .value , document_id_list: idList .value }
170+ documentApi .batchGenerateRelated (id , data ).then (() => {
171+ MsgSuccess (' 生成问题成功' )
172+ emit (' refresh' )
173+ dialogVisible .value = false
174+ })
175+ }
175176 }
176177 })
177178}
178179
179-
180180function getModel() {
181181 loading .value = true
182182 datasetApi
@@ -203,26 +203,9 @@ function getProvider() {
203203 })
204204}
205205
206-
207206defineExpose ({ open })
208207 </script >
209208<style lang="scss" scope>
210- .select-dataset-dialog {
211- padding : 10px ;
212-
213- .el-dialog__header {
214- padding : 24px 24px 0 8px ;
215- }
216-
217- .el-dialog__body {
218- padding : 8px !important ;
219- }
220-
221- .el-dialog__footer {
222- padding : 0 24px 24px ;
223- }
224- }
225-
226209.update-info {
227210 background : #d6e2ff ;
228211 line-height : 25px ;
0 commit comments