UnisKB/ui/src/api/application.ts

273 lines
6.1 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
/**
*
2023-12-06 11:09:54 +00:00
* page {
"current_page": "string",
"page_size": "string",
}
* param {
"name": "string",
}
2023-11-23 09:20:19 +00:00
*/
2023-12-06 11:09:54 +00:00
const getApplication: (
page: pageRequest,
param: any,
loading?: Ref<boolean>
) => Promise<Result<any>> = (page, param, loading) => {
return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading)
2023-11-23 09:20:19 +00:00
}
2023-11-24 11:02:52 +00:00
2023-11-28 10:53:22 +00:00
/**
*
2024-01-17 08:29:37 +00:00
* @param
2023-11-28 10:53:22 +00:00
*/
2023-11-29 03:25:14 +00:00
const postApplication: (
data: ApplicationFormType,
loading?: Ref<boolean>
) => Promise<Result<any>> = (data, loading) => {
2023-11-28 10:53:22 +00:00
return post(`${prefix}`, data, undefined, loading)
}
2023-11-29 07:42:48 +00:00
/**
*
2024-07-01 01:45:59 +00:00
* @param
2023-11-29 07:42:48 +00:00
*/
const putApplication: (
2024-04-15 10:46:03 +00:00
application_id: String,
2023-11-29 07:42:48 +00:00
data: ApplicationFormType,
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, data, loading) => {
return put(`${prefix}/${application_id}`, data, undefined, loading)
2023-11-29 07:42:48 +00:00
}
2023-11-29 03:25:14 +00:00
/**
*
2024-04-15 10:46:03 +00:00
* @param application_id
2023-11-29 03:25:14 +00:00
*/
2023-12-12 06:30:03 +00:00
const delApplication: (
2024-04-15 10:46:03 +00:00
application_id: String,
2023-12-12 06:30:03 +00:00
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<boolean>> = (application_id, loading) => {
return del(`${prefix}/${application_id}`, undefined, {}, loading)
2023-11-29 03:25:14 +00:00
}
/**
*
2024-04-15 10:46:03 +00:00
* @param application_id
2023-11-29 03:25:14 +00:00
*/
2023-11-29 07:42:48 +00:00
const getApplicationDetail: (
2024-04-15 10:46:03 +00:00
application_id: string,
2023-11-29 07:42:48 +00:00
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, loading) => {
return get(`${prefix}/${application_id}`, undefined, loading)
2023-11-29 07:42:48 +00:00
}
/**
2023-12-18 03:32:29 +00:00
* 使
2024-04-15 10:46:03 +00:00
* @param application_id
2023-11-29 07:42:48 +00:00
*/
const getApplicationDataset: (
2024-04-15 10:46:03 +00:00
application_id: string,
2023-11-29 07:42:48 +00:00
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, loading) => {
return get(`${prefix}/${application_id}/list_dataset`, undefined, loading)
2023-11-29 03:25:14 +00:00
}
2023-11-29 09:34:45 +00:00
/**
2023-12-08 08:55:29 +00:00
* AccessToken
2024-04-15 10:46:03 +00:00
* @param application_id
2023-11-29 09:34:45 +00:00
*/
2024-04-15 10:46:03 +00:00
const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
application_id,
2023-11-29 09:34:45 +00:00
loading
) => {
2024-04-15 10:46:03 +00:00
return get(`${prefix}/${application_id}/access_token`, undefined, loading)
2023-11-29 09:34:45 +00:00
}
/**
2023-12-08 08:55:29 +00:00
* AccessToken
2024-04-15 10:46:03 +00:00
* @param application_id
2023-12-08 08:55:29 +00:00
* data {
* "is_active": true
* }
2023-11-29 09:34:45 +00:00
*/
2023-12-08 08:55:29 +00:00
const putAccessToken: (
2024-04-15 10:46:03 +00:00
application_id: string,
2023-12-08 08:55:29 +00:00
data: any,
loading?: Ref<boolean>
2024-04-15 10:46:03 +00:00
) => Promise<Result<any>> = (application_id, data, loading) => {
return put(`${prefix}/${application_id}/access_token`, data, undefined, loading)
2023-11-29 09:34:45 +00:00
}
2023-11-30 10:50:42 +00:00
/**
*
* @param
{
"access_token": "string"
}
*/
const postAppAuthentication: (access_token: string, loading?: Ref<boolean>) => Promise<any> = (
access_token,
loading
) => {
return post(`${prefix}/authentication`, { access_token }, undefined, loading)
}
/**
*
* @param
{
"access_token": "string"
}
*/
const getProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`${prefix}/profile`, undefined, loading)
}
/**
* Id
* @param
2024-01-17 08:29:37 +00:00
2023-11-30 10:50:42 +00:00
}
*/
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
return post(`${prefix}/chat/open`, data)
}
2024-07-01 01:45:59 +00:00
/**
* Id
* @param
}
*/
const postWorkflowChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
return post(`${prefix}/chat_workflow/open`, data)
}
2023-11-30 10:50:42 +00:00
/**
* Id
* @param
* {
"model_id": "string",
"multiple_rounds_dialogue": true,
"dataset_id_list": [
"string"
]
}
*/
2024-04-15 10:46:03 +00:00
const getChatOpen: (application_id: String) => Promise<Result<any>> = (application_id) => {
return get(`${prefix}/${application_id}/chat/open`)
2023-11-30 10:50:42 +00:00
}
/**
*
* @param
2023-11-30 10:50:42 +00:00
* chat_id: string
* data
2023-11-30 10:50:42 +00:00
*/
2024-04-02 11:37:20 +00:00
const postChatMessage: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
return postStream(`/api${prefix}/chat_message/${chat_id}`, data)
2023-11-30 10:50:42 +00:00
}
2023-12-01 10:21:49 +00:00
/**
*
* @param
* application_id : string; chat_id : string; chat_record_id : string
* {
"vote_status": "string", // -1 0 1
}
*/
const putChatVote: (
application_id: string,
chat_id: string,
chat_record_id: string,
vote_status: string,
loading?: Ref<boolean>
) => Promise<any> = (application_id, chat_id, chat_record_id, vote_status, loading) => {
return put(
`${prefix}/${application_id}/chat/${chat_id}/chat_record/${chat_record_id}/vote`,
{
vote_status
},
undefined,
loading
)
}
2023-12-29 07:13:30 +00:00
/**
*
* @param application_id
* @param loading
* @query { query_text: string, top_number: number, similarity: number }
* @returns
*/
const getApplicationHitTest: (
application_id: string,
data: any,
loading?: Ref<boolean>
) => Promise<Result<Array<any>>> = (application_id, data, loading) => {
return get(`${prefix}/${application_id}/hit_test`, data, loading)
}
2024-03-05 09:22:22 +00:00
/**
* 使
* @param application_id
* @param loading
* @query { query_text: string, top_number: number, similarity: number }
* @returns
*/
const getApplicationModel: (
application_id: string,
loading?: Ref<boolean>
) => Promise<Result<Array<any>>> = (application_id, loading) => {
return get(`${prefix}/${application_id}/model`, loading)
}
2024-07-01 01:45:59 +00:00
/**
*
* @param
*/
const putPublishApplication: (
application_id: String,
data: ApplicationFormType,
loading?: Ref<boolean>
) => Promise<Result<any>> = (application_id, data, loading) => {
return put(`${prefix}/${application_id}/publish`, data, undefined, loading)
}
2023-11-23 09:20:19 +00:00
export default {
2023-11-24 11:02:52 +00:00
getAllAppilcation,
getApplication,
postApplication,
2023-11-29 07:42:48 +00:00
putApplication,
2023-11-24 11:02:52 +00:00
postChatOpen,
2023-11-30 10:50:42 +00:00
getChatOpen,
2023-11-29 03:25:14 +00:00
postChatMessage,
delApplication,
2023-11-29 07:42:48 +00:00
getApplicationDetail,
2023-11-29 09:34:45 +00:00
getApplicationDataset,
2023-11-30 10:50:42 +00:00
getAccessToken,
2023-12-08 08:55:29 +00:00
putAccessToken,
2023-11-30 10:50:42 +00:00
postAppAuthentication,
2023-12-01 10:21:49 +00:00
getProfile,
2023-12-29 07:13:30 +00:00
putChatVote,
2024-03-05 09:22:22 +00:00
getApplicationHitTest,
2024-07-01 01:45:59 +00:00
getApplicationModel,
putPublishApplication,
postWorkflowChatOpen
2023-11-23 09:20:19 +00:00
}