type.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * {
  3. * "modelClassId": 41,
  4. * "modelMcpId": 56,
  5. * "message": [
  6. * {
  7. * "role": "user",
  8. * "timestamp": 1719242380731,
  9. * "id": "88",
  10. * "content": "分析一下最近10条登录日志"
  11. * }
  12. * ],
  13. * "UserId": 10
  14. * }
  15. */
  16. // 消息类型定义
  17. export type Message = {
  18. id: number
  19. role: 'user' | 'assistant' | 'system' | 'meta'
  20. content: string
  21. timestamp: number
  22. }
  23. export type ChatRequest = {
  24. modelClassId?: number
  25. modelMcpId?: number[]
  26. message: Message[]
  27. }
  28. export type ChatResponseType = 'message' | 'toolcall' | 'toolres' | 'error'
  29. export type ChatResponseBase<T = ChatResponseType> = {
  30. type: T
  31. }
  32. export type Text = ChatResponseBase<'message'> & {
  33. message: string
  34. }
  35. export type ToolCallRequest = ChatResponseBase<'toolcall'> & {
  36. request: {
  37. name: string,
  38. data: string
  39. }
  40. }
  41. export type ToolCallResponse = ChatResponseBase<'toolres'> & {
  42. response: {
  43. name: string,
  44. data: string
  45. }
  46. }
  47. export type ErrorResponse = ChatResponseBase<'error'> & {
  48. error: string
  49. }
  50. export type MetaResponse = ChatResponseBase<'meta'> & {
  51. meta: string
  52. }
  53. export type ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse
  54. // 大语言模型配置相关类型定义
  55. // 大语言模型配置列表查询参数
  56. export type LmConfigListParams = {
  57. keyWord?: string // 搜索关键字
  58. dateRange?: string[] // 日期范围
  59. OrderBy?: string // 排序
  60. pageNum?: number // 分页号码,默认1
  61. pageSize?: number // 分页数量,最大500,默认10
  62. modelClass?: string // 模型分类
  63. modelName?: string // 模型名称
  64. modelType?: string // 模型类型
  65. status?: string // 是否启用
  66. createdAt?: string // 创建时间
  67. }
  68. // 大语言模型配置基础信息
  69. export type LmConfigInfo = {
  70. id?: number
  71. modelClass?: string // 模型分类
  72. modelName?: string // 模型名称
  73. apiKey?: string // API密钥
  74. baseUrl?: string // 基础URL
  75. modelType?: string // 模型类型
  76. isCallFun?: boolean // 是否调用函数
  77. maxToken?: number // 最大令牌数
  78. status: boolean // 是否启用
  79. createdAt?: string // 创建时间
  80. updatedAt?: string // 更新时间
  81. createdBy?: number // 创建者ID
  82. updatedBy?: number // 更新者ID
  83. createdUser?: any // 创建用户信息
  84. actionBtn?: any // 操作按钮
  85. [key: string]: any // 允许其他字段
  86. }
  87. // 大语言模型配置添加请求
  88. export type LmConfigAddReq = Omit<LmConfigInfo, 'id' | 'createdAt' | 'updatedAt'>
  89. // 大语言模型配置编辑请求
  90. export type LmConfigEditReq = LmConfigInfo & {
  91. id: number // 编辑时ID必须
  92. }
  93. // 大语言模型配置状态设置请求
  94. export type LmConfigStatusReq = {
  95. id: number
  96. status: string
  97. }
  98. // 删除请求参数
  99. export type LmConfigDeleteParams = {
  100. ids: number[]
  101. }
  102. // 获取单个配置参数
  103. export type LmConfigGetParams = {
  104. id: number
  105. }