Pārlūkot izejas kodu

feat: 大模型表单复显

sheldon 1 mēnesi atpakaļ
vecāks
revīzija
4ec02ff2e9

+ 26 - 5
src/api/modules/model.ts

@@ -15,11 +15,32 @@ export async function fetchModel(){
   //@ts-ignore
   return res.data
 }
-
+export type TAgentLLMDetail = {
+  id: string;
+  name: string;
+  system: string;
+  userId: string;
+  qsetsWithAttach: any[];
+  retrivalsWithAttach: any[];
+  modelId: string;
+  modelPersona: {
+    options: Record<string, any>;
+  };
+  voiceId: string;
+  voiceTtsPersona: {
+    speechRate: number;
+    volume: number;
+    sampleRate: number;
+    format: string;
+  };
+  ctime: number;
+};
 export async function fetchModelDetail(params: {id: string}){
-  return request<{
-    total: number,
-    content: TModel[]
-  }>(`/anycall/selectAgentDetail`, {cloneId: params.id})
+  // res = await request<TAgentLLMDetail>(`/anycall/selectAgentLLMDetail`, {cloneId: params.id})
+  const res = await request<{
+    code: number;
+    data: TAgentLLMDetail
+  }>(`/anycall/selectAgentLLMDetail`, {cloneId: params.id})
+  return res.data
 }
 

+ 11 - 4
src/components/VoiceSelector.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 import { voiceList } from '@/api/modules/anycallService'
-import type { TVoice } from '@/types/voice'
+// import type { TVoice } from '@/types/voice'
 
 // 定义组件属性
 interface Props {
@@ -9,6 +9,7 @@ interface Props {
   placeholder?: string
   style?: string | object
   className?: string
+  gender: number
 }
 
 // 定义组件事件
@@ -20,7 +21,8 @@ interface Emits {
 const props = withDefaults(defineProps<Props>(), {
   disabled: false,
   placeholder: '请选择音色',
-  style: 'width: 140px;'
+  style: 'width: 140px;',
+  gender: 1
 })
 
 // 定义事件触发器
@@ -37,6 +39,12 @@ watch(
   },
   { immediate: true }
 )
+watch(
+  () => props.gender,
+  (newValue) => {
+    fetchData()
+  }
+)
 
 // 音色选项数据
 const options = ref<Array<{value: string, name: string}>>([])
@@ -48,7 +56,7 @@ const fetchData = async () => {
       page: 1,
       size: 100, // 获取足够多的选项
       system: true,
-      gender: 1
+      gender: props.gender
     }
     const res = await voiceList(params)
     if (res.code === 0) {
@@ -65,7 +73,6 @@ const fetchData = async () => {
   }
 }
 
-// 组件挂载时获取数据
 onMounted(() => {
   fetchData()
 })

+ 1 - 2
src/views/role-management/components/EditForm.vue

@@ -3,7 +3,6 @@ import { ElDialog, ElForm, ElFormItem, ElInput, ElDatePicker, ElButton, ElMessag
 import type { FormInstance, FormRules } from 'element-plus'
 import FaImageUpload from '@/ui/components/FaImageUpload/index.vue'
 import VoiceSelector from '@/components/VoiceSelector.vue'
-import LLMSelector from '@/components/LLMSelector.vue'
 import { saveRole } from '@/api/modules/anycallService'
 import type { TRole } from '@/api/modules/anycallService'
 // 定义表单数据类型
@@ -213,7 +212,7 @@ const handleRemoveAgent = ()=> {
         </ElFormItem> -->
 
         <ElFormItem label="use voice" prop="voiceName" label-width="120">
-           <VoiceSelector v-model="formData.voiceId" />
+           <VoiceSelector :gender="formData.gender ?? 1" v-model="formData.voice" />
         </ElFormItem>
 
         <ElFormItem label="Avatar" prop="avatar" label-width="120">

+ 12 - 0
src/views/role-management/components/EditLLMForm.vue

@@ -3,6 +3,7 @@ import { ElDialog, ElForm, ElFormItem, ElInput, ElDatePicker, ElButton, ElMessag
 import type { FormInstance, FormRules } from 'element-plus'
 import LLMSelector from '@/components/LLMSelector.vue'
 import { updateAgentLLm } from '@/api/modules/anycallService'
+import { fetchModelDetail } from '@/api/modules/model'
 // 定义表单数据类型
 type IFormData  = {
   llmId: string
@@ -54,6 +55,13 @@ const formData = ref<Partial<IFormData>>({
   llmId: '',
 });
 
+const fetchData = async  () => {
+  const {code, data} = await fetchModelDetail({id: props.cloneId})
+  if(code === 0 && data){
+    console.log(data)
+    formData.value.llmId = data.modelId
+  }
+}
 
 
 // 监听 props.modelValue 变化
@@ -76,6 +84,9 @@ const formRules = ref<FormRules>({
 // 监听可见性变化
 watch(() => props.visible, (newVisible) => {
   resetForm()
+  if(newVisible){
+    fetchData()
+  }
 })
 
 
@@ -123,6 +134,7 @@ function handleClose() {
   emit('update:visible', false)
 }
 
+
 </script>
 <template>
   <div>