diff --git a/app/components/Models.tsx b/app/components/Models.tsx index 9d1bf92..acf6900 100644 --- a/app/components/Models.tsx +++ b/app/components/Models.tsx @@ -1,8 +1,6 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; const Models: React.FC = () => { - const [selectedModel, setSelectedModel] = useState('Offline Fast'); - const modelOptions = [ 'Offline Fast', 'Offline Fast (FOSS)', @@ -18,14 +16,25 @@ const Models: React.FC = () => { 'Online Expensive (Google)', ]; + const [selectedModel, setSelectedModel] = useState(() => { + // Load the selected model from localStorage on initial render + return localStorage.getItem('selectedModel') || 'Offline Fast'; + }); + const handleModelChange = (event: React.ChangeEvent) => { - setSelectedModel(event.target.value); + const newModel = event.target.value; + setSelectedModel(newModel); }; const isOfflineModel = (model: string) => { return model.includes('Offline'); }; + // Save selected model to localStorage whenever it changes + useEffect(() => { + localStorage.setItem('selectedModel', selectedModel); + }, [selectedModel]); + return (
@@ -69,31 +78,31 @@ const Models: React.FC = () => {