questions.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import axios from "@/utils/request";
  2. import { fetchEventSource } from '@microsoft/fetch-event-source'
  3. // 数字人对话框
  4. export function CreateDialogue (data){
  5. return axios({
  6. url: "bjdxWeb/ai/create-dialogue",
  7. method: 'post',
  8. data
  9. })
  10. }
  11. // 发送 Stream 消息
  12. // 为什么不用 axios 呢?因为它不支持 SSE 调用
  13. export async function sendChatMessageStream (
  14. conversationId,
  15. content,
  16. ctrl,
  17. enableContext,
  18. onMessage,
  19. onError,
  20. onClose
  21. ) {
  22. return fetchEventSource(`http://127.0.0.1:8080/admin-api/bjdxWeb/ai/dialogue-send-stream`, {
  23. method: 'post',
  24. headers: {
  25. 'Content-Type': 'application/json',
  26. // Authorization: `Bearer b55bd67fba3e4bb49608168f078fde63`
  27. },
  28. openWhenHidden: true,
  29. body: JSON.stringify({
  30. conversationId,
  31. content,
  32. useContext: enableContext
  33. }),
  34. onmessage: onMessage,
  35. onerror: onError,
  36. onclose: onClose,
  37. signal: ctrl.signal
  38. })
  39. }
  40. // 生成图片
  41. export function CreatePainting (data){
  42. return axios({
  43. url: "bjdxWeb/ai/create-painting",
  44. method: 'post',
  45. data
  46. })
  47. }
  48. // 绘画
  49. export function CreatePaintingGetMy (data){
  50. return axios({
  51. url: "bjdxWeb/ai/painting-get-my",
  52. method: 'get',
  53. data
  54. })
  55. }