mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 04:27:39 +00:00
(feature)(webapp) modify view to dataSet
This commit is contained in:
@@ -5,14 +5,12 @@ import { AgentType, ModelType } from './type';
|
|||||||
const prefix = isMobile ? '/openapi' : '/api';
|
const prefix = isMobile ? '/openapi' : '/api';
|
||||||
|
|
||||||
export function saveConversation(chatName: string, agentId: number) {
|
export function saveConversation(chatName: string, agentId: number) {
|
||||||
return axios.post<any>(
|
return axios.post<any>(`${prefix}/chat/manage/save?chatName=${chatName}&agentId=${agentId}`);
|
||||||
`${prefix}/chat/manage/save?chatName=${chatName}&agentId=${agentId}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateConversationName(chatName: string, chatId: number = 0) {
|
export function updateConversationName(chatName: string, chatId: number = 0) {
|
||||||
return axios.post<any>(
|
return axios.post<any>(
|
||||||
`${prefix}/chat/manage/updateChatName?chatName=${chatName}&chatId=${chatId}`,
|
`${prefix}/chat/manage/updateChatName?chatName=${chatName}&chatId=${chatId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,12 +23,12 @@ export function getAllConversations(agentId?: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getModelList() {
|
export function getModelList() {
|
||||||
return axios.get<ModelType[]>(`${prefix}/chat/conf/modelList/view`);
|
return axios.get<ModelType[]>(`${prefix}/chat/conf/modelList/dataSet`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateQAFeedback(questionId: number, score: number) {
|
export function updateQAFeedback(questionId: number, score: number) {
|
||||||
return axios.post<any>(
|
return axios.post<any>(
|
||||||
`${prefix}/chat/manage/updateQAFeedback?id=${questionId}&score=${score}&feedback=`,
|
`${prefix}/chat/manage/updateQAFeedback?id=${questionId}&score=${score}&feedback=`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export type ModelInfoType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type EntityInfoType = {
|
export type EntityInfoType = {
|
||||||
viewInfo: ModelInfoType;
|
dataSetInfo: ModelInfoType;
|
||||||
dimensions: FieldType[];
|
dimensions: FieldType[];
|
||||||
metrics: FieldType[];
|
metrics: FieldType[];
|
||||||
entityId: number;
|
entityId: number;
|
||||||
@@ -51,6 +51,7 @@ export type FilterItemType = {
|
|||||||
operator?: string;
|
operator?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
value: any;
|
value: any;
|
||||||
|
entityName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModelType = {
|
export type ModelType = {
|
||||||
@@ -83,7 +84,7 @@ export type ChatContextType = {
|
|||||||
aggType: string;
|
aggType: string;
|
||||||
modelId: number;
|
modelId: number;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
view: ModelType;
|
dataSet: ModelType;
|
||||||
dateInfo: DateInfoType;
|
dateInfo: DateInfoType;
|
||||||
dimensions: FieldType[];
|
dimensions: FieldType[];
|
||||||
metrics: FieldType[];
|
metrics: FieldType[];
|
||||||
@@ -92,7 +93,7 @@ export type ChatContextType = {
|
|||||||
elementMatches: any[];
|
elementMatches: any[];
|
||||||
nativeQuery: boolean;
|
nativeQuery: boolean;
|
||||||
queryMode: string;
|
queryMode: string;
|
||||||
queryType: 'METRIC' | 'METRIC_TAG' | 'TAG' | 'OTHER';
|
queryType: 'METRIC' | 'METRIC_TAG' | 'ID' | 'TAG' | 'OTHER';
|
||||||
dimensionFilters: FilterItemType[];
|
dimensionFilters: FilterItemType[];
|
||||||
properties: any;
|
properties: any;
|
||||||
sqlInfo: SqlInfoType;
|
sqlInfo: SqlInfoType;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { AGG_TYPE_MAP, PREFIX_CLS } from '../../common/constants';
|
import { AGG_TYPE_MAP, PREFIX_CLS } from '../../common/constants';
|
||||||
import { ChatContextType, DateInfoType, EntityInfoType, FilterItemType } from '../../common/type';
|
import { ChatContextType, DateInfoType, EntityInfoType, FilterItemType } from '../../common/type';
|
||||||
import { Button, DatePicker, Tag } from 'antd';
|
import { Button, DatePicker } from 'antd';
|
||||||
import { CheckCircleFilled, ReloadOutlined } from '@ant-design/icons';
|
import { CheckCircleFilled, ReloadOutlined } from '@ant-design/icons';
|
||||||
import Loading from './Loading';
|
import Loading from './Loading';
|
||||||
import FilterItem from './FilterItem';
|
import FilterItem from './FilterItem';
|
||||||
@@ -89,7 +89,7 @@ const ParseTip: React.FC<Props> = ({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
modelId,
|
modelId,
|
||||||
view,
|
dataSet,
|
||||||
dimensions,
|
dimensions,
|
||||||
metrics,
|
metrics,
|
||||||
aggType,
|
aggType,
|
||||||
@@ -148,8 +148,8 @@ const ParseTip: React.FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={`${prefixCls}-tip-item`}>
|
<div className={`${prefixCls}-tip-item`}>
|
||||||
<div className={`${prefixCls}-tip-item-name`}>数据视图:</div>
|
<div className={`${prefixCls}-tip-item-name`}>数据集:</div>
|
||||||
<div className={itemValueClass}>{view?.name}</div>
|
<div className={itemValueClass}>{dataSet?.name}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(queryType === 'METRIC' || queryType === 'METRIC_TAG' || queryType === 'TAG') && (
|
{(queryType === 'METRIC' || queryType === 'METRIC_TAG' || queryType === 'TAG') && (
|
||||||
@@ -167,7 +167,7 @@ const ParseTip: React.FC<Props> = ({
|
|||||||
<div className={`${prefixCls}-tip-item`}>
|
<div className={`${prefixCls}-tip-item`}>
|
||||||
<div className={`${prefixCls}-tip-item-name`}>指标:</div>
|
<div className={`${prefixCls}-tip-item-name`}>指标:</div>
|
||||||
<div className={itemValueClass}>
|
<div className={itemValueClass}>
|
||||||
{queryType === 'METRIC' || queryType === 'METRIC_TAG'
|
{queryType === 'METRIC' || queryType === 'ID'
|
||||||
? metrics[0].name
|
? metrics[0].name
|
||||||
: metrics.map(metric => metric.name).join('、')}
|
: metrics.map(metric => metric.name).join('、')}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ const BarChart: React.FC<Props> = ({ data, triggerResize, loading, metricField,
|
|||||||
if (metricColumn && !metricColumn?.authorized) {
|
if (metricColumn && !metricColumn?.authorized) {
|
||||||
return (
|
return (
|
||||||
<NoPermissionChart
|
<NoPermissionChart
|
||||||
model={entityInfo?.viewInfo.name || ''}
|
model={entityInfo?.dataSetInfo.name || ''}
|
||||||
chartType="barChart"
|
chartType="barChart"
|
||||||
onApplyAuth={onApplyAuth}
|
onApplyAuth={onApplyAuth}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const MetricCard: React.FC<Props> = ({ data, loading, onApplyAuth }) => {
|
|||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
<div className={`${prefixCls}-indicator`}>
|
<div className={`${prefixCls}-indicator`}>
|
||||||
{indicatorColumn && !indicatorColumn?.authorized ? (
|
{indicatorColumn && !indicatorColumn?.authorized ? (
|
||||||
<ApplyAuth model={entityInfo?.viewInfo.name || ''} onApplyAuth={onApplyAuth} />
|
<ApplyAuth model={entityInfo?.dataSetInfo.name || ''} onApplyAuth={onApplyAuth} />
|
||||||
) : (
|
) : (
|
||||||
<div style={{ display: 'flex', alignItems: 'flex-end' }}>
|
<div style={{ display: 'flex', alignItems: 'flex-end' }}>
|
||||||
<div className={`${prefixCls}-indicator-value`}>
|
<div className={`${prefixCls}-indicator-value`}>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const MetricTrend: React.FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<MetricTrendChart
|
<MetricTrendChart
|
||||||
model={entityInfo?.viewInfo.name}
|
model={entityInfo?.dataSetInfo.name}
|
||||||
dateColumnName={dateColumnName}
|
dateColumnName={dateColumnName}
|
||||||
categoryColumnName={categoryColumnName}
|
categoryColumnName={categoryColumnName}
|
||||||
metricField={currentMetricField}
|
metricField={currentMetricField}
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ const Table: React.FC<Props> = ({ data, size, loading, onApplyAuth }) => {
|
|||||||
title: name || nameEn,
|
title: name || nameEn,
|
||||||
render: (value: string | number) => {
|
render: (value: string | number) => {
|
||||||
if (!authorized) {
|
if (!authorized) {
|
||||||
return <ApplyAuth model={entityInfo?.viewInfo.name || ''} onApplyAuth={onApplyAuth} />;
|
return (
|
||||||
|
<ApplyAuth model={entityInfo?.dataSetInfo.name || ''} onApplyAuth={onApplyAuth} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (dataFormatType === 'percent') {
|
if (dataFormatType === 'percent') {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createFromIconfontCN } from '@ant-design/icons';
|
import { createFromIconfontCN } from '@ant-design/icons';
|
||||||
|
|
||||||
const IconFont = createFromIconfontCN({
|
const IconFont = createFromIconfontCN({
|
||||||
scriptUrl: '//at.alicdn.com/t/c/font_4120566_8i352njvpoi.js',
|
scriptUrl: '//at.alicdn.com/t/c/font_4120566_7rwv3aw6wep.js',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default IconFont;
|
export default IconFont;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export function chatParse(
|
|||||||
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,
|
dataSetId: modelId,
|
||||||
agentId,
|
agentId,
|
||||||
queryFilters: filters
|
queryFilters: filters
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ const ToolModal: React.FC<Props> = ({ editTool, onSaveTool, onCancel }) => {
|
|||||||
node.title = node.name;
|
node.title = node.name;
|
||||||
node.value = node.type === 'DOMAIN' ? `DOMAIN_${node.id}` : node.id;
|
node.value = node.type === 'DOMAIN' ? `DOMAIN_${node.id}` : node.id;
|
||||||
node.checkable =
|
node.checkable =
|
||||||
node.type === 'VIEW' || (node.type === 'DOMAIN' && node.children?.length > 0);
|
node.type === 'DATASET' || (node.type === 'DOMAIN' && node.children?.length > 0);
|
||||||
});
|
});
|
||||||
setModelList([{ title: '默认', value: -1, type: 'VIEW' }, ...treeData]);
|
setModelList([{ title: '默认', value: -1, type: 'DATASET' }, ...treeData]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const initPluginList = async () => {
|
const initPluginList = async () => {
|
||||||
@@ -105,10 +105,10 @@ const ToolModal: React.FC<Props> = ({ editTool, onSaveTool, onCancel }) => {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
{(toolType === AgentToolTypeEnum.NL2SQL_RULE ||
|
{(toolType === AgentToolTypeEnum.NL2SQL_RULE ||
|
||||||
toolType === AgentToolTypeEnum.NL2SQL_LLM) && (
|
toolType === AgentToolTypeEnum.NL2SQL_LLM) && (
|
||||||
<FormItem name="viewIds" label="视图">
|
<FormItem name="dataSetIds" label="数据集">
|
||||||
<TreeSelect
|
<TreeSelect
|
||||||
treeData={modelList}
|
treeData={modelList}
|
||||||
placeholder="请选择视图"
|
placeholder="请选择数据集"
|
||||||
multiple
|
multiple
|
||||||
treeCheckable
|
treeCheckable
|
||||||
allowClear
|
allowClear
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function deleteAgent(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getModelList() {
|
export function getModelList() {
|
||||||
return request<Result<ModelType[]>>('/api/chat/conf/getDomainViewTree', {
|
return request<Result<ModelType[]>>('/api/chat/conf/getDomainDataSetTree', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export type ModelType = {
|
|||||||
parentId: number;
|
parentId: number;
|
||||||
name: string;
|
name: string;
|
||||||
bizName: string;
|
bizName: string;
|
||||||
type: 'DOMAIN' | 'VIEW';
|
type: 'DOMAIN' | 'DATASET';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MetricType = {
|
export type MetricType = {
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ const DetailModal: React.FC<Props> = ({ detail, onSubmit, onCancel }) => {
|
|||||||
node.title = node.name;
|
node.title = node.name;
|
||||||
node.value = node.type === 'DOMAIN' ? `DOMAIN_${node.id}` : node.id;
|
node.value = node.type === 'DOMAIN' ? `DOMAIN_${node.id}` : node.id;
|
||||||
node.checkable =
|
node.checkable =
|
||||||
node.type === 'VIEW' || (node.type === 'DOMAIN' && node.children?.length > 0);
|
node.type === 'DATASET' || (node.type === 'DOMAIN' && node.children?.length > 0);
|
||||||
});
|
});
|
||||||
setModelList([{ title: '默认', value: -1, type: 'VIEW' }, ...treeData]);
|
setModelList([{ title: '默认', value: -1, type: 'DATASET' }, ...treeData]);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -187,10 +187,10 @@ const DetailModal: React.FC<Props> = ({ detail, onSubmit, onCancel }) => {
|
|||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
>
|
>
|
||||||
<Form {...layout} form={form} style={{ maxWidth: 820 }}>
|
<Form {...layout} form={form} style={{ maxWidth: 820 }}>
|
||||||
<FormItem name="viewList" label="视图">
|
<FormItem name="dataSetList" label="数据集">
|
||||||
<TreeSelect
|
<TreeSelect
|
||||||
treeData={modelList}
|
treeData={modelList}
|
||||||
placeholder="请选择视图"
|
placeholder="请选择数据集"
|
||||||
multiple
|
multiple
|
||||||
treeCheckable
|
treeCheckable
|
||||||
allowClear
|
allowClear
|
||||||
@@ -243,64 +243,6 @@ const DetailModal: React.FC<Props> = ({ detail, onSubmit, onCancel }) => {
|
|||||||
<FormItem name="pattern" label="函数描述">
|
<FormItem name="pattern" label="函数描述">
|
||||||
<TextArea placeholder="请输入函数描述,多个描述换行分隔" allowClear />
|
<TextArea placeholder="请输入函数描述,多个描述换行分隔" allowClear />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
{/* <FormItem name="params" label="函数参数" hidden={pluginType === PluginTypeEnum.NL2SQL_LLM}>
|
|
||||||
<div className={styles.paramsSection}>
|
|
||||||
{functionParams.map((functionParam: FunctionParamFormItemType) => {
|
|
||||||
const { id, name, type, description } = functionParam;
|
|
||||||
return (
|
|
||||||
<div className={styles.filterRow} key={id}>
|
|
||||||
<Input
|
|
||||||
placeholder="参数名称"
|
|
||||||
value={name}
|
|
||||||
className={styles.filterParamName}
|
|
||||||
onChange={(e) => {
|
|
||||||
functionParam.name = e.target.value;
|
|
||||||
setFunctionParams([...functionParams]);
|
|
||||||
}}
|
|
||||||
allowClear
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
placeholder="参数类型"
|
|
||||||
options={[
|
|
||||||
{ label: '字符串', value: 'string' },
|
|
||||||
{ label: '整型', value: 'int' },
|
|
||||||
]}
|
|
||||||
className={styles.filterParamValueField}
|
|
||||||
allowClear
|
|
||||||
value={type}
|
|
||||||
onChange={(value) => {
|
|
||||||
functionParam.type = value;
|
|
||||||
setFunctionParams([...functionParams]);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
placeholder="参数描述"
|
|
||||||
value={description}
|
|
||||||
className={styles.filterParamValueField}
|
|
||||||
onChange={(e) => {
|
|
||||||
functionParam.description = e.target.value;
|
|
||||||
setFunctionParams([...functionParams]);
|
|
||||||
}}
|
|
||||||
allowClear
|
|
||||||
/>
|
|
||||||
<DeleteOutlined
|
|
||||||
onClick={() => {
|
|
||||||
setFunctionParams(functionParams.filter((item) => item.id !== id));
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setFunctionParams([...functionParams, { id: uuid() }]);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PlusOutlined />
|
|
||||||
新增函数参数
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</FormItem> */}
|
|
||||||
<FormItem name="exampleQuestions" label="示例问题">
|
<FormItem name="exampleQuestions" label="示例问题">
|
||||||
<div className={styles.paramsSection}>
|
<div className={styles.paramsSection}>
|
||||||
{examples.map((example) => {
|
{examples.map((example) => {
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ const PluginManage = () => {
|
|||||||
key: 'name',
|
key: 'name',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '视图',
|
title: '数据集',
|
||||||
dataIndex: 'viewList',
|
dataIndex: 'dataSetList',
|
||||||
key: 'viewList',
|
key: 'dataSetList',
|
||||||
width: 200,
|
width: 200,
|
||||||
render: (value: number[]) => {
|
render: (value: number[]) => {
|
||||||
if (value?.includes(-1)) {
|
if (value?.includes(-1)) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function deletePlugin(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getModelList() {
|
export function getModelList() {
|
||||||
return request<Result<ModelType[]>>('/api/chat/conf/getDomainViewTree', {
|
return request<Result<ModelType[]>>('/api/chat/conf/getDomainDataSetTree', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user