|
|
|
import { defHttp } from '@/utils/axios/index'
|
|
|
|
import type { MenuTypeEnum } from '@/enums/menuEnum'
|
|
|
|
import type { ModelTypeEnum, NetTypeEnum } from '@/enums/messageEnum'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 新建会话
|
|
|
|
*/
|
|
|
|
export async function addMessage(data: {
|
|
|
|
type: MenuTypeEnum
|
|
|
|
title: string
|
|
|
|
sort: number
|
|
|
|
roleId?: string
|
|
|
|
modelType: ModelTypeEnum
|
|
|
|
}) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/conversation/save`,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 编辑会话名称
|
|
|
|
*/
|
|
|
|
export async function updateMessage(data: any) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/conversation/update`,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 根据id删除会话
|
|
|
|
*/
|
|
|
|
export async function removeMessage(ids: string) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/conversation/remove?ids=${ids}`,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 对话列表
|
|
|
|
*/
|
|
|
|
export async function conversationList(menuType: number) {
|
|
|
|
return defHttp.get({
|
|
|
|
url: `/open-chat/chat/conversation/list?type=${menuType}`,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 对话列表置顶
|
|
|
|
*/
|
|
|
|
export async function conversationToTop(conversationId: string) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/conversation/top?id=${conversationId}`,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 对话历史记录
|
|
|
|
*/
|
|
|
|
export async function historyMessage(params: {
|
|
|
|
conversationId: string
|
|
|
|
current: number
|
|
|
|
size: number
|
|
|
|
}) {
|
|
|
|
return defHttp.get({
|
|
|
|
url: `/open-chat/chat/chatMessageLog/page`,
|
|
|
|
params,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 停止对话
|
|
|
|
*/
|
|
|
|
export async function stopMessage(data: { conversationId: string }) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/stopGenerate`,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 发送消息(文生文)要带modelType,区分gpt3.5和gpt4
|
|
|
|
*/
|
|
|
|
export async function sendTextToText(data: {
|
|
|
|
conversationId: string
|
|
|
|
question: string
|
|
|
|
modelType: ModelTypeEnum
|
|
|
|
roleId?: number
|
|
|
|
netType: NetTypeEnum
|
|
|
|
}) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/chat/session`,
|
|
|
|
data,
|
|
|
|
timeout: 120 * 1000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 发送消息(文生图)不需要带modelType
|
|
|
|
*/
|
|
|
|
export async function sendTextToImage(data: {
|
|
|
|
conversationId: string
|
|
|
|
question: string
|
|
|
|
}) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/gpts/getDallEImages`,
|
|
|
|
data,
|
|
|
|
timeout: 120 * 1000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 发送消息(知识库)
|
|
|
|
*/
|
|
|
|
export async function sendRepository(data: {
|
|
|
|
conversationId: string
|
|
|
|
question: string
|
|
|
|
}) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/gpts/getQanythingStreamChat`,
|
|
|
|
data,
|
|
|
|
timeout: 120 * 1000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 发送消息(图像分析)不需要带modelType
|
|
|
|
*/
|
|
|
|
export async function sendVisualAnalysis(data: {
|
|
|
|
conversationId: string
|
|
|
|
question: string
|
|
|
|
fileUrl: string
|
|
|
|
}) {
|
|
|
|
return defHttp.post({
|
|
|
|
url: `/open-chat/gpts/getImageVision`,
|
|
|
|
data,
|
|
|
|
timeout: 120 * 1000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description 获取chat信息
|
|
|
|
*/
|
|
|
|
export async function chatInfo() {
|
|
|
|
return defHttp.get({
|
|
|
|
url: `/open-chat/chat/ai/getWxUserInfo`,
|
|
|
|
})
|
|
|
|
}
|