type.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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' | 'tool'
  20. //仅markdown渲染器需要
  21. render_content: string
  22. //实际传给AI的内容
  23. content: string
  24. timestamp: number
  25. //仅role为tool时需要
  26. name?: string,
  27. tool_call_id?: string
  28. //仅role为assistant时需要
  29. like?: boolean
  30. tool_calls?: FunctionCall[]
  31. }
  32. export type FunctionCall = {
  33. id: string,
  34. type: 'function',
  35. function: {
  36. name: string,
  37. arguments: string
  38. }
  39. }
  40. export type ChatRequest = {
  41. modelClassId?: number
  42. modelMcpId?: number[]
  43. message: Message[]
  44. }
  45. export type ChatResponseType = 'message' | 'toolcall' | 'toolres' | 'error' | 'datamsg' | 'structdata'
  46. export type ChatResponseBase<T = ChatResponseType> = {
  47. type: T
  48. }
  49. export type Text = ChatResponseBase<'message'> & {
  50. message: string
  51. }
  52. export type ToolCallRequest = ChatResponseBase<'toolcall'> & {
  53. request: {
  54. id: string
  55. name: string,
  56. data: string
  57. }
  58. }
  59. export type ToolCallResponse = ChatResponseBase<'toolres'> & {
  60. response: {
  61. id: string
  62. name: string,
  63. data: string
  64. }
  65. }
  66. export type ErrorResponse = ChatResponseBase<'error'> & {
  67. error: string
  68. }
  69. export type MetaResponse = ChatResponseBase<'meta'> & {
  70. meta: string
  71. }
  72. export type DataResponse = ChatResponseBase<'datamsg'> & {
  73. data: string
  74. }
  75. export type StructDataResponse = ChatResponseBase<'structdata'> & {
  76. uuid: string
  77. }
  78. export type ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse | DataResponse | StructDataResponse
  79. // 大语言模型配置相关类型定义
  80. // 大语言模型配置列表查询参数
  81. export type LmConfigListParams = {
  82. keyWord?: string // 搜索关键字
  83. dateRange?: string[] // 日期范围
  84. OrderBy?: string // 排序
  85. pageNum?: number // 分页号码,默认1
  86. pageSize?: number // 分页数量,最大500,默认10
  87. modelClass?: string // 模型分类
  88. modelName?: string // 模型名称
  89. modelType?: string // 模型类型
  90. status?: string // 是否启用
  91. createdAt?: string // 创建时间
  92. }
  93. // 大语言模型配置基础信息
  94. export type LmConfigInfo = {
  95. id?: number
  96. modelClass?: string // 模型分类
  97. modelName?: string // 模型名称
  98. apiKey?: string // API密钥
  99. baseUrl?: string // 基础URL
  100. modelType?: string // 模型类型
  101. isCallFun?: boolean // 是否调用函数
  102. maxToken?: number // 最大令牌数
  103. status: boolean // 是否启用
  104. createdAt?: string // 创建时间
  105. updatedAt?: string // 更新时间
  106. createdBy?: number // 创建者ID
  107. updatedBy?: number // 更新者ID
  108. createdUser?: any // 创建用户信息
  109. actionBtn?: any // 操作按钮
  110. [key: string]: any // 允许其他字段
  111. }
  112. // 大语言模型配置添加请求
  113. export type LmConfigAddReq = Omit<LmConfigInfo, 'id' | 'createdAt' | 'updatedAt'>
  114. // 大语言模型配置编辑请求
  115. export type LmConfigEditReq = LmConfigInfo & {
  116. id: number // 编辑时ID必须
  117. }
  118. // 大语言模型配置状态设置请求
  119. export type LmConfigStatusReq = {
  120. id: number
  121. status: string
  122. }
  123. // 删除请求参数
  124. export type LmConfigDeleteParams = {
  125. ids: number[]
  126. }
  127. // 获取单个配置参数
  128. export type LmConfigGetParams = {
  129. id: number
  130. }
  131. export type LmSession = {
  132. session_id: number
  133. title: string
  134. }
  135. // 会话消息列表查询参数
  136. export type SessionMessagesListParams = {
  137. sessionId: number
  138. }
  139. // 保存会话消息请求
  140. export type SessionMessagesSaveReq = {
  141. sessionId: number
  142. messages: Message[]
  143. }
  144. export type LmDashboard = {
  145. id: number
  146. title: string
  147. data: string
  148. remark?: string // 备注
  149. createdAt?: string // 创建时间
  150. updatedAt?: string // 更新时间
  151. createdBy?: number // 创建者ID
  152. updatedBy?: number // 更新者ID
  153. }