UnisKB/ui/src/api/application.ts

86 lines
1.8 KiB
TypeScript
Raw Normal View History

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",
}
*/
2023-11-27 10:08:58 +00:00
const postChatMessage: (chat_id: string, message: string) => Promise<any> = (chat_id, message) => {
return postStream(`/api/${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
}