Model filter on logs (#11048)

* add model filter

* remove calling all models
This commit is contained in:
tanjiro
2025-05-22 23:31:43 +09:00
committed by GitHub
parent dd4a65b83a
commit 1c652b67b6
3 changed files with 3 additions and 32 deletions
@@ -88,6 +88,7 @@ const FilterComponent: React.FC<FilterComponentProps> = ({
"Key Alias",
"User ID",
"Key Hash",
"Model"
];
return (
@@ -226,7 +226,6 @@ export default function SpendLogsTable({
filteredLogs,
allTeams: hookAllTeams,
allKeyAliases,
allModels,
handleFilterChange,
handleFilterReset
} = useLogFilterLogic({
@@ -408,17 +407,7 @@ export default function SpendLogsTable({
{
name: 'Model',
label: 'Model',
isSearchable: true,
searchFn: async (searchText: string) => {
if (!allModels || allModels.length === 0) return [];
const filtered = allModels.filter((model: string) => {
return model.toLowerCase().includes(searchText.toLowerCase());
});
return filtered.map((model: string) => ({
label: model,
value: model
}));
}
isSearchable: false,
},
{
name: 'Key Alias',
@@ -440,7 +429,7 @@ export default function SpendLogsTable({
name: 'Key Hash',
label: 'Key Hash',
isSearchable: false,
}
},
]
// When a session is selected, render the SessionView component
@@ -198,24 +198,6 @@ export function useLogFilterLogic({
enabled: !!accessToken,
});
const { data: allModels = [] } = useQuery<string[], Error>({
queryKey: ['allModels', accessToken, userID, userRole],
queryFn: async () => {
if (!accessToken || !userID || !userRole) return [];
const response = await modelAvailableCall(
accessToken,
userID,
userRole,
false, // return_wildcard_routes
null // teamID
);
return response.data.map((model: { id: string }) => model.id);
},
enabled: !!accessToken && !!userID && !!userRole,
});
// Update filters state
const handleFilterChange = (newFilters: Partial<LogFilterState>) => {
setFilters(prev => {
@@ -252,7 +234,6 @@ export function useLogFilterLogic({
filteredLogs,
allKeyAliases,
allTeams,
allModels,
handleFilterChange,
handleFilterReset,
};