Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 1x 1x 1x 1x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 16x 20x 3x 3x 20x 3x 3x 20x 4x 4x 20x 3x 3x 16x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x | 'use client';
import { useModels } from '@web/providers/models';
import { useSystemSettings } from '@web/providers/system-settings';
import { useEffect, useMemo } from 'react';
interface SettingsValidationResult {
/** Whether all required settings are configured */
isComplete: boolean;
/** Whether the validation is still loading */
isLoading: boolean;
/** List of missing required settings */
missingSettings: string[];
/** Whether there are any models configured */
hasModels: boolean;
/** Whether there are text models available */
hasTextModels: boolean;
/** Whether there are embed models available */
hasEmbedModels: boolean;
/** Whether both text and embed models are available */
hasRequiredModelTypes: boolean;
}
/**
* Hook to validate system settings configuration.
* Checks if all required models are configured in settings.
*/
export function useSettingsValidation(): SettingsValidationResult {
const { settings, isLoading: isLoadingSettings } = useSystemSettings();
const { models, isLoading: isLoadingModels, setQueryParams } = useModels();
// Load all models
useEffect(() => {
setQueryParams({});
}, [setQueryParams]);
const isLoading = isLoadingSettings || isLoadingModels;
const hasModels = models.length > 0;
const hasTextModels = models.some((m) => m.model_type === 'text');
const hasEmbedModels = models.some((m) => m.model_type === 'embed');
const hasRequiredModelTypes = hasTextModels && hasEmbedModels;
const missingSettings = useMemo(() => {
if (isLoading) return [];
const missing: string[] = [];
// Always check all settings regardless of model types
if (!settings?.system_prompt_reflection_model_id) {
missing.push('System Prompt Reflection model');
}
if (!settings?.evaluation_generation_model_id) {
missing.push('Evaluation Generation model');
}
if (!settings?.judge_model_id) {
missing.push('Judge model');
}
if (!settings?.embedding_model_id) {
missing.push('Embedding model');
}
return missing;
}, [isLoading, settings]);
const isComplete =
!isLoading && hasRequiredModelTypes && missingSettings.length === 0;
return {
isComplete,
isLoading,
missingSettings,
hasModels,
hasTextModels,
hasEmbedModels,
hasRequiredModelTypes,
};
}
|