2023-11-22 10:37:08 +00:00
|
|
|
import { Result } from '@/request/Result'
|
2023-11-27 09:06:39 +00:00
|
|
|
import { get, post, postStream, del, put } from '@/request/index'
|
2023-11-23 09:20:19 +00:00
|
|
|
import type { pageRequest } from '@/api/type/common'
|
2023-11-24 11:02:52 +00:00
|
|
|
import type { ApplicationFormType } from '@/api/type/application'
|
2023-11-27 09:06:39 +00:00
|
|
|
import { type Ref } from 'vue'
|
|
|
|
|
|
2023-11-22 10:37:08 +00:00
|
|
|
const prefix = '/application'
|
|
|
|
|
|
2023-11-24 11:02:52 +00:00
|
|
|
/**
|
|
|
|
|
* 获取全部应用
|
|
|
|
|
* @param 参数
|
|
|
|
|
*/
|
|
|
|
|
const getAllAppilcation: () => Promise<Result<any[]>> = () => {
|
|
|
|
|
return get(`${prefix}`)
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-23 09:20:19 +00:00
|
|
|
/**
|
|
|
|
|
* 获取分页应用
|
|
|
|
|
* @param 参数 {
|
|
|
|
|
"current_page": "string",
|
|
|
|
|
"page_size": "string",
|
|
|
|
|
"name": "string",
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
const getApplication: (param: pageRequest) => Promise<Result<any>> = (param) => {
|
|
|
|
|
return get(
|
|
|
|
|
`${prefix}/${param.current_page}/${param.page_size}`,
|
|
|
|
|
param.name && { name: param.name }
|
|
|
|
|
)
|
|
|
|
|
}
|
2023-11-24 11:02:52 +00:00
|
|
|
|
|
|
|
|
/**
|
2023-11-27 09:06:39 +00:00
|
|
|
* 创建应用
|
2023-11-24 11:02:52 +00:00
|
|
|
* @param 参数
|
|
|
|
|
* {
|
|
|
|
|
"name": "string",
|
|
|
|
|
"desc": "string",
|
|
|
|
|
"model_id": "string",
|
|
|
|
|
"multiple_rounds_dialogue": true,
|
|
|
|
|
"prologue": "string",
|
|
|
|
|
"example": [
|
|
|
|
|
"string"
|
|
|
|
|
],
|
|
|
|
|
"dataset_id_list": [
|
|
|
|
|
"string"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
const postApplication: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
|
|
|
|
return post(`${prefix}`, data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-27 09:06:39 +00:00
|
|
|
* 获得临时回话Id
|
2023-11-24 11:02:52 +00:00
|
|
|
* @param 参数
|
|
|
|
|
* {
|
|
|
|
|
"model_id": "string",
|
|
|
|
|
"multiple_rounds_dialogue": true,
|
|
|
|
|
"dataset_id_list": [
|
|
|
|
|
"string"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
|
|
|
|
return post(`${prefix}/chat/open`, data)
|
|
|
|
|
}
|
2023-11-27 09:06:39 +00:00
|
|
|
// 对话
|
2023-11-24 11:02:52 +00:00
|
|
|
/**
|
|
|
|
|
* 创建数据集
|
|
|
|
|
* @param 参数
|
|
|
|
|
* chat_id: string
|
|
|
|
|
* {
|
|
|
|
|
"message": "string",
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
const postChatMessage: (chat_id: string, message: string) => Promise<Result<any>> = (
|
|
|
|
|
chat_id,
|
|
|
|
|
message
|
|
|
|
|
) => {
|
2023-11-27 09:06:39 +00:00
|
|
|
return postStream(`${prefix}/chat_message/${chat_id}`, { message })
|
2023-11-24 11:02:52 +00:00
|
|
|
}
|
2023-11-23 09:20:19 +00:00
|
|
|
export default {
|
2023-11-24 11:02:52 +00:00
|
|
|
getAllAppilcation,
|
|
|
|
|
getApplication,
|
|
|
|
|
postApplication,
|
|
|
|
|
postChatOpen,
|
|
|
|
|
postChatMessage
|
2023-11-23 09:20:19 +00:00
|
|
|
}
|