mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(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:
@@ -311,10 +311,12 @@ const ChatFooter: ForwardRefRenderFunction<any, Props> = (
|
|||||||
<div>历史对话</div>
|
<div>历史对话</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={styles.toolItem} onClick={onOpenAgents}>
|
{agentList?.length > 1 && (
|
||||||
<IconFont type="icon-zhinengzhuli" className={styles.toolIcon} />
|
<div className={styles.toolItem} onClick={onOpenAgents}>
|
||||||
<div>智能助理</div>
|
<IconFont type="icon-zhinengzhuli" className={styles.toolIcon} />
|
||||||
</div>
|
<div>智能助理</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{!isMobile && (
|
{!isMobile && (
|
||||||
<div className={styles.toolItem} onClick={onOpenShowcase}>
|
<div className={styles.toolItem} onClick={onOpenShowcase}>
|
||||||
<IconFont type="icon-showcase" className={styles.toolIcon} />
|
<IconFont type="icon-showcase" className={styles.toolIcon} />
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ const Chat: ForwardRefRenderFunction<any, Props> = (
|
|||||||
msg: item.queryText,
|
msg: item.queryText,
|
||||||
parseInfos: item.parseInfos,
|
parseInfos: item.parseInfos,
|
||||||
parseTimeCost: item.parseTimeCost,
|
parseTimeCost: item.parseTimeCost,
|
||||||
msgData: item.queryResult,
|
msgData: { ...(item.queryResult || {}), similarQueries: item.similarQueries },
|
||||||
score: item.score,
|
score: item.score,
|
||||||
agentId: currentAgent?.id,
|
agentId: currentAgent?.id,
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ export type MsgDataType = {
|
|||||||
response: PluginResonseType;
|
response: PluginResonseType;
|
||||||
parseInfos?: ChatContextType[];
|
parseInfos?: ChatContextType[];
|
||||||
queryTimeCost?: number;
|
queryTimeCost?: number;
|
||||||
|
similarQueries: SimilarQuestionType[];
|
||||||
|
recommendedDimensions: DrillDownDimensionType[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum ParseStateEnum {
|
export enum ParseStateEnum {
|
||||||
@@ -220,6 +222,7 @@ export type HistoryMsgItemType = {
|
|||||||
createTime: string;
|
createTime: string;
|
||||||
feedback: string;
|
feedback: string;
|
||||||
score: number;
|
score: number;
|
||||||
|
similarQueries: SimilarQuestionType[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HistoryType = {
|
export type HistoryType = {
|
||||||
@@ -242,8 +245,8 @@ export type SendMsgParamsType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type SimilarQuestionType = {
|
export type SimilarQuestionType = {
|
||||||
// queryId: number;
|
queryId: number;
|
||||||
// parseId: number;
|
parseId: number;
|
||||||
queryText: string;
|
queryText: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,21 @@ import { useEffect, useState } from 'react';
|
|||||||
import { querySimilarQuestions } from '../../service';
|
import { querySimilarQuestions } from '../../service';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
// similarQuestions: SimilarQuestionType[];
|
queryId?: number;
|
||||||
queryText: string;
|
similarQueries?: SimilarQuestionType[];
|
||||||
agentId?: number;
|
|
||||||
defaultExpanded?: boolean;
|
defaultExpanded?: boolean;
|
||||||
onSelectQuestion: (question: SimilarQuestionType) => void;
|
onSelectQuestion: (question: SimilarQuestionType) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SimilarQuestions: React.FC<Props> = ({
|
const SimilarQuestions: React.FC<Props> = ({
|
||||||
// similarQuestions,
|
queryId,
|
||||||
queryText,
|
similarQueries,
|
||||||
agentId,
|
|
||||||
defaultExpanded,
|
defaultExpanded,
|
||||||
onSelectQuestion,
|
onSelectQuestion,
|
||||||
}) => {
|
}) => {
|
||||||
const [similarQuestions, setSimilarQuestions] = useState<SimilarQuestionType[]>([]);
|
const [similarQuestions, setSimilarQuestions] = useState<SimilarQuestionType[]>(
|
||||||
|
similarQueries || []
|
||||||
|
);
|
||||||
const [expanded, setExpanded] = useState(defaultExpanded || false);
|
const [expanded, setExpanded] = useState(defaultExpanded || false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
@@ -28,9 +28,9 @@ const SimilarQuestions: React.FC<Props> = ({
|
|||||||
|
|
||||||
const initData = async () => {
|
const initData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await querySimilarQuestions(queryText, agentId);
|
const res = await querySimilarQuestions(queryId!);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setSimilarQuestions(res.data || []);
|
setSimilarQuestions(res.data?.similarQueries || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -97,7 +97,9 @@ const ChatItem: React.FC<Props> = ({
|
|||||||
data = res.data;
|
data = res.data;
|
||||||
tip = '';
|
tip = '';
|
||||||
}
|
}
|
||||||
setDataCache({ ...dataCache, [chatContext!.id!]: { tip, data } });
|
if (chatContext) {
|
||||||
|
setDataCache({ ...dataCache, [chatContext!.id!]: { tip, data } });
|
||||||
|
}
|
||||||
if (data) {
|
if (data) {
|
||||||
setData(data);
|
setData(data);
|
||||||
setExecuteTip('');
|
setExecuteTip('');
|
||||||
@@ -356,9 +358,9 @@ const ChatItem: React.FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
{(parseTip !== '' || (executeMode && !executeLoading)) && integrateSystem !== 'c2' && (
|
{(parseTip !== '' || (executeMode && !executeLoading)) && integrateSystem !== 'c2' && (
|
||||||
<SimilarQuestionItem
|
<SimilarQuestionItem
|
||||||
queryText={msg || msgData?.queryText || ''}
|
queryId={parseInfo?.queryId}
|
||||||
agentId={agentId}
|
|
||||||
defaultExpanded={parseTip !== '' || executeTip !== '' || integrateSystem === 'wiki'}
|
defaultExpanded={parseTip !== '' || executeTip !== '' || integrateSystem === 'wiki'}
|
||||||
|
similarQueries={data?.similarQueries}
|
||||||
onSelectQuestion={onSelectQuestion}
|
onSelectQuestion={onSelectQuestion}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -244,7 +244,7 @@
|
|||||||
&-tip-content-option-disabled {
|
&-tip-content-option-disabled {
|
||||||
cursor: auto;
|
cursor: auto;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--text-color-secondary);
|
color: var(--text-color-secondary);
|
||||||
border-color: var(--border-color-base);
|
border-color: var(--border-color-base);
|
||||||
}
|
}
|
||||||
@@ -414,12 +414,14 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-select-selector, .ant-input-number-input {
|
.ant-select-selector,
|
||||||
|
.ant-input-number-input {
|
||||||
background-color: #f5f8fb !important;
|
background-color: #f5f8fb !important;
|
||||||
border-color: #ececec !important;
|
border-color: #ececec !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-select-selection-item, .ant-input-number-input {
|
.ant-select-selection-item,
|
||||||
|
.ant-input-number-input {
|
||||||
color: var(--chat-blue);
|
color: var(--chat-blue);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
@@ -447,7 +449,7 @@
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-code {
|
&-code {
|
||||||
margin-top: 10px !important;
|
margin-top: 10px !important;
|
||||||
padding: 6px 14px 8px !important;
|
padding: 6px 14px 8px !important;
|
||||||
@@ -455,7 +457,7 @@
|
|||||||
border-radius: 4px !important;
|
border-radius: 4px !important;
|
||||||
background: #f5f8fb !important;
|
background: #f5f8fb !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-copy-btn {
|
&-copy-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 24px;
|
top: 24px;
|
||||||
|
|||||||
@@ -270,8 +270,7 @@ const ChatMsg: React.FC<Props> = ({ queryId, data, chartIndex, triggerResize })
|
|||||||
)}
|
)}
|
||||||
{existDrillDownDimension && (
|
{existDrillDownDimension && (
|
||||||
<DrillDownDimensions
|
<DrillDownDimensions
|
||||||
modelId={chatContext.modelId}
|
drillDownDimensions={data?.recommendedDimensions || []}
|
||||||
metricId={activeMetricField?.id || defaultMetricField?.id}
|
|
||||||
drillDownDimension={drillDownDimension}
|
drillDownDimension={drillDownDimension}
|
||||||
secondDrillDownDimension={secondDrillDownDimension}
|
secondDrillDownDimension={secondDrillDownDimension}
|
||||||
originDimensions={chatContext.dimensions}
|
originDimensions={chatContext.dimensions}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { CLS_PREFIX } from '../../common/constants';
|
import { CLS_PREFIX } from '../../common/constants';
|
||||||
import { DrillDownDimensionType, FilterItemType } from '../../common/type';
|
import { DrillDownDimensionType, FilterItemType } from '../../common/type';
|
||||||
import { queryDrillDownDimensions } from '../../service';
|
|
||||||
import DimensionSection from './DimensionSection';
|
import DimensionSection from './DimensionSection';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
modelId: number;
|
drillDownDimensions: DrillDownDimensionType[];
|
||||||
metricId?: number;
|
|
||||||
drillDownDimension?: DrillDownDimensionType;
|
drillDownDimension?: DrillDownDimensionType;
|
||||||
secondDrillDownDimension?: DrillDownDimensionType;
|
secondDrillDownDimension?: DrillDownDimensionType;
|
||||||
originDimensions?: DrillDownDimensionType[];
|
originDimensions?: DrillDownDimensionType[];
|
||||||
@@ -18,8 +16,7 @@ type Props = {
|
|||||||
const MAX_DIMENSION_COUNT = 20;
|
const MAX_DIMENSION_COUNT = 20;
|
||||||
|
|
||||||
const DrillDownDimensions: React.FC<Props> = ({
|
const DrillDownDimensions: React.FC<Props> = ({
|
||||||
modelId,
|
drillDownDimensions,
|
||||||
metricId,
|
|
||||||
drillDownDimension,
|
drillDownDimension,
|
||||||
secondDrillDownDimension,
|
secondDrillDownDimension,
|
||||||
originDimensions,
|
originDimensions,
|
||||||
@@ -32,9 +29,8 @@ const DrillDownDimensions: React.FC<Props> = ({
|
|||||||
const prefixCls = `${CLS_PREFIX}-drill-down-dimensions`;
|
const prefixCls = `${CLS_PREFIX}-drill-down-dimensions`;
|
||||||
|
|
||||||
const initData = async () => {
|
const initData = async () => {
|
||||||
const res = await queryDrillDownDimensions(modelId, metricId);
|
|
||||||
setDimensions(
|
setDimensions(
|
||||||
res.data.dimensions
|
drillDownDimensions
|
||||||
.filter(
|
.filter(
|
||||||
dimension =>
|
dimension =>
|
||||||
!dimensionFilters?.some(filter => filter.name === dimension.name) &&
|
!dimensionFilters?.some(filter => filter.name === dimension.name) &&
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
import axios from './axiosInstance';
|
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';
|
import { isMobile } from '../utils/utils';
|
||||||
|
|
||||||
const DEFAULT_CHAT_ID = 0;
|
const DEFAULT_CHAT_ID = 0;
|
||||||
|
|
||||||
const prefix = isMobile ? '/openapi' : '/api';
|
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`, {
|
return axios.post<SearchRecommendItem[]>(`${prefix}/chat/query/search`, {
|
||||||
queryText,
|
queryText,
|
||||||
chatId: chatId || DEFAULT_CHAT_ID,
|
chatId: chatId || DEFAULT_CHAT_ID,
|
||||||
modelId,
|
modelId,
|
||||||
agentId
|
agentId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,30 +34,40 @@ export function chatQuery(queryText: string, chatId?: number, modelId?: number,
|
|||||||
queryText,
|
queryText,
|
||||||
chatId: chatId || DEFAULT_CHAT_ID,
|
chatId: chatId || DEFAULT_CHAT_ID,
|
||||||
modelId,
|
modelId,
|
||||||
queryFilters: filters ? {
|
queryFilters: filters
|
||||||
filters
|
? {
|
||||||
} : undefined,
|
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`, {
|
return axios.post<ParseDataType>(`${prefix}/chat/query/parse`, {
|
||||||
queryText,
|
queryText,
|
||||||
chatId: chatId || DEFAULT_CHAT_ID,
|
chatId: chatId || DEFAULT_CHAT_ID,
|
||||||
modelId,
|
modelId,
|
||||||
agentId,
|
agentId,
|
||||||
queryFilters: filters ? {
|
queryFilters: filters
|
||||||
filters
|
? {
|
||||||
} : undefined,
|
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`, {
|
return axios.post<MsgDataType>(`${prefix}/chat/query/execute`, {
|
||||||
queryText,
|
queryText,
|
||||||
chatId: chatId || DEFAULT_CHAT_ID,
|
chatId: chatId || DEFAULT_CHAT_ID,
|
||||||
queryId: parseInfo.queryId,
|
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);
|
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}`, {
|
return axios.post<HistoryType>(`${prefix}/chat/manage/pageQueryInfo?chatId=${chatId}`, {
|
||||||
current,
|
current,
|
||||||
pageSize,
|
pageSize,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function querySimilarQuestions(queryId: number) {
|
||||||
|
return axios.get<HistoryMsgItemType>(`${prefix}/chat/manage/getChatQuery/${queryId}`);
|
||||||
|
}
|
||||||
|
|
||||||
export function queryEntities(entityId: string | number, modelId: number) {
|
export function queryEntities(entityId: string | number, modelId: number) {
|
||||||
return axios.post<any>(`${prefix}/chat/query/choice`, {
|
return axios.post<any>(`${prefix}/chat/query/choice`, {
|
||||||
entityId,
|
entityId,
|
||||||
@@ -74,21 +106,35 @@ export function queryEntities(entityId: string | number, modelId: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateQAFeedback(questionId: number, score: 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) {
|
export function queryDimensionValues(
|
||||||
return axios.get<{ dimensions: DrillDownDimensionType[] }>(`${prefix}/chat/recommend/metric/${modelId}${metricId ? `?metricId=${metricId}` : ''}`);
|
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) {
|
// export function querySimilarQuestions(queryText: string, agentId?: number) {
|
||||||
return axios.post<any>(`${prefix}/chat/query/queryDimensionValue`, { modelId, bizName, agentId, elementID, value});
|
// 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) {
|
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}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user