settings
This commit is contained in:
parent
a05b9d6a5f
commit
ddaf7638ac
1 changed files with 141 additions and 141 deletions
|
@ -1,11 +1,14 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
// Define the available model options
|
||||
const modelOptions = [
|
||||
const offlineModels = [
|
||||
'Offline Fast',
|
||||
'Offline Fast (FOSS)',
|
||||
'Offline Slow',
|
||||
'Offline Slow (FOSS)',
|
||||
];
|
||||
|
||||
const onlineModels = [
|
||||
'Online (La Plateforme)',
|
||||
'Online (FOSS) (La Plateforme)',
|
||||
'Online Cheap (OpenAI)',
|
||||
|
@ -16,48 +19,45 @@
|
|||
'Online Expensive (Google)',
|
||||
];
|
||||
|
||||
const fossModels = [
|
||||
'Offline Fast (FOSS)',
|
||||
'Offline Slow (FOSS)',
|
||||
'Online (FOSS) (La Plateforme)',
|
||||
];
|
||||
|
||||
// Define the properties passed to the Models component
|
||||
interface ModelsProps {
|
||||
selectedOption: string; // Privacy setting: "Offline", "AI Online", "None"
|
||||
}
|
||||
|
||||
const Models: React.FC<ModelsProps> = ({ selectedOption }) => {
|
||||
// State for the selected model, default is loaded from localStorage or defaults to 'Offline Fast'
|
||||
const [selectedModel, setSelectedModel] = useState<string>(() => {
|
||||
return localStorage.getItem('selectedModel') || 'Offline Fast';
|
||||
});
|
||||
|
||||
// Handle changes in the selected model from the dropdown
|
||||
const handleModelChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const newModel = event.target.value;
|
||||
setSelectedModel(newModel);
|
||||
};
|
||||
|
||||
// Utility function to check if a model is an offline model
|
||||
const isOfflineModel = (model: string) => {
|
||||
return model.includes('Offline');
|
||||
};
|
||||
const isOfflineModel = (model: string) => offlineModels.includes(model);
|
||||
const isOnlineModel = (model: string) => onlineModels.includes(model);
|
||||
const isFossModel = (model: string) => fossModels.includes(model);
|
||||
|
||||
// Utility function to check if a model is an online model
|
||||
const isOnlineModel = (model: string) => {
|
||||
return model.includes('Online');
|
||||
};
|
||||
|
||||
// Save selected model to localStorage whenever it changes
|
||||
useEffect(() => {
|
||||
localStorage.setItem('selectedModel', selectedModel);
|
||||
}, [selectedModel]);
|
||||
|
||||
// Filter models based on the selected privacy option (Offline, AI Online, None)
|
||||
const filteredModels = modelOptions.filter((model) => {
|
||||
if (selectedOption === 'Offline') {
|
||||
return !isOnlineModel(model); // Hide online models
|
||||
} else if (selectedOption === 'AI Online') {
|
||||
return !isOfflineModel(model); // Hide offline models
|
||||
} else {
|
||||
return true; // Show all models for "None"
|
||||
const filteredModels = (() => {
|
||||
switch (selectedOption) {
|
||||
case 'Offline':
|
||||
return offlineModels; // Show only offline models
|
||||
case 'AI Online':
|
||||
return onlineModels; // Show only online models
|
||||
default:
|
||||
return [...offlineModels, ...onlineModels]; // Show all models
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
return (
|
||||
<div className="model-background">
|
||||
|
|
Loading…
Reference in a new issue