type.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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'
  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 ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse | DataResponse
  76. // 大语言模型配置相关类型定义
  77. // 大语言模型配置列表查询参数
  78. export type LmConfigListParams = {
  79. keyWord?: string // 搜索关键字
  80. dateRange?: string[] // 日期范围
  81. OrderBy?: string // 排序
  82. pageNum?: number // 分页号码,默认1
  83. pageSize?: number // 分页数量,最大500,默认10
  84. modelClass?: string // 模型分类
  85. modelName?: string // 模型名称
  86. modelType?: string // 模型类型
  87. status?: string // 是否启用
  88. createdAt?: string // 创建时间
  89. }
  90. // 大语言模型配置基础信息
  91. export type LmConfigInfo = {
  92. id?: number
  93. modelClass?: string // 模型分类
  94. modelName?: string // 模型名称
  95. apiKey?: string // API密钥
  96. baseUrl?: string // 基础URL
  97. modelType?: string // 模型类型
  98. isCallFun?: boolean // 是否调用函数
  99. maxToken?: number // 最大令牌数
  100. status: boolean // 是否启用
  101. createdAt?: string // 创建时间
  102. updatedAt?: string // 更新时间
  103. createdBy?: number // 创建者ID
  104. updatedBy?: number // 更新者ID
  105. createdUser?: any // 创建用户信息
  106. actionBtn?: any // 操作按钮
  107. [key: string]: any // 允许其他字段
  108. }
  109. // 大语言模型配置添加请求
  110. export type LmConfigAddReq = Omit<LmConfigInfo, 'id' | 'createdAt' | 'updatedAt'>
  111. // 大语言模型配置编辑请求
  112. export type LmConfigEditReq = LmConfigInfo & {
  113. id: number // 编辑时ID必须
  114. }
  115. // 大语言模型配置状态设置请求
  116. export type LmConfigStatusReq = {
  117. id: number
  118. status: string
  119. }
  120. // 删除请求参数
  121. export type LmConfigDeleteParams = {
  122. ids: number[]
  123. }
  124. // 获取单个配置参数
  125. export type LmConfigGetParams = {
  126. id: number
  127. }
  128. export type LmSession = {
  129. session_id: number
  130. title: string
  131. }
  132. // 会话消息列表查询参数
  133. export type SessionMessagesListParams = {
  134. sessionId: number
  135. }
  136. // 保存会话消息请求
  137. export type SessionMessagesSaveReq = {
  138. sessionId: number
  139. messages: Message[]
  140. }
  141. export type LmDashboard = {
  142. id: number
  143. title: string
  144. data: string
  145. createdAt?: string // 创建时间
  146. updatedAt?: string // 更新时间
  147. createdBy?: number // 创建者ID
  148. updatedBy?: number // 更新者ID
  149. }