(feature)(chat-sdk) modify the method for obtaining similar questions and recommended drill-down dimensions; do not display assistant button when there is only one assistant (#514)

This commit is contained in:
williamhliu
2023-12-15 17:41:35 +08:00
committed by GitHub
parent 4dae84034e
commit 4b00c16eb7
9 changed files with 107 additions and 57 deletions

View File

@@ -1,17 +1,31 @@
import axios from './axiosInstance';
import { ChatContextType, DrillDownDimensionType, EntityInfoType, HistoryType, MsgDataType, ParseDataType, SearchRecommendItem } from '../common/type';
import {
ChatContextType,
DrillDownDimensionType,
EntityInfoType,
HistoryMsgItemType,
HistoryType,
MsgDataType,
ParseDataType,
SearchRecommendItem,
} from '../common/type';
import { isMobile } from '../utils/utils';
const DEFAULT_CHAT_ID = 0;
const prefix = isMobile ? '/openapi' : '/api';
export function searchRecommend(queryText: string, chatId?: number, modelId?: number, agentId?: number) {
export function searchRecommend(
queryText: string,
chatId?: number,
modelId?: number,
agentId?: number
) {
return axios.post<SearchRecommendItem[]>(`${prefix}/chat/query/search`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
agentId
agentId,
});
}
@@ -20,30 +34,40 @@ export function chatQuery(queryText: string, chatId?: number, modelId?: number,
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
queryFilters: filters ? {
filters
} : undefined,
queryFilters: filters
? {
filters,
}
: undefined,
});
}
export function chatParse(queryText: string, chatId?: number, modelId?: number, agentId?: number, filters?: any[]) {
export function chatParse(
queryText: string,
chatId?: number,
modelId?: number,
agentId?: number,
filters?: any[]
) {
return axios.post<ParseDataType>(`${prefix}/chat/query/parse`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
modelId,
agentId,
queryFilters: filters ? {
filters
} : undefined,
queryFilters: filters
? {
filters,
}
: undefined,
});
}
export function chatExecute(queryText: string, chatId: number, parseInfo: ChatContextType ) {
export function chatExecute(queryText: string, chatId: number, parseInfo: ChatContextType) {
return axios.post<MsgDataType>(`${prefix}/chat/query/execute`, {
queryText,
chatId: chatId || DEFAULT_CHAT_ID,
queryId: parseInfo.queryId,
parseId: parseInfo.id
parseId: parseInfo.id,
});
}
@@ -59,13 +83,21 @@ export function queryData(chatContext: Partial<ChatContextType>) {
return axios.post<MsgDataType>(`${prefix}/chat/query/queryData`, chatContext);
}
export function getHistoryMsg(current: number, chatId: number = DEFAULT_CHAT_ID, pageSize: number = 10) {
export function getHistoryMsg(
current: number,
chatId: number = DEFAULT_CHAT_ID,
pageSize: number = 10
) {
return axios.post<HistoryType>(`${prefix}/chat/manage/pageQueryInfo?chatId=${chatId}`, {
current,
pageSize,
});
}
export function querySimilarQuestions(queryId: number) {
return axios.get<HistoryMsgItemType>(`${prefix}/chat/manage/getChatQuery/${queryId}`);
}
export function queryEntities(entityId: string | number, modelId: number) {
return axios.post<any>(`${prefix}/chat/query/choice`, {
entityId,
@@ -74,21 +106,35 @@ export function queryEntities(entityId: string | number, modelId: number) {
}
export function updateQAFeedback(questionId: number, score: number) {
return axios.post<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, metricId?: number) {
return axios.get<{ dimensions: DrillDownDimensionType[] }>(`${prefix}/chat/recommend/metric/${modelId}${metricId ? `?metricId=${metricId}` : ''}`);
export function queryDimensionValues(
modelId: number,
bizName: string,
agentId: number,
elementID: number,
value: string
) {
return axios.post<any>(`${prefix}/chat/query/queryDimensionValue`, {
modelId,
bizName,
agentId,
elementID,
value,
});
}
export function queryDimensionValues(modelId: number, bizName: string, agentId: number, elementID: number, value: string) {
return axios.post<any>(`${prefix}/chat/query/queryDimensionValue`, { modelId, bizName, agentId, elementID, value});
}
export function querySimilarQuestions(queryText: string, agentId?: number) {
return axios.get<any>(`${prefix}/chat/manage/getSolvedQuery?queryText=${queryText}&agentId=${agentId || 0}`);
}
// export function querySimilarQuestions(queryText: string, agentId?: number) {
// return axios.get<any>(
// `${prefix}/chat/manage/getSolvedQuery?queryText=${queryText}&agentId=${agentId || 0}`
// );
// }
export function queryEntityInfo(queryId: number, parseId: number) {
return axios.get<EntityInfoType>(`${prefix}/chat/query/getEntityInfo?queryId=${queryId}&parseId=${parseId}`)
return axios.get<EntityInfoType>(
`${prefix}/chat/query/getEntityInfo?queryId=${queryId}&parseId=${parseId}`
);
}