mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-17 16:02:14 +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:
@@ -5,21 +5,21 @@ import { useEffect, useState } from 'react';
|
||||
import { querySimilarQuestions } from '../../service';
|
||||
|
||||
type Props = {
|
||||
// similarQuestions: SimilarQuestionType[];
|
||||
queryText: string;
|
||||
agentId?: number;
|
||||
queryId?: number;
|
||||
similarQueries?: SimilarQuestionType[];
|
||||
defaultExpanded?: boolean;
|
||||
onSelectQuestion: (question: SimilarQuestionType) => void;
|
||||
};
|
||||
|
||||
const SimilarQuestions: React.FC<Props> = ({
|
||||
// similarQuestions,
|
||||
queryText,
|
||||
agentId,
|
||||
queryId,
|
||||
similarQueries,
|
||||
defaultExpanded,
|
||||
onSelectQuestion,
|
||||
}) => {
|
||||
const [similarQuestions, setSimilarQuestions] = useState<SimilarQuestionType[]>([]);
|
||||
const [similarQuestions, setSimilarQuestions] = useState<SimilarQuestionType[]>(
|
||||
similarQueries || []
|
||||
);
|
||||
const [expanded, setExpanded] = useState(defaultExpanded || false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
@@ -28,9 +28,9 @@ const SimilarQuestions: React.FC<Props> = ({
|
||||
|
||||
const initData = async () => {
|
||||
setLoading(true);
|
||||
const res = await querySimilarQuestions(queryText, agentId);
|
||||
const res = await querySimilarQuestions(queryId!);
|
||||
setLoading(false);
|
||||
setSimilarQuestions(res.data || []);
|
||||
setSimilarQuestions(res.data?.similarQueries || []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -97,7 +97,9 @@ const ChatItem: React.FC<Props> = ({
|
||||
data = res.data;
|
||||
tip = '';
|
||||
}
|
||||
setDataCache({ ...dataCache, [chatContext!.id!]: { tip, data } });
|
||||
if (chatContext) {
|
||||
setDataCache({ ...dataCache, [chatContext!.id!]: { tip, data } });
|
||||
}
|
||||
if (data) {
|
||||
setData(data);
|
||||
setExecuteTip('');
|
||||
@@ -356,9 +358,9 @@ const ChatItem: React.FC<Props> = ({
|
||||
)}
|
||||
{(parseTip !== '' || (executeMode && !executeLoading)) && integrateSystem !== 'c2' && (
|
||||
<SimilarQuestionItem
|
||||
queryText={msg || msgData?.queryText || ''}
|
||||
agentId={agentId}
|
||||
queryId={parseInfo?.queryId}
|
||||
defaultExpanded={parseTip !== '' || executeTip !== '' || integrateSystem === 'wiki'}
|
||||
similarQueries={data?.similarQueries}
|
||||
onSelectQuestion={onSelectQuestion}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -244,7 +244,7 @@
|
||||
&-tip-content-option-disabled {
|
||||
cursor: auto;
|
||||
|
||||
&:hover {
|
||||
&:hover {
|
||||
color: var(--text-color-secondary);
|
||||
border-color: var(--border-color-base);
|
||||
}
|
||||
@@ -414,12 +414,14 @@
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ant-select-selector, .ant-input-number-input {
|
||||
.ant-select-selector,
|
||||
.ant-input-number-input {
|
||||
background-color: #f5f8fb !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);
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -447,7 +449,7 @@
|
||||
margin-right: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
&-code {
|
||||
margin-top: 10px !important;
|
||||
padding: 6px 14px 8px !important;
|
||||
@@ -455,7 +457,7 @@
|
||||
border-radius: 4px !important;
|
||||
background: #f5f8fb !important;
|
||||
}
|
||||
|
||||
|
||||
&-copy-btn {
|
||||
position: absolute;
|
||||
top: 24px;
|
||||
|
||||
@@ -270,8 +270,7 @@ const ChatMsg: React.FC<Props> = ({ queryId, data, chartIndex, triggerResize })
|
||||
)}
|
||||
{existDrillDownDimension && (
|
||||
<DrillDownDimensions
|
||||
modelId={chatContext.modelId}
|
||||
metricId={activeMetricField?.id || defaultMetricField?.id}
|
||||
drillDownDimensions={data?.recommendedDimensions || []}
|
||||
drillDownDimension={drillDownDimension}
|
||||
secondDrillDownDimension={secondDrillDownDimension}
|
||||
originDimensions={chatContext.dimensions}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { CLS_PREFIX } from '../../common/constants';
|
||||
import { DrillDownDimensionType, FilterItemType } from '../../common/type';
|
||||
import { queryDrillDownDimensions } from '../../service';
|
||||
import DimensionSection from './DimensionSection';
|
||||
|
||||
type Props = {
|
||||
modelId: number;
|
||||
metricId?: number;
|
||||
drillDownDimensions: DrillDownDimensionType[];
|
||||
drillDownDimension?: DrillDownDimensionType;
|
||||
secondDrillDownDimension?: DrillDownDimensionType;
|
||||
originDimensions?: DrillDownDimensionType[];
|
||||
@@ -18,8 +16,7 @@ type Props = {
|
||||
const MAX_DIMENSION_COUNT = 20;
|
||||
|
||||
const DrillDownDimensions: React.FC<Props> = ({
|
||||
modelId,
|
||||
metricId,
|
||||
drillDownDimensions,
|
||||
drillDownDimension,
|
||||
secondDrillDownDimension,
|
||||
originDimensions,
|
||||
@@ -32,9 +29,8 @@ const DrillDownDimensions: React.FC<Props> = ({
|
||||
const prefixCls = `${CLS_PREFIX}-drill-down-dimensions`;
|
||||
|
||||
const initData = async () => {
|
||||
const res = await queryDrillDownDimensions(modelId, metricId);
|
||||
setDimensions(
|
||||
res.data.dimensions
|
||||
drillDownDimensions
|
||||
.filter(
|
||||
dimension =>
|
||||
!dimensionFilters?.some(filter => filter.name === dimension.name) &&
|
||||
|
||||
Reference in New Issue
Block a user