type.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. //仅role为user时需要
  32. files?: Array<UploadFile> | undefined
  33. }
  34. export type UploadFile = {
  35. size: number
  36. path: string
  37. name: string
  38. type: string
  39. full_path: string
  40. }
  41. export type FunctionCall = {
  42. id: string
  43. type: 'function'
  44. function: {
  45. name: string
  46. arguments: string
  47. }
  48. }
  49. export type ChatRequest = {
  50. session_id: number
  51. modelClassId?: number
  52. modelEmbeddingId?: number
  53. modelMcpId?: number[]
  54. message: Message[]
  55. }
  56. export type ChatResponseType = 'message' | 'toolcall' | 'toolres' | 'error' | 'datamsg' | 'structdata'
  57. export type ChatResponseBase<T = ChatResponseType> = {
  58. type: T
  59. }
  60. export type Text = ChatResponseBase<'message'> & {
  61. message: string
  62. }
  63. export type ToolCallRequest = ChatResponseBase<'toolcall'> & {
  64. request: {
  65. id: string
  66. name: string
  67. data: string
  68. }
  69. }
  70. export type ToolCallResponse = ChatResponseBase<'toolres'> & {
  71. response: {
  72. id: string
  73. name: string
  74. data: string
  75. }
  76. }
  77. export type ErrorResponse = ChatResponseBase<'error'> & {
  78. error: string
  79. }
  80. export type MetaResponse = ChatResponseBase<'meta'> & {
  81. meta: string
  82. }
  83. export type DataResponse = ChatResponseBase<'datamsg'> & {
  84. data: string
  85. }
  86. export type StructDataResponse = ChatResponseBase<'structdata'> & {
  87. uuid: string
  88. }
  89. export type ChatResponse = Text | ToolCallRequest | ToolCallResponse | ErrorResponse | DataResponse | StructDataResponse
  90. export type ModelType = 'embedding' | 'chat'
  91. // 大语言模型配置相关类型定义
  92. // 大语言模型配置列表查询参数
  93. export type LmConfigListParams = {
  94. keyWord?: string // 搜索关键字
  95. dateRange?: string[] // 日期范围
  96. OrderBy?: string // 排序
  97. pageNum?: number // 分页号码,默认1
  98. pageSize?: number // 分页数量,最大500,默认10
  99. modelClass?: string // 模型分类
  100. modelName?: string // 模型名称
  101. modelType?: ModelType // 模型类型
  102. status?: string // 是否启用
  103. createdAt?: string // 创建时间
  104. }
  105. // 大语言模型配置基础信息
  106. export type LmConfigInfo = {
  107. id?: number
  108. modelClass?: string // 模型分类
  109. modelName?: string // 模型名称
  110. apiKey?: string // API密钥
  111. baseUrl?: string // 基础URL
  112. modelType?: ModelType // 模型类型
  113. isCallFun?: boolean // 是否调用函数
  114. maxToken?: number // 最大令牌数
  115. status: boolean // 是否启用
  116. createdAt?: string // 创建时间
  117. updatedAt?: string // 更新时间
  118. createdBy?: number // 创建者ID
  119. updatedBy?: number // 更新者ID
  120. createdUser?: any // 创建用户信息
  121. actionBtn?: any // 操作按钮
  122. [key: string]: any // 允许其他字段
  123. }
  124. // 大语言模型配置添加请求
  125. export type LmConfigAddReq = Omit<LmConfigInfo, 'id' | 'createdAt' | 'updatedAt'>
  126. // 大语言模型配置编辑请求
  127. export type LmConfigEditReq = LmConfigInfo & {
  128. id: number // 编辑时ID必须
  129. }
  130. // 大语言模型配置状态设置请求
  131. export type LmConfigStatusReq = {
  132. id: number
  133. status: string
  134. }
  135. // 删除请求参数
  136. export type LmConfigDeleteParams = {
  137. ids: number[]
  138. }
  139. // 获取单个配置参数
  140. export type LmConfigGetParams = {
  141. id: number
  142. }
  143. export type LmSession = {
  144. session_id: number
  145. title: string
  146. }
  147. // 会话消息列表查询参数
  148. export type SessionMessagesListParams = {
  149. sessionId: number
  150. }
  151. // 保存会话消息请求
  152. export type SessionMessagesSaveReq = {
  153. sessionId: number
  154. messages: Message[]
  155. }
  156. export type LmDashboard = {
  157. id: number
  158. title: string
  159. data: string
  160. remark?: string // 备注
  161. createdAt?: string // 创建时间
  162. updatedAt?: string // 更新时间
  163. createdBy?: number // 创建者ID
  164. updatedBy?: number // 更新者ID
  165. }
  166. export type Prompt = {
  167. id: number
  168. title: string
  169. prompt: string
  170. placeholder?: string
  171. createdAt?: string // 创建时间
  172. updatedAt?: string // 更新时间
  173. createdBy?: number // 创建者ID
  174. updatedBy?: number // 更新者ID
  175. }
  176. // Prompt列表查询参数
  177. export type PromptListParams = {
  178. keyWord?: string // 搜索关键字
  179. dateRange?: string[] // 日期范围
  180. OrderBy?: string // 排序
  181. pageNum?: number // 分页号码,默认1
  182. pageSize?: number // 分页数量,最大500,默认10
  183. title?: string // 标题
  184. createdAt?: string // 创建时间
  185. }
  186. // Prompt添加请求
  187. export type PromptAddReq = Omit<Prompt, 'id' | 'createdAt' | 'updatedAt'>
  188. // Prompt编辑请求
  189. export type PromptEditReq = Prompt & {
  190. id: number // 编辑时ID必须
  191. }
  192. // Prompt删除请求参数
  193. export type PromptDeleteParams = {
  194. ids: number[]
  195. }
  196. // 获取单个Prompt参数
  197. export type PromptGetParams = {
  198. id: number
  199. }