agent.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import {
  2. bluebookAiAgent,
  3. } from '@/xiaolanbenlib/api/index'
  4. import request from '@/xiaolanbenlib/module/axios.js'
  5. import { TAgentDetail, TComponentItem, TEditAgentCharacter, TAgentContactCard, TAgentShared, TAgent, TAgentRequiredData } from '@/types/agent'
  6. // 获取我的智能体详细信息
  7. // 供编辑页使用,预览页使用智能体信息接口获取
  8. export const getMyAgent = (agentId: string) => {
  9. return request.get<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
  10. }
  11. // 获取创建智能体时的默认填充内容项
  12. export const getNewAgentInfo = () => {
  13. return request.get<{
  14. "address"?: string;
  15. "avatarLogo"?: string;
  16. "avatarUrl"?: string;
  17. "email"?: string;
  18. "enabledChatBg"?: boolean;
  19. "enabledPersonalKb"?: boolean;
  20. "entName"?: string;
  21. "greeting"?: string;
  22. "mobile"?: string;
  23. "name"?: string;
  24. "personality"?: string;
  25. "position"?: string;
  26. "qrCodeUrl"?: string;
  27. "questionGuides"?: string[];
  28. "voiceId"?: string;
  29. "voiceName"?: string;
  30. }>(`${bluebookAiAgent}api/v1/my/new/agent/info`)
  31. }
  32. // 创建新智能体
  33. export const createNewAgent = (data: Omit<TAgentRequiredData, 'agentId'>) => {
  34. return request.post<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/create`, data)
  35. }
  36. // 编辑智能体
  37. export const editAgent = (data: TAgentRequiredData) => {
  38. return request.put<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/${data.agentId}`, data)
  39. }
  40. // 设置当前我的默认智能体
  41. export const setDefaultAgent = (agentId: string) => {
  42. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/default`)
  43. }
  44. // 编辑智能体--微官网组件
  45. export const editAgentWebsite = (agentId: string, data: {components: TComponentItem[]}) => {
  46. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/website`, data)
  47. }
  48. // 我的智能体列表
  49. export const getAgents = () => {
  50. return request.get<TAgent[]>(`${bluebookAiAgent}api/v1/my/agents`)
  51. }
  52. // 删除智能体--仅允许删除个人智能体
  53. export const deleteAgent = (agentId: string) => {
  54. return request.delete(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
  55. }
  56. // 访问某个智能体,允许不登录状态下访问
  57. export const getAgent = (agentId: string, shareKey?: string) => {
  58. return request.get<TAgentDetail>(`${bluebookAiAgent}api/v1/agent/${agentId}`, {
  59. params: {shareKey}
  60. })
  61. }
  62. // 上报访客日志--间隔 N 秒调用一次
  63. export const postVisitorLog = (data: {
  64. agentId: string,
  65. loginId: string,
  66. shareKey?: string,
  67. }) => {
  68. return request.post<TAgentDetail>(`${bluebookAiAgent}api/v1/agent/visitor/log`, data)
  69. }
  70. // 文本润色
  71. export const textPolishing = (data: {
  72. content: string
  73. type: 'personality'|'greeting' // 人设/开场白
  74. }) => {
  75. return request.post<{content: string}>(`${bluebookAiAgent}api/v1/my/agent/textPolishing`, data)
  76. }
  77. // 获取智能体的分享信息--仅登录才能分享
  78. export const getAgentShareInfo = (agentId: string) => {
  79. return request.get<TAgentShared>(`${bluebookAiAgent}api/v1/agent/${agentId}/shareInfo`)
  80. }
  81. // 批量获取智能体信息,用于微官网组件 -- 允许未登录用户直接访问
  82. export const getAgentBatch = (agentIds: string) => {
  83. return request.get<TAgent[]>(`${bluebookAiAgent}api/v1/agent/batch`, {
  84. params: {agentIds}
  85. })
  86. }
  87. // 获取指定企业的同事智能体--用于官网信息中智能体推荐部份--包含自己的智能体
  88. export const getEntAgentPartners = (params: {
  89. entId: number|string,
  90. startId?: string
  91. pageSize: number
  92. }) => {
  93. return request.get<TAgent[]>(`${bluebookAiAgent}api/v1/my/ent/${params.entId}/agent/partners`, {
  94. params
  95. })
  96. }
  97. // ============ deprecated ===========
  98. // 编辑智能体--设置形象ID
  99. // deprecated
  100. // export const editAgentAvatar = (agentId: string, avatarId: string|number, enabledChatBg:boolean) => {
  101. // return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/avatar`, {
  102. // avatarId,
  103. // enabledChatBg,
  104. // })
  105. // }
  106. // 编辑智能体--是否启用背景聊天效果
  107. // deprecated
  108. export const editAgentChatBg = (agentId: string, enabledChatBg: boolean) => {
  109. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/avatar/chatBg`, {
  110. enabledChatBg,
  111. })
  112. }
  113. // 编辑智能体--名片部份内容
  114. // address (string, optional): 地址,长度最多250 ,
  115. // email (string, optional): 邮箱,长度最多50 ,
  116. // entName (string, optional): 企业名称,长度最多100,如果是个人版允许编辑、企业版可以原值传入即可 ,
  117. // mobile (string, optional): 手机号 ,
  118. // name (string, optional): 智能体名称--名片的姓名;长度最多20 ,
  119. // position (string, optional): 职位,长度最多30 ,
  120. // qrCodeUrl (string, optional): 二维码地址,长度最多250
  121. // deprecated
  122. export const editAgentCard = (agentId: string, data: TAgentContactCard) => {
  123. return request.put<any, any>(`${bluebookAiAgent}api/v1/my/agent/${agentId}/card`, data)
  124. }
  125. // 编辑智能体--声音、人设、开场白、问题引导、知识库
  126. // deprecated
  127. export const editAgentCharacter = (agentId: string, data: TEditAgentCharacter) => {
  128. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/character`, data)
  129. }