260720
This commit is contained in:
+25
-19
@@ -1,30 +1,36 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
import type { ApiResult } from '@/api';
|
||||
import { ChatParam } from '@/api/oa/chatgpt/model';
|
||||
import type {
|
||||
ChatMessageParam,
|
||||
ChatMessageStopParam
|
||||
} from '@/api/oa/chatgpt/model';
|
||||
|
||||
/**
|
||||
* 发送
|
||||
* 发送聊天消息
|
||||
*/
|
||||
export async function send(data: ChatParam) {
|
||||
const res = await request.post<ApiResult<unknown>>('/open/chat/send', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求openAI
|
||||
* /open/chat/chat
|
||||
* 'https://chatgpt.websoft.top/api/open/chat/chat',
|
||||
*/
|
||||
export async function chat(data: ChatParam) {
|
||||
export async function sendMessage(
|
||||
data: ChatMessageParam,
|
||||
config?: AxiosRequestConfig
|
||||
) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'https://chatgpt.websoft.top/api/open/chat/chat',
|
||||
data
|
||||
'/ai/chat/message',
|
||||
data,
|
||||
config
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
return res.data.data ?? res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止AI生成
|
||||
*/
|
||||
export async function stopMessage(data: ChatMessageStopParam) {
|
||||
const res = await request.post<ApiResult<unknown>>('/ai/messageStop', data);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data ?? res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message || '停止失败'));
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/**
|
||||
* 消息
|
||||
* 聊天消息参数
|
||||
*/
|
||||
export interface Chat {
|
||||
noticeId?: number;
|
||||
content?: any;
|
||||
tenantId?: number;
|
||||
export interface ChatMessageParam {
|
||||
query?: string;
|
||||
conversationId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务搜索条件
|
||||
* 停止AI生成参数
|
||||
*/
|
||||
export interface ChatParam {
|
||||
tenantId?: number;
|
||||
content?: string;
|
||||
noticeId?: number;
|
||||
export interface ChatMessageStopParam {
|
||||
taskId?: string;
|
||||
mode?: 'chat' | 'writing' | 'image' | 'projectQualityReview' | 'competitionHistoryPreprocess';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user