MCPcopy Create free account
hub / github.com/Icecubesaad/OpenLLM-Studio / ModelWizard

Function ModelWizard

src/components/ModelWizard.tsx:25–744  ·  view source on GitHub ↗
({ onClose }: ModelWizardProps)

Source from the content-addressed store, hash-verified

23}
24
25export function ModelWizard({ onClose }: ModelWizardProps) {
26 const [step, setStep] = useState(1);
27 const [useCase, setUseCase] = useState<'coding' | 'chat' | 'agents'>('chat');
28 const [recommendations, setRecommendations] = useState<ModelRecommendation[]>([]);
29 const [selectedModel, setSelectedModel] = useState<ModelRecommendation | null>(null);
30 const [availableFiles, setAvailableFiles] = useState<HfModelFile[]>([]);
31 const [selectedFile, setSelectedFile] = useState<HfModelFile | null>(null);
32 const [loadingRecs, setLoadingRecs] = useState(false);
33 const [recError, setRecError] = useState<string | null>(null);
34 const [loadingFiles, setLoadingFiles] = useState(false);
35 const [filesError, setFilesError] = useState<string | null>(null);
36 const [downloading, setDownloading] = useState(false);
37 const [downloadProgress, setDownloadProgress] = useState<DownloadProgress | null>(null);
38 const [activeDownloadModelName, setActiveDownloadModelName] = useState<string | null>(null);
39 const [wizardStage, setWizardStage] = useState<string | null>(null);
40 const { hardwareInfo, isDetecting, redetect } = useHardwareInfo();
41 const { openRouterApiKey, claudeApiKey, openAiApiKey, recommendationApiKey, hfToken } = useAppStore();
42 const hasAnyApiKey = !!(openRouterApiKey || recommendationApiKey || claudeApiKey || openAiApiKey);
43 const recommendationRequestRef = useRef(0);
44 const filesRequestRef = useRef(0);
45 const lastAutoFetchKeyRef = useRef<string | null>(null);
46
47 const useCaseDescriptions = {
48 coding: 'Optimized for code generation, refactoring, and technical tasks',
49 chat: 'Best for conversational AI and general-purpose interactions',
50 agents: 'Specialized for tool-calling and autonomous task execution',
51 };
52
53 const availableMemory = useMemo(
54 () => hardwareInfo ? Math.max(hardwareInfo.ram_gb, hardwareInfo.vram_gb) : 8,
55 [hardwareInfo],
56 );
57
58 const recommendedFilename = useMemo(() => {
59 if (!selectedModel || availableFiles.length === 0) {
60 return null;
61 }
62
63 return (
64 availableFiles.find((file) => file.filename === selectedModel.filename)?.filename
65 || availableFiles.find((file) => file.quantization === selectedModel.quantization)?.filename
66 || availableFiles[0]?.filename
67 || null
68 );
69 }, [availableFiles, selectedModel]);
70
71 useEffect(() => {
72 const autoFetchKey = step === 3 && hardwareInfo
73 ? `${useCase}:${hardwareInfo.ram_gb}:${hardwareInfo.vram_gb}:${hasAnyApiKey}`
74 : null;
75
76 if (
77 step === 3
78 && hardwareInfo
79 && recommendations.length === 0
80 && !loadingRecs
81 && hasAnyApiKey
82 && autoFetchKey

Callers

nothing calls this directly

Calls 7

useHardwareInfoFunction · 0.90
getHfModelFilesFunction · 0.90
listenToWizardStatusFunction · 0.90
fetchRecommendationsFunction · 0.85
formatFileSizeGbFunction · 0.85
getQuantQualityLabelFunction · 0.85
setupListenerFunction · 0.70

Tested by

no test coverage detected