[新增]完善AI写作

This commit is contained in:
hhhero
2024-07-08 00:41:20 +08:00
parent 1afdbe651e
commit f72e4f47f4
5 changed files with 174 additions and 30 deletions

View File

@ -1,4 +1,3 @@
import request from '@/config/axios'
import { fetchEventSource } from '@microsoft/fetch-event-source'
import { getAccessToken } from '@/utils/auth'
@ -34,7 +33,19 @@ export interface WriteParams {
*/
language: number
}
export const writeStream = (data: WriteParams, onMessage, onError, onClose, ctrl) => {
export const writeStream = ({
data,
onClose,
onMessage,
onError,
ctrl
}: {
data: WriteParams
onMessage?: (res: any) => void
onError?: (...args: any[]) => void
onClose?: (...args: any[]) => void
ctrl: AbortController
}) => {
// return request.post({ url: '/ai/write/generate-stream', data })
const token = getAccessToken()
return fetchEventSource(`${config.base_url}/ai/write/generate-stream`, {