Ver Fonte

feat:【ai 大模型】支持 Chat Role 的 mcp 配置

YunaiV há 6 meses atrás
pai
commit
da9c6799c8

+ 6 - 5
src/api/ai/model/chatRole/index.ts

@@ -15,6 +15,7 @@ export interface ChatRoleVO {
   status: number // 状态
   knowledgeIds?: number[] // 引用的知识库 ID 列表
   toolIds?: number[] // 引用的工具 ID 列表
+  mcpClientNames?: string[] // 引用的 MCP Client 名字列表
 }
 
 // AI 聊天角色 分页请求 vo
@@ -57,26 +58,26 @@ export const ChatRoleApi = {
 
   // 获取 my role
   getMyPage: async (params: ChatRolePageReqVO) => {
-    return await request.get({ url: `/ai/chat-role/my-page`, params})
+    return await request.get({ url: `/ai/chat-role/my-page`, params })
   },
 
   // 获取角色分类
   getCategoryList: async () => {
-    return await request.get({ url: `/ai/chat-role/category-list`})
+    return await request.get({ url: `/ai/chat-role/category-list` })
   },
 
   // 创建角色
   createMy: async (data: ChatRoleVO) => {
-    return await request.post({ url: `/ai/chat-role/create-my`, data})
+    return await request.post({ url: `/ai/chat-role/create-my`, data })
   },
 
   // 更新角色
   updateMy: async (data: ChatRoleVO) => {
-    return await request.put({ url: `/ai/chat-role/update-my`, data})
+    return await request.put({ url: `/ai/chat-role/update-my`, data })
   },
 
   // 删除角色 my
   deleteMy: async (id: number) => {
     return await request.delete({ url: `/ai/chat-role/delete-my?id=` + id })
-  },
+  }
 }

+ 1 - 0
src/utils/dict.ts

@@ -227,6 +227,7 @@ export enum DICT_TYPE {
   AI_WRITE_FORMAT = 'ai_write_format', // AI 写作格式
   AI_WRITE_TONE = 'ai_write_tone', // AI 写作语气
   AI_WRITE_LANGUAGE = 'ai_write_language', // AI 写作语言
+  AI_MCP_CLIENT_NAME = 'ai_mcp_client_name', // AI MCP Client 名字
 
   // ========== IOT - 物联网模块  ==========
   IOT_NET_TYPE = 'iot_net_type', // IOT 联网方式

+ 15 - 3
src/views/ai/model/chatRole/ChatRoleForm.vue

@@ -47,6 +47,16 @@
           <el-option v-for="item in toolList" :key="item.id" :label="item.name" :value="item.id" />
         </el-select>
       </el-form-item>
+      <el-form-item label="引用 MCP" prop="toolIds">
+        <el-select v-model="formData.mcpClientNames" placeholder="请选择 MCP" clearable multiple>
+          <el-option
+            v-for="dict in getStrDictOptions(DICT_TYPE.AI_MCP_CLIENT_NAME)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item label="是否公开" prop="publicStatus" v-if="!isUser">
         <el-radio-group v-model="formData.publicStatus">
           <el-radio
@@ -80,7 +90,7 @@
   </Dialog>
 </template>
 <script setup lang="ts">
-import { getIntDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
+import { getIntDictOptions, getBoolDictOptions, DICT_TYPE, getStrDictOptions } from '@/utils/dict'
 import { ChatRoleApi, ChatRoleVO } from '@/api/ai/model/chatRole'
 import { CommonStatusEnum } from '@/utils/constants'
 import { ModelApi, ModelVO } from '@/api/ai/model/model'
@@ -111,7 +121,8 @@ const formData = ref({
   publicStatus: true,
   status: CommonStatusEnum.ENABLE,
   knowledgeIds: [] as number[],
-  toolIds: [] as number[]
+  toolIds: [] as number[],
+  mcpClientNames: [] as string[]
 })
 const formRef = ref() // 表单 Ref
 const models = ref([] as ModelVO[]) // 聊天模型列表
@@ -204,7 +215,8 @@ const resetForm = () => {
     publicStatus: true,
     status: CommonStatusEnum.ENABLE,
     knowledgeIds: [],
-    toolIds: []
+    toolIds: [],
+    mcpClientNames: []
   }
   formRef.value?.resetFields()
 }