(feature)(webapp) modify QL to SQL (#354)

This commit is contained in:
williamhliu
2023-11-10 09:36:50 +08:00
committed by GitHub
parent 63a526709d
commit bf3a111e55
10 changed files with 31 additions and 31 deletions

View File

@@ -71,9 +71,9 @@ export type EntityDimensionType = {
}
export type SqlInfoType = {
s2QL: string;
logicSql: string;
querySql: string;
s2SQL: string;
correctS2SQL: string;
querySQL: string;
}
export type ChatContextType = {

View File

@@ -130,14 +130,14 @@ const ParseTip: React.FC<Props> = ({
return (
<div className={`${prefixCls}-tip-content`}>
{!!agentType && queryMode !== 'LLM_S2QL' ? (
{!!agentType && queryMode !== 'LLM_S2SQL' ? (
<div className={`${prefixCls}-tip-item`}>
{agentType === 'plugin' ? '插件' : '内置'}
<span className={itemValueClass}>{agentName}</span>
</div>
) : (
<>
{(queryMode?.includes('ENTITY') || queryMode === 'LLM_S2QL') &&
{(queryMode?.includes('ENTITY') || queryMode === 'LLM_S2SQL') &&
typeof entityId === 'string' &&
!!entityAlias &&
!!entityName ? (
@@ -162,14 +162,14 @@ const ParseTip: React.FC<Props> = ({
</div>
</div>
)}
{['METRIC_GROUPBY', 'METRIC_ORDERBY', 'ENTITY_DETAIL', 'LLM_S2QL'].includes(
{['METRIC_GROUPBY', 'METRIC_ORDERBY', 'ENTITY_DETAIL', 'LLM_S2SQL'].includes(
queryMode!
) &&
fields &&
fields.length > 0 && (
<div className={`${prefixCls}-tip-item`}>
<div className={`${prefixCls}-tip-item-name`}>
{queryMode === 'LLM_S2QL'
{queryMode === 'LLM_S2SQL'
? nativeQuery
? '查询字段'
: '下钻维度'
@@ -275,7 +275,7 @@ const ParseTip: React.FC<Props> = ({
const tipNode = (
<div className={`${prefixCls}-tip`}>
{getTipNode()}
{!(!!agentType && queryMode !== 'LLM_S2QL') && getFiltersNode()}
{!(!!agentType && queryMode !== 'LLM_S2SQL') && getFiltersNode()}
</div>
);

View File

@@ -28,7 +28,7 @@ const SqlItem: React.FC<Props> = ({ integrateSystem, sqlInfo, sqlTimeCost }) =>
setSqlType('');
};
if (!sqlInfo.s2QL && !sqlInfo.logicSql && !sqlInfo.querySql) {
if (!sqlInfo.s2SQL && !sqlInfo.correctS2SQL && !sqlInfo.querySQL) {
return null;
}
@@ -49,37 +49,37 @@ const SqlItem: React.FC<Props> = ({ integrateSystem, sqlInfo, sqlTimeCost }) =>
)}
</div>
<div className={`${tipPrefixCls}-content-options`}>
{sqlInfo.s2QL && (
{sqlInfo.s2SQL && (
<div
className={`${tipPrefixCls}-content-option ${
sqlType === 's2QL' ? `${tipPrefixCls}-content-option-active` : ''
sqlType === 's2SQL' ? `${tipPrefixCls}-content-option-active` : ''
}`}
onClick={() => {
setSqlType(sqlType === 's2QL' ? '' : 's2QL');
setSqlType(sqlType === 's2SQL' ? '' : 's2SQL');
}}
>
S2QL
S2SQL
</div>
)}
{sqlInfo.logicSql && (
{sqlInfo.correctS2SQL && (
<div
className={`${tipPrefixCls}-content-option ${
sqlType === 'logicSql' ? `${tipPrefixCls}-content-option-active` : ''
sqlType === 'correctS2SQL' ? `${tipPrefixCls}-content-option-active` : ''
}`}
onClick={() => {
setSqlType(sqlType === 'logicSql' ? '' : 'logicSql');
setSqlType(sqlType === 'correctS2SQL' ? '' : 'correctS2SQL');
}}
>
S2QL
S2SQL
</div>
)}
{sqlInfo.querySql && (
{sqlInfo.querySQL && (
<div
className={`${tipPrefixCls}-content-option ${
sqlType === 'querySql' ? `${tipPrefixCls}-content-option-active` : ''
sqlType === 'querySQL' ? `${tipPrefixCls}-content-option-active` : ''
}`}
onClick={() => {
setSqlType(sqlType === 'querySql' ? '' : 'querySql');
setSqlType(sqlType === 'querySQL' ? '' : 'querySQL');
}}
>
SQL

View File

@@ -28,7 +28,7 @@ const MetricCard: React.FC<Props> = ({ data, loading, onApplyAuth }) => {
const prefixCls = `${PREFIX_CLS}-metric-card`;
const matricCardClass = classNames(prefixCls, {
[`${PREFIX_CLS}-metric-card-dsl`]: queryMode === 'LLM_S2QL',
[`${PREFIX_CLS}-metric-card-dsl`]: queryMode === 'LLM_S2SQL',
});
const [isNumber, setIsNumber] = useState(false);

View File

@@ -60,7 +60,7 @@ const ChatMsg: React.FC<Props> = ({ queryId, data, chartIndex, triggerResize })
const metricFields = columns.filter(item => item.showType === 'NUMBER');
const isDslMetricCard =
queryMode === 'LLM_S2QL' && singleData && metricFields.length === 1 && columns.length === 1;
queryMode === 'LLM_S2SQL' && singleData && metricFields.length === 1 && columns.length === 1;
const isMetricCard = (queryMode.includes('METRIC') || isDslMetricCard) && singleData;
@@ -210,7 +210,7 @@ const ChatMsg: React.FC<Props> = ({ queryId, data, chartIndex, triggerResize })
);
const isMultipleMetric =
(queryMode.includes('METRIC') || queryMode === 'LLM_S2QL') &&
(queryMode.includes('METRIC') || queryMode === 'LLM_S2SQL') &&
recommendMetrics?.length > 0 &&
queryColumns?.filter(column => column.showType === 'NUMBER').length === 1;