agent.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {
  2. bluebookAiAgent,
  3. } from '@/lib/api/index'
  4. import request from '@/lib/module/axios.js'
  5. import { TAgentDetail, TComponentItem } from '@/types/agent'
  6. // 创建一个新的智能体--用户点击创建按钮时调用获取新智能体id与名称信息
  7. export const createAgent = (data: TAgentDetail) => {
  8. return request.post<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent`, data)
  9. }
  10. // 获取我的智能体详细信息
  11. // 供编辑页使用,预览页使用智能体信息接口获取
  12. export const getAgent = (agentId: string) => {
  13. return request.get<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
  14. }
  15. // 编辑智能体--设置形象ID
  16. export const editAgentAvatar = (agentId: string, avatarUrl: string, enabledChatBg:boolean) => {
  17. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/avatar`, {
  18. avatarUrl,
  19. enabledChatBg,
  20. })
  21. }
  22. // 设置当前我的默认智能体
  23. export const setDefaultAgent = (agentId: string) => {
  24. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/default`)
  25. }
  26. // 编辑智能体--微官网组件
  27. export const editAgentWebsite = (agentId: string, data: {components: TComponentItem[]}) => {
  28. return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/website`, data)
  29. }
  30. // 编辑智能体--名片部份内容
  31. // address (string, optional): 地址,长度最多250 ,
  32. // email (string, optional): 邮箱,长度最多50 ,
  33. // entName (string, optional): 企业名称,长度最多100,如果是个人版允许编辑、企业版可以原值传入即可 ,
  34. // mobile (string, optional): 手机号 ,
  35. // name (string, optional): 智能体名称--名片的姓名;长度最多20 ,
  36. // position (string, optional): 职位,长度最多30 ,
  37. // qrCodeUrl (string, optional): 二维码地址,长度最多250
  38. export type TAgentContactCard = {
  39. "address"?: string,
  40. "email"?: string,
  41. "entName"?: string,
  42. "mobile"?: string,
  43. "name"?: string,
  44. "position"?: string,
  45. "qrCodeUrl"?: string
  46. }
  47. export const editAgentCard = (agentId: string, data: TAgentContactCard) => {
  48. return request.put<any, any>(`${bluebookAiAgent}api/v1/my/agent/${agentId}/card`, data)
  49. }
  50. export type TAgent = {
  51. "agentId": "string",
  52. "isDefault": boolean,
  53. "isEnt": boolean,
  54. "isNewEnt": boolean,
  55. "name": "string"
  56. }
  57. // 我的智能体列表
  58. export const getAgents = () => {
  59. return request.get<TAgent>(`${bluebookAiAgent}api/v1/my/agents`)
  60. }
  61. // 删除智能体--仅允许删除个人智能体
  62. export const deleteAgent = (agentId: string) => {
  63. return request.delete(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
  64. }