fix: usage filter
This commit is contained in:
@@ -293,6 +293,10 @@
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.items-center {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.color-white-tertiary {
|
.color-white-tertiary {
|
||||||
color: var(--color-white-tertiary);
|
color: var(--color-white-tertiary);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ const DailyUsage: React.FC<DailyUsageProps> = (props) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: summary.models_called.toString(),
|
label: summary.models_called.toString(),
|
||||||
value: 'Models called',
|
value: 'Models used',
|
||||||
color: baseColorMap.baseR2,
|
color: baseColorMap.baseR2,
|
||||||
iconType: 'roundRect'
|
iconType: 'roundRect'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
export const groupByOptions = [
|
export const groupByOptions = [
|
||||||
|
{
|
||||||
|
value: '',
|
||||||
|
label: 'None'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: 'model',
|
value: 'model',
|
||||||
label: 'Model'
|
label: 'Model'
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ export type BreakdownItem = UsageFilterItem & {
|
|||||||
models_called: number;
|
models_called: number;
|
||||||
api_keys_used: number;
|
api_keys_used: number;
|
||||||
last_active: string;
|
last_active: string;
|
||||||
|
provider_type: string;
|
||||||
|
provider_name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UsageMeta {
|
export interface UsageMeta {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// columns.ts
|
// columns.ts
|
||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import { tableSorter } from '@/config/settings';
|
import { tableSorter } from '@/config/settings';
|
||||||
|
import ProviderLogo from '@/pages/maas-provider/components/provider-logo';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { BreakdownItem as ListItem } from '../config/types';
|
import { BreakdownItem as ListItem } from '../config/types';
|
||||||
@@ -31,16 +32,6 @@ const useModelsColumns = (): Array<{
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'Provider',
|
|
||||||
dataIndex: 'provider',
|
|
||||||
key: 'provider',
|
|
||||||
render: (text: string, record: ListItem) => (
|
|
||||||
<AutoTooltip ghost style={{ maxWidth: 400 }}>
|
|
||||||
{text || '-'}
|
|
||||||
</AutoTooltip>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Cluster',
|
title: 'Cluster',
|
||||||
dataIndex: 'cluster_name',
|
dataIndex: 'cluster_name',
|
||||||
@@ -50,6 +41,21 @@ const useModelsColumns = (): Array<{
|
|||||||
<AutoTooltip ghost>{text || '-'}</AutoTooltip>
|
<AutoTooltip ghost>{text || '-'}</AutoTooltip>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Provider',
|
||||||
|
dataIndex: 'provider_name',
|
||||||
|
key: 'provider_name',
|
||||||
|
render: (text: string, record: ListItem) => (
|
||||||
|
<span className="flex-center gap-8">
|
||||||
|
<ProviderLogo provider={record.provider_type || 'deployments'} />
|
||||||
|
<AutoTooltip ghost style={{ maxWidth: 400 }}>
|
||||||
|
{text ||
|
||||||
|
(!record.provider_type &&
|
||||||
|
intl.formatMessage({ id: 'menu.models.deployment' }))}
|
||||||
|
</AutoTooltip>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Input Tokens',
|
title: 'Input Tokens',
|
||||||
dataIndex: 'input_tokens',
|
dataIndex: 'input_tokens',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { exportJsonToExcel } from '@/utils/excel-reader';
|
import { exportJsonToExcel } from '@/utils/excel-reader';
|
||||||
import { useModel } from '@@/plugin-model';
|
import { useModel } from '@@/plugin-model';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import _ from 'lodash';
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import BreakdownTabs from './components/breakdown-tabs';
|
import BreakdownTabs from './components/breakdown-tabs';
|
||||||
import DailyUsage from './components/daily-usage';
|
import DailyUsage from './components/daily-usage';
|
||||||
@@ -134,6 +135,10 @@ const Usage: React.FC = () => {
|
|||||||
currentSelectedFilters = commonFilters,
|
currentSelectedFilters = commonFilters,
|
||||||
currentChartFilters = chartFilters
|
currentChartFilters = chartFilters
|
||||||
) => {
|
) => {
|
||||||
|
const filteredChartFilters = _.pickBy(
|
||||||
|
currentChartFilters,
|
||||||
|
(value: string) => value
|
||||||
|
);
|
||||||
fetchTimeSeriesData({
|
fetchTimeSeriesData({
|
||||||
...currentChartFilters,
|
...currentChartFilters,
|
||||||
start_date: currentSelectedFilters.start_date,
|
start_date: currentSelectedFilters.start_date,
|
||||||
@@ -174,6 +179,10 @@ const Usage: React.FC = () => {
|
|||||||
fetchData(commonFilters, { ...chartFilters, [type]: value });
|
fetchData(commonFilters, { ...chartFilters, [type]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
fetchData(commonFilters, chartFilters);
|
||||||
|
};
|
||||||
|
|
||||||
console.log('timeSeriesData:', timeSeriesData);
|
console.log('timeSeriesData:', timeSeriesData);
|
||||||
|
|
||||||
const handleOnExportChart = () => {
|
const handleOnExportChart = () => {
|
||||||
@@ -228,7 +237,7 @@ const Usage: React.FC = () => {
|
|||||||
modelOptions={metaData?.models || []}
|
modelOptions={metaData?.models || []}
|
||||||
userOptions={metaData?.users || []}
|
userOptions={metaData?.users || []}
|
||||||
apiKeyOptions={metaData?.api_keys || []}
|
apiKeyOptions={metaData?.api_keys || []}
|
||||||
handleSearch={fetchData}
|
handleSearch={handleSearch}
|
||||||
onScopeChange={handleScopeChange}
|
onScopeChange={handleScopeChange}
|
||||||
onDateChange={handleDateChange}
|
onDateChange={handleDateChange}
|
||||||
onModelsChange={(value) => handleFilterChange('models', value)}
|
onModelsChange={(value) => handleFilterChange('models', value)}
|
||||||
|
|||||||
Reference in New Issue
Block a user