fix(frontend): update ModelInfoResponse types to match backend structure
- Update TypeScript types to match flat backend response structure - Remove nested model_info and metrics objects - Remove label_config, use labels array and per_class_metrics array - Update all component references to use new structure - Generate default colors for prediction labels in CandleChart - Fix TypeScript type errors for nullable model_version - Remove accuracy/F1 metrics display (not in new response)
This commit is contained in:
parent
aa81d4f3d0
commit
5a7c901980
95 changed files with 326 additions and 63 deletions
|
|
@ -365,7 +365,7 @@ export default function Home() {
|
|||
setPredictionState((prev) => ({
|
||||
...prev,
|
||||
modelInfo: data,
|
||||
selectedLabels: new Set(data.label_config.map((l) => l.name)),
|
||||
selectedLabels: new Set(data.labels),
|
||||
error: null,
|
||||
}));
|
||||
return data;
|
||||
|
|
@ -382,9 +382,9 @@ export default function Home() {
|
|||
}, []);
|
||||
|
||||
// Generate cache key from chart, timerange, and model version
|
||||
const generateCacheKey = useCallback((chartId: number | null, modelVersion?: string) => {
|
||||
const generateCacheKey = useCallback((chartId: number | null, modelVersion?: string | null) => {
|
||||
if (!chartId) return null;
|
||||
const version = modelVersion || predictionState.modelInfo?.model_info.model_version || 'unknown';
|
||||
const version = modelVersion || predictionState.modelInfo?.model_version || 'unknown';
|
||||
return `${chartId}_${version}`;
|
||||
}, [predictionState.modelInfo]);
|
||||
|
||||
|
|
@ -392,12 +392,12 @@ export default function Home() {
|
|||
const fetchPredictions = useCallback(async (candles: any[]) => {
|
||||
if (!activeChartId || candles.length === 0) return;
|
||||
|
||||
const cacheKey = generateCacheKey(activeChartId, predictionState.modelInfo?.model_info.model_version);
|
||||
const cacheKey = generateCacheKey(activeChartId, predictionState.modelInfo?.model_version);
|
||||
|
||||
// Check cache first
|
||||
if (cacheKey && predictionCacheRef.current.has(cacheKey)) {
|
||||
const cached = predictionCacheRef.current.get(cacheKey)!;
|
||||
if (cached.modelVersion === predictionState.modelInfo?.model_info.model_version) {
|
||||
if (cached.modelVersion === predictionState.modelInfo?.model_version) {
|
||||
setPredictionState((prev) => ({
|
||||
...prev,
|
||||
spans: cached.spans,
|
||||
|
|
@ -562,7 +562,7 @@ export default function Home() {
|
|||
// Clear prediction cache when model version changes
|
||||
useEffect(() => {
|
||||
if (predictionState.modelInfo) {
|
||||
const currentVersion = predictionState.modelInfo.model_info.model_version;
|
||||
const currentVersion = predictionState.modelInfo.model_version;
|
||||
// Clear cache entries with different model versions
|
||||
const newCache = new Map();
|
||||
for (const [key, value] of predictionCacheRef.current.entries()) {
|
||||
|
|
@ -572,7 +572,7 @@ export default function Home() {
|
|||
}
|
||||
predictionCacheRef.current = newCache;
|
||||
}
|
||||
}, [predictionState.modelInfo?.model_info.model_version]);
|
||||
}, [predictionState.modelInfo?.model_version]);
|
||||
|
||||
// Health polling - check model status every 30 seconds when offline
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue