chat_records.api 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import "../base.api"
  2. type (
  3. // The data of chat records information | ChatRecords信息
  4. ChatRecordsInfo {
  5. BaseIDInfo
  6. // 内容
  7. Content *string `json:"content,optional"`
  8. // 内容类型:1-提问 2-回答
  9. ContentType *uint8 `json:"contentType,optional"`
  10. // 角色类型:1-用户 2-智能体
  11. RoleType *string `json:"roleType,optional"`
  12. // 会话ID
  13. SessionId *uint64 `json:"sessionId,optional"`
  14. // 用户ID
  15. UserId *uint64 `json:"userId,optional"`
  16. // 聊天ID
  17. BotId *uint64 `json:"botId,optional"`
  18. // 类型:1-微信 2-小程序card 3-智能体
  19. BotType *uint8 `json:"botType,optional,options=1|2|3"`
  20. Finish bool `json:"finish,optional"`
  21. }
  22. // The response data of chat records list | ChatRecords列表数据
  23. ChatRecordsListResp {
  24. BaseDataInfo
  25. // ChatRecords list data | ChatRecords列表数据
  26. Data ChatRecordsListInfo `json:"data"`
  27. }
  28. // ChatRecords list data | ChatRecords列表数据
  29. ChatRecordsListInfo {
  30. BaseListInfo
  31. // The API list data | ChatRecords列表数据
  32. Data []ChatRecordsInfo `json:"data"`
  33. }
  34. // Get chat records list request params | ChatRecords列表请求参数
  35. ChatRecordsListReq {
  36. PageInfo
  37. SessionId *uint64 `json:"sessionId"`
  38. BotId *uint64 `json:"botId,optional"`
  39. BotType *uint8 `json:"botType,optional"`
  40. }
  41. // ChatRecords information response | ChatRecords信息返回体
  42. ChatRecordsInfoResp {
  43. BaseDataInfo
  44. // ChatRecords information | ChatRecords数据
  45. Data ChatRecordsInfo `json:"data"`
  46. }
  47. ChatRecommendReq {
  48. SessionId *uint64 `json:"sessionId"`
  49. }
  50. ChatRecommendResp {
  51. BaseDataInfo
  52. // The API list data | ChatRecords列表数据
  53. Data ChatRecommend `json:"data"`
  54. }
  55. ChatRecommend {
  56. Data []string `json:"data"`
  57. SessionId uint64 `json:"sessionId"`
  58. }
  59. ChatAskReq {
  60. CardId *uint64 `json:"cardId"`
  61. Question *string `json:"question"`
  62. SessionId *int `json:"sessionId"`
  63. }
  64. ChatAskResp {
  65. BaseDataInfo
  66. Data *string `json:"data"`
  67. }
  68. GptChatReq{
  69. ConversationId *string `json:"conversationId,optional"`
  70. Content *string `json:"content"`
  71. AgentId *uint64 `json:"agentId"`
  72. }
  73. GptMessageReq {
  74. ConversationId *string `json:"conversationId,optional"`
  75. FirstId *string `json:"firstId,optional"`
  76. Limit *int `json:"limit"`
  77. AgentId *uint64 `json:"agentId"`
  78. }
  79. GptMessageResp {
  80. BaseDataInfo
  81. Data GptMessageList `json:"data"`
  82. }
  83. GptMessageList {
  84. HasMore bool `json:"hasMore"`
  85. Data []Message `json:"data"`
  86. }
  87. Message {
  88. Id *string `json:"id"`
  89. ConversationId *string `json:"conversationId,optional"`
  90. Query *string `json:"query"`
  91. Answer *string `json:"answer"`
  92. Inputs interface{} `json:"inputs"`
  93. CreatedAt *int `json:"createdAt"`
  94. }
  95. GptsSessionReq {
  96. Limit *int `json:"limit"`
  97. LastId *string `json:"lastId,optional"`
  98. AgentId *uint64 `json:"agentId"`
  99. }
  100. GptsSessionResp {
  101. BaseDataInfo
  102. Data GptsSessionList `json:"data"`
  103. }
  104. GptsSessionList {
  105. HasMore bool `json:"hasMore"`
  106. Data []Session `json:"data"`
  107. }
  108. Session {
  109. Id *string `json:"id"`
  110. Name *string `json:"name"`
  111. CreatedAt *int `json:"createdAt"`
  112. Inputs interface{} `json:"inputs"`
  113. }
  114. GptsDeleteSessionReq {
  115. AgentId *uint64 `json:"agentId"`
  116. ConversationId *string `json:"conversationId"`
  117. }
  118. GptsRenameSessionReq {
  119. AgentId *uint64 `json:"agentId"`
  120. ConversationId *string `json:"conversationId"`
  121. Name *string `json:"name"`
  122. }
  123. )
  124. @server(
  125. group: chatrecords
  126. )
  127. service Wechat {
  128. // Create chat records information | 创建ChatRecords
  129. @handler gptsSubmitApiChat
  130. post /gpts/chat/submit (GptChatReq)
  131. // Get chat message list | 获取聊天历史
  132. @handler gptsGetApiMessage
  133. post /gpts/chat/message (GptMessageReq) returns (GptMessageResp)
  134. // Get chat session list | 获取会话列表
  135. @handler gptsGetApiSession
  136. post /gpts/chat/session (GptsSessionReq) returns (GptsSessionResp)
  137. // Create chat records information | 创建ChatRecords
  138. @handler gptsDeleteApiSession
  139. post /gpts/chat/session/delete (GptsDeleteSessionReq) returns (BaseMsgResp)
  140. // Create chat records information | 创建ChatRecords
  141. @handler gptsRenameApiSession
  142. post /gpts/chat/session/rename (GptsRenameSessionReq) returns (BaseMsgResp)
  143. }
  144. @server(
  145. jwt: Auth
  146. group: chatrecords
  147. middleware: Miniprogram
  148. )
  149. service Wechat {
  150. // Create chat records information | 创建ChatRecords
  151. @handler submitApiChat
  152. post /api/chat/create (ChatRecordsInfo)
  153. // Create chat records information | 创建ChatRecords
  154. @handler answerApiChat
  155. post /api/chat/answer (ChatAskReq) returns (ChatAskResp)
  156. // Get chat records list | 获取ChatRecords列表
  157. @handler getApiChatList
  158. post /api/chat/list (ChatRecordsListReq) returns (ChatRecordsListResp)
  159. // Get chat records list | 获取ChatRecords列表
  160. @handler getApiRecommendChat
  161. post /api/chat/recommmend (ChatRecommendReq) returns (ChatRecommendResp)
  162. }
  163. @server(
  164. jwt: Auth
  165. group: chatrecords
  166. middleware: Authority
  167. )
  168. service Wechat {
  169. // Create chat records information | 创建ChatRecords
  170. @handler createChatRecords
  171. post /chat_records/create (ChatRecordsInfo) returns (BaseMsgResp)
  172. // Update chat records information | 更新ChatRecords
  173. @handler updateChatRecords
  174. post /chat_records/update (ChatRecordsInfo) returns (BaseMsgResp)
  175. // Delete chat records information | 删除ChatRecords信息
  176. @handler deleteChatRecords
  177. post /chat_records/delete (IDsReq) returns (BaseMsgResp)
  178. // Get chat records list | 获取ChatRecords列表
  179. @handler getChatRecordsList
  180. post /chat_records/list (ChatRecordsListReq) returns (ChatRecordsListResp)
  181. // Get chat records by ID | 通过ID获取ChatRecords
  182. @handler getChatRecordsById
  183. post /chat_records (IDReq) returns (ChatRecordsInfoResp)
  184. }