Pārlūkot izejas kodu

fix: 对接绑定大模型接口

sheldon 1 mēnesi atpakaļ
vecāks
revīzija
9d221b90dc

+ 4 - 3
src/api/modules/anycallService.ts

@@ -14,7 +14,8 @@ export function anycallPage(params: {
     content: TAgent[]
   }>(`/anycall/selectLib`, params)
 }
-export function updateCallings(params: any){
+//
+export function updateCallings(params: {cloneId: string, callings: string}){
   return request(`/anycall/updateCallings`, params)
 }
 // 推荐
@@ -70,8 +71,8 @@ export function importZip(params: any){
 
 
 export function updateAgentLLm(params: {
-  agentId: string,
+  cloneId: string,
   llmId: string
 }){
-  return request(`/anycall/updateAgentLLm`, {}, {params: {agentId: params.agentId, llmId: params.llmId}})
+  return request(`/anycall/updateAgentLLm`, {cloneId: params.cloneId, llmId: params.llmId})
 }

+ 2 - 2
src/api/modules/model.ts

@@ -16,10 +16,10 @@ export async function fetchModel(){
   return res.data
 }
 
-export async function fetchModelDetail(){
+export async function fetchModelDetail(params: {id: string}){
   return request<{
     total: number,
     content: TModel[]
-  }>(`/anycall/selectAgentDetail`)
+  }>(`/anycall/selectAgentDetail`, {cloneId: params.id})
 }
 

+ 148 - 0
src/views/role-management/components/EditCallingsForm.vue

@@ -0,0 +1,148 @@
+<script setup lang="ts">
+import { ElDialog, ElForm, ElFormItem, ElInput, ElDatePicker, ElButton, ElMessage, ElRadio } from 'element-plus'
+import type { FormInstance, FormRules } from 'element-plus'
+import { updateCallings } from '@/api/modules/anycallService'
+// 定义表单数据类型
+type IFormData  = {
+  callings: string
+}
+
+// 定义组件的属性
+interface Props {
+  cloneId: string
+  visible: boolean
+  modelValue?: IFormData | null
+  mode?: 'create' | 'edit'
+}
+
+// 定义组件的事件
+interface Emits {
+  (e: 'update:visible', value: boolean): void
+  (e: 'cancel'): void
+  (e: 'refresh'): void
+}
+
+// 接收属性和事件
+const props = withDefaults(defineProps<Props>(), {
+  visible: false,
+  modelValue: null,
+  mode: 'create'
+})
+
+const emit = defineEmits<Emits>()
+
+// 创建本地响应式变量用于 v-model 绑定
+const dialogVisible = ref(props.visible)
+
+// 监听 props.visible 变化,更新本地变量
+watch(() => props.visible, (newVisible) => {
+  dialogVisible.value = newVisible
+})
+
+// 监听本地变量变化,发出 update 事件
+watch(dialogVisible, (newVisible) => {
+  emit('update:visible', newVisible)
+})
+
+// 表单引用
+const editFormRef = ref<FormInstance>();
+
+// 响应式数据 - 直接定义所有必需字段
+const formData = ref<Partial<IFormData>>({
+  callings: '',
+});
+
+
+
+// 监听 props.modelValue 变化
+watch(() => props.modelValue, (newModelValue) => {
+  if (newModelValue) {
+    formData.value = {
+      ...formData.value,
+      ...newModelValue
+    };
+    console.log(newModelValue, formData.value,33344)
+  }
+});
+
+// 表单验证规则
+const formRules = ref<FormRules>({
+  callings: [
+    { required: true, message: '输入数量', trigger: 'blur' },
+  ],
+})
+
+// 监听可见性变化
+watch(() => props.visible, (newVisible) => {
+  resetForm()
+})
+
+
+// 重置表单
+function resetForm() {
+  console.log('reset')
+  if (editFormRef.value) {
+    editFormRef.value.resetFields()
+  }
+  formData.value = {
+    callings: '',
+  }
+}
+
+// 处理确认
+async function handleConfirm() {
+  if (!editFormRef.value) return
+
+  try {
+    await editFormRef.value.validate()
+
+    const { code } = await updateCallings({
+      cloneId: props.cloneId,
+      callings: formData.value.callings || ''
+    })
+    if (code === 0) {
+      ElMessage.success('操作成功')
+      emit('refresh')
+    }
+    // 关闭对话框
+    emit('update:visible', false)
+  } catch (error) {
+    // 验证失败,不做处理
+  }
+}
+
+
+function handleCancel() {
+  emit('cancel')
+  emit('update:visible', false)
+}
+
+
+function handleClose() {
+  emit('update:visible', false)
+}
+
+</script>
+<template>
+  <div>
+
+    <ElDialog title="编辑Callings" v-model="dialogVisible" align-center @close="handleClose"
+      width="400" :z-index="2000">
+      <ElForm ref="editFormRef" :model="formData" :rules="formRules" label-width="120px" class="mt-4 space-y-4 w-full">
+
+
+        {{ formData }}
+        <ElFormItem label="callings" prop="callings" label-width="120">
+           <ElInput type="number" v-model.number="formData.callings" />
+        </ElFormItem>
+
+      </ElForm>
+      <template #footer>
+        <div class="flex justify-end space-x-2">
+          <ElButton @click="handleCancel">取消</ElButton>
+          <ElButton type="primary" @click="handleConfirm">确定</ElButton>
+        </div>
+      </template>
+    </ElDialog>
+  </div>
+</template>

+ 2 - 4
src/views/role-management/components/EditLLMForm.vue

@@ -1,10 +1,8 @@
 <script setup lang="ts">
 import { ElDialog, ElForm, ElFormItem, ElInput, ElDatePicker, ElButton, ElMessage, ElRadio } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
-import FaImageUpload from '@/ui/components/FaImageUpload/index.vue'
 import LLMSelector from '@/components/LLMSelector.vue'
 import { updateAgentLLm } from '@/api/modules/anycallService'
-import type { TRole } from '@/api/modules/anycallService'
 // 定义表单数据类型
 type IFormData  = {
   llmId: string
@@ -12,7 +10,7 @@ type IFormData  = {
 
 // 定义组件的属性
 interface Props {
-  agentId: string
+  cloneId: string
   visible: boolean
   modelValue?: IFormData | null
   mode?: 'create' | 'edit'
@@ -100,7 +98,7 @@ async function handleConfirm() {
     await editFormRef.value.validate()
 
     const { code } = await updateAgentLLm({
-      agentId: props.agentId,
+      cloneId: props.cloneId,
       llmId: formData.value.llmId || ''
     })
     if (code === 0) {

+ 16 - 4
src/views/role-management/index.vue

@@ -10,6 +10,7 @@ import type { UploadFile, UploadFiles } from 'element-plus'
 import FileUploader from '@/components/Uploader/FileUploader.vue'
 import EditForm from './components/EditForm.vue'
 import EditLLMForm from './components/EditLLMForm.vue'
+import EditCallingsForm from './components/EditCallingsForm.vue'
 import SearchForm from './components/SearchForm.vue'
 
 import type { TAgent } from '@/types/role'
@@ -25,8 +26,9 @@ const editFormVisible = ref(false)
 const editMode = ref<'create' | 'edit'>('create')
 const currentData = ref<any>(null)
 
+const currentCloneId = ref<string>()
 const editLLMFormVisible = ref(false)
-const currentAgentId = ref<string>()
+const editCallingsFormVisible = ref(false)
 
 const importedResultDialogVisible = ref(false)
 const importedFile = ref<UploadFile | null>(null)
@@ -110,10 +112,18 @@ const handleEdit = (data: TAgent) => {
 }
 const handleEditLLM = (data: TAgent) => {
   console.log(data)
-  currentAgentId.value = data.agentId
+  currentData.value = data
+  currentCloneId.value = data.id
   editLLMFormVisible.value = true
 }
 
+const handleEditCallings = (data: TAgent) => {
+  console.log(data)
+  currentData.value = data
+  currentCloneId.value = data.id
+  editCallingsFormVisible.value = true
+}
+
 const handleSearch = () => {
   pagination.value.page = 1
   fetchData()
@@ -174,10 +184,11 @@ onMounted(async () => {
         </ElTableColumn>
         <ElTableColumn label="Language" prop="language" min-width="180" />
         <ElTableColumn label="voiceName" prop="voiceName" min-width="240" />
-        <ElTableColumn fixed="right" label="操作" min-width="200">
+        <ElTableColumn fixed="right" label="操作" min-width="240">
           <template #default="{row}">
             <ElButton link type="primary" size="small" @click="handleEdit(row)">编辑</ElButton>
             <ElButton link type="primary" size="small" @click="handleEditLLM(row)">绑定大模型</ElButton>
+            <ElButton link type="primary" size="small" @click="handleEditCallings(row)">修改 callings</ElButton>
             <!-- <ElPopconfirm title="确定推荐吗?" @confirm="handleRecommend(row.id, row.topFlag)">
               <template #reference>
                 <ElButton link type="primary" size="small">
@@ -203,7 +214,8 @@ onMounted(async () => {
     <EditForm v-model:visible="editFormVisible" :model-value="currentData" :mode="editMode" @refresh="handleRefresh"
       @cancel="handleFormCancel" />
 
-    <EditLLMForm v-model:visible="editLLMFormVisible" :agentId="currentAgentId" @refresh="handleRefresh"></EditLLMForm>
+    <EditLLMForm v-model:visible="editLLMFormVisible" :cloneId="currentCloneId ?? ''" @refresh="handleRefresh"></EditLLMForm>
+    <EditCallingsForm v-model:visible="editCallingsFormVisible" :model-value="currentData" :cloneId="currentCloneId ?? ''" @refresh="handleRefresh"></EditCallingsForm>
 
     <ElDialog title="导入结果" v-model="importedResultDialogVisible" align-center
       width="800" :z-index="2000" :close-on-click-modal="false">