Files
DB-GPT/web/components/models_evaluation/context/EvaluationContext.tsx
alanchen 368f42227e feat(benchmark): Support Falcon Text2SQL Datasets LLM benchmark (#2918)
Co-authored-by: yaoyifan-yyf <yaoyifan.yyf@antgroup.com>
Co-authored-by: alan.cl <alan.cl@antgroup.com>
Co-authored-by: iterminatorheart <123625928+iterminatorheart@users.noreply.github.com>
Co-authored-by: VLADIMIR KOBZEV <vladimir.kobzev@improvado.io>
Co-authored-by: Aries-ckt <916701291@qq.com>
Co-authored-by: xiandu.wl <xiandu.wl@antgroup.com>
2025-10-23 14:26:36 +08:00

46 lines
1.1 KiB
TypeScript

import React, { createContext, useContext } from 'react';
import { useEvaluationList } from '../hooks/useEvaluationList';
interface EvaluationContextType {
refresh: () => void;
data: any;
loading: boolean;
getModelsEvaluation: (page?: number, pageSize?: number) => void;
}
const EvaluationContext = createContext<EvaluationContextType | undefined>(undefined);
interface EvaluationProviderProps {
children: React.ReactNode;
filterValue?: string;
type?: string;
}
export const EvaluationProvider: React.FC<EvaluationProviderProps> = ({ children, filterValue = '', type = 'all' }) => {
const { data, loading, getModelsEvaluation, refresh } = useEvaluationList({
filterValue,
type,
});
return (
<EvaluationContext.Provider
value={{
refresh,
data,
loading,
getModelsEvaluation,
}}
>
{children}
</EvaluationContext.Provider>
);
};
export const useEvaluation = () => {
const context = useContext(EvaluationContext);
if (context === undefined) {
throw new Error('useEvaluation must be used within an EvaluationProvider');
}
return context;
};