123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- /**
- * {
- * "modelClassId": 41,
- * "modelMcpId": 56,
- * "message": [
- * {
- * "role": "user",
- * "timestamp": 1719242380731,
- * "id": "88",
- * "content": "分析一下最近10条登录日志"
- * }
- * ],
- * "UserId": 10
- * }
- */
- // 消息类型定义
- export type Message = {
- id: number
- role: 'user' | 'assistant' | 'system' | 'meta' | 'tool'
- //仅markdown渲染器需要
- render_content: string
- //实际传给AI的内容
- content: string
- timestamp: number
- //仅role为tool时需要
- name?: string,
- tool_call_id?: string
- //仅role为assistant时需要
- like?: boolean
- tool_calls?: FunctionCall[]
- }
- export type FunctionCall = {
- id: string,
- type: 'function',
- function: {
- name: string,
- arguments: string
- }
- }
- export type ChatRequest = {
- modelClassId?: number
- modelMcpId?: number[]
- message: Message[]
- }
- export type ChatResponseType = 'message' | 'toolcall' | 'toolres' | 'error' | 'datamsg'
- export type ChatResponseBase<T = ChatResponseType> = {
- type: T
- }
- export type Text = ChatResponseBase<'message'> & {
- message: string
- }
- export type ToolCallRequest = ChatResponseBase<'toolcall'> & {
- request: {
- id: string
- name: string,
- data: string
- }
- }
- export type ToolCallResponse = ChatResponseBase<'toolres'> & {
- response: {
- id: string
- name: string,
- data: string
- }
- }
- export type ErrorResponse = ChatResponseBase<'error'> & {
- error: string
- }
- export type MetaResponse = ChatResponseBase<'meta'> & {
- meta: string
- }
- export type DataResponse = ChatResponseBase<'datamsg'> & {
- data: string
- }
- export type ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse | DataResponse
- // 大语言模型配置相关类型定义
- // 大语言模型配置列表查询参数
- export type LmConfigListParams = {
- keyWord?: string // 搜索关键字
- dateRange?: string[] // 日期范围
- OrderBy?: string // 排序
- pageNum?: number // 分页号码,默认1
- pageSize?: number // 分页数量,最大500,默认10
- modelClass?: string // 模型分类
- modelName?: string // 模型名称
- modelType?: string // 模型类型
- status?: string // 是否启用
- createdAt?: string // 创建时间
- }
- // 大语言模型配置基础信息
- export type LmConfigInfo = {
- id?: number
- modelClass?: string // 模型分类
- modelName?: string // 模型名称
- apiKey?: string // API密钥
- baseUrl?: string // 基础URL
- modelType?: string // 模型类型
- isCallFun?: boolean // 是否调用函数
- maxToken?: number // 最大令牌数
- status: boolean // 是否启用
- createdAt?: string // 创建时间
- updatedAt?: string // 更新时间
- createdBy?: number // 创建者ID
- updatedBy?: number // 更新者ID
- createdUser?: any // 创建用户信息
- actionBtn?: any // 操作按钮
- [key: string]: any // 允许其他字段
- }
- // 大语言模型配置添加请求
- export type LmConfigAddReq = Omit<LmConfigInfo, 'id' | 'createdAt' | 'updatedAt'>
- // 大语言模型配置编辑请求
- export type LmConfigEditReq = LmConfigInfo & {
- id: number // 编辑时ID必须
- }
- // 大语言模型配置状态设置请求
- export type LmConfigStatusReq = {
- id: number
- status: string
- }
- // 删除请求参数
- export type LmConfigDeleteParams = {
- ids: number[]
- }
- // 获取单个配置参数
- export type LmConfigGetParams = {
- id: number
- }
- export type LmSession = {
- session_id: number
- title: string
- }
- // 会话消息列表查询参数
- export type SessionMessagesListParams = {
- sessionId: number
- }
- // 保存会话消息请求
- export type SessionMessagesSaveReq = {
- sessionId: number
- messages: Message[]
- }
- export type LmDashboard = {
- id: number
- title: string
- data: string
- createdAt?: string // 创建时间
- updatedAt?: string // 更新时间
- createdBy?: number // 创建者ID
- updatedBy?: number // 更新者ID
- }
|