chat.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { http } from '@/utils/request';
  2. import { ChatR, ImageR } from '@/api/models';
  3. import { AxiosProgressEvent } from 'axios';
  4. /**
  5. * @description: 聊天
  6. */
  7. export function chat(
  8. data: ChatR,
  9. onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
  10. ) {
  11. return http.post({
  12. url: '/client/chat',
  13. data,
  14. onDownloadProgress: onDownloadProgress,
  15. });
  16. }
  17. /**
  18. * @description: Doc聊天
  19. */
  20. export function docsChat(
  21. knowledgeId: string,
  22. data: any,
  23. onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
  24. ) {
  25. return http.post({
  26. url: `/client/docs/${knowledgeId}`,
  27. data,
  28. onDownloadProgress: onDownloadProgress,
  29. });
  30. }
  31. export function getPrompts(data: any) {
  32. return http.get({
  33. url: '/client/prompt/list',
  34. data: data,
  35. });
  36. }
  37. export function getChatModels() {
  38. return http.get({
  39. url: '/client/getChatModels',
  40. });
  41. }
  42. export function getImageModels() {
  43. return http.get({
  44. url: '/client/getImageModels',
  45. });
  46. }
  47. export function genWrite(
  48. data: ChatR,
  49. onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
  50. ) {
  51. return http.post({
  52. url: `/client/chat/write`,
  53. data: data,
  54. onDownloadProgress: onDownloadProgress,
  55. });
  56. }
  57. export function genChart(data: ChatR) {
  58. return http.post({
  59. url: '/client/chat/chart',
  60. data: data,
  61. });
  62. }
  63. /**
  64. * @description 生成图片
  65. */
  66. export function genImage(data: ImageR) {
  67. return http.post({
  68. url: '/client/chat/image',
  69. data: data,
  70. });
  71. }
  72. /**
  73. * @description: 生成思维导图
  74. */
  75. export function genMindMap(data: ChatR) {
  76. return http.post({
  77. url: '/client/chat/mindmap',
  78. data: data,
  79. });
  80. }