| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import axios from "@/utils/request";
- import { fetchEventSource } from '@microsoft/fetch-event-source'
- // 数字人对话框
- export function CreateDialogue (data){
- return axios({
- url: "bjdxWeb/ai/create-dialogue",
- method: 'post',
- data
- })
- }
- // 发送 Stream 消息
- // 为什么不用 axios 呢?因为它不支持 SSE 调用
- export async function sendChatMessageStream (
- conversationId,
- content,
- ctrl,
- enableContext,
- onMessage,
- onError,
- onClose
- ) {
- return fetchEventSource(`http://127.0.0.1:8080/admin-api/bjdxWeb/ai/dialogue-send-stream`, {
- method: 'post',
- headers: {
- 'Content-Type': 'application/json',
- // Authorization: `Bearer b55bd67fba3e4bb49608168f078fde63`
- },
- openWhenHidden: true,
- body: JSON.stringify({
- conversationId,
- content,
- useContext: enableContext
- }),
- onmessage: onMessage,
- onerror: onError,
- onclose: onClose,
- signal: ctrl.signal
- })
- }
- // 生成图片
- export function CreatePainting (data){
- return axios({
- url: "bjdxWeb/ai/create-painting",
- method: 'post',
- data
- })
- }
- // 绘画
- export function CreatePaintingGetMy (data){
- return axios({
- url: "bjdxWeb/ai/painting-get-my",
- method: 'get',
- data
- })
- }
|