Integrate Chat and Copilot into chat-sdk, and add SQL parse display (#166)

This commit is contained in:
williamhliu
2023-10-02 18:05:12 +08:00
committed by GitHub
parent 741ed4191b
commit 71cb20eb4f
68 changed files with 1353 additions and 882 deletions

View File

@@ -1,12 +1,12 @@
import axios from './axiosInstance';
import { ChatContextType, DrillDownDimensionType, HistoryType, MsgDataType, ParseDataType, SearchRecommendItem } from '../common/type';
const DEFAULT_CHAT_ID = 12009993;
const DEFAULT_CHAT_ID = 0;
const prefix = '/api';
export function searchRecommend(queryText: string, chatId?: number, modelId?: number, agentId?: number) {
return axios.post<Result<SearchRecommendItem[]>>(`${prefix}/chat/query/search`, {
return axios.post<SearchRecommendItem[]>(`${prefix}/chat/query/search`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
@@ -15,7 +15,7 @@ export function searchRecommend(queryText: string, chatId?: number, modelId?: nu
}
export function chatQuery(queryText: string, chatId?: number, modelId?: number, filters?: any[]) {
return axios.post<Result<MsgDataType>>(`${prefix}/chat/query/query`, {
return axios.post<MsgDataType>(`${prefix}/chat/query/query`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
@@ -26,7 +26,7 @@ export function chatQuery(queryText: string, chatId?: number, modelId?: number,
}
export function chatParse(queryText: string, chatId?: number, modelId?: number, agentId?: number, filters?: any[]) {
return axios.post<Result<ParseDataType>>(`${prefix}/chat/query/parse`, {
return axios.post<ParseDataType>(`${prefix}/chat/query/parse`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
@@ -38,7 +38,7 @@ export function chatParse(queryText: string, chatId?: number, modelId?: number,
}
export function chatExecute(queryText: string, chatId: number, parseInfo: ChatContextType ) {
return axios.post<Result<MsgDataType>>(`${prefix}/chat/query/execute`, {
return axios.post<MsgDataType>(`${prefix}/chat/query/execute`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
queryId: parseInfo.queryId,
@@ -47,7 +47,7 @@ export function chatExecute(queryText: string, chatId: number, parseInfo: ChatC
}
export function switchEntity(entityId: string, modelId?: number, chatId?: number) {
return axios.post<Result<any>>(`${prefix}/chat/query/switchQuery`, {
return axios.post<any>(`${prefix}/chat/query/switchQuery`, {
queryText: entityId,
modelId,
chatId: chatId || DEFAULT_CHAT_ID,
@@ -55,46 +55,46 @@ export function switchEntity(entityId: string, modelId?: number, chatId?: number
}
export function queryData(chatContext: Partial<ChatContextType>) {
return axios.post<Result<MsgDataType>>(`${prefix}/chat/query/queryData`, chatContext);
return axios.post<MsgDataType>(`${prefix}/chat/query/queryData`, chatContext);
}
export function queryContext(queryText: string, chatId?: number) {
return axios.post<Result<ChatContextType>>(`${prefix}/chat/query/queryContext`, {
return axios.post<ChatContextType>(`${prefix}/chat/query/queryContext`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
});
}
export function getHistoryMsg(current: number, chatId: number = DEFAULT_CHAT_ID, pageSize: number = 10) {
return axios.post<Result<HistoryType>>(`${prefix}/chat/manage/pageQueryInfo?chatId=${chatId}`, {
return axios.post<HistoryType>(`${prefix}/chat/manage/pageQueryInfo?chatId=${chatId}`, {
current,
pageSize,
});
}
export function saveConversation(chatName: string) {
return axios.post<Result<any>>(`${prefix}/chat/manage/save?chatName=${chatName}`);
return axios.post<any>(`${prefix}/chat/manage/save?chatName=${chatName}`);
}
export function getAllConversations() {
return axios.get<Result<any>>(`${prefix}/chat/manage/getAll`);
return axios.get<any>(`${prefix}/chat/manage/getAll`);
}
export function queryEntities(entityId: string | number, modelId: number) {
return axios.post<Result<any>>(`${prefix}/chat/query/choice`, {
return axios.post<any>(`${prefix}/chat/query/choice`, {
entityId,
modelId,
});
}
export function updateQAFeedback(questionId: number, score: number) {
return axios.post<Result<any>>(`${prefix}/chat/manage/updateQAFeedback?id=${questionId}&score=${score}&feedback=`);
return axios.post<any>(`${prefix}/chat/manage/updateQAFeedback?id=${questionId}&score=${score}&feedback=`);
}
export function queryDrillDownDimensions(modelId: number) {
return axios.get<Result<{ dimensions: DrillDownDimensionType[] }>>(`${prefix}/chat/recommend/metric/${modelId}`);
return axios.get<{ dimensions: DrillDownDimensionType[] }>(`${prefix}/chat/recommend/metric/${modelId}`);
}
export function queryDimensionValues(modelId: number, bizName: string, value: string) {
return axios.post<Result<any>>(`${prefix}/chat/query/queryDimensionValue`, { modelId, bizName, value});
return axios.post<any>(`${prefix}/chat/query/queryDimensionValue`, { modelId, bizName, value});
}