Merge branch 'main' of interstellardevelopment.org:React-Group/interstellar_ai
|
@ -1,23 +1,37 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
const Models: React.FC = () => {
|
||||
const modelOptions = [
|
||||
'Offline Fast',
|
||||
'Offline Fast (FOSS)',
|
||||
'Offline Slow',
|
||||
'Offline Slow (FOSS)',
|
||||
'Online (La Plateforme)',
|
||||
'Online (FOSS) (La Plateforme)',
|
||||
'Online Cheap (OpenAI)',
|
||||
'Online Expensive (OpenAI)',
|
||||
'Online Cheap (Anthropic)',
|
||||
'Online Expensive (Anthropic)',
|
||||
'Online Cheap (Google)',
|
||||
'Online Expensive (Google)',
|
||||
];
|
||||
// Define the available model options
|
||||
const offlineModels = [
|
||||
'Offline Fast',
|
||||
'Offline Fast (FOSS)',
|
||||
'Offline Slow',
|
||||
'Offline Slow (FOSS)',
|
||||
];
|
||||
|
||||
const onlineModels = [
|
||||
'Online (La Plateforme)',
|
||||
'Online (FOSS) (La Plateforme)',
|
||||
'Online Cheap (OpenAI)',
|
||||
'Online Expensive (OpenAI)',
|
||||
'Online Cheap (Anthropic)',
|
||||
'Online Expensive (Anthropic)',
|
||||
'Online Cheap (Google)',
|
||||
'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 }) => {
|
||||
const [selectedModel, setSelectedModel] = useState<string>(() => {
|
||||
// Load the selected model from localStorage on initial render
|
||||
return localStorage.getItem('selectedModel') || 'Offline Fast';
|
||||
});
|
||||
|
||||
|
@ -26,31 +40,45 @@ const Models: React.FC = () => {
|
|||
setSelectedModel(newModel);
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
// Save selected model to localStorage whenever it changes
|
||||
useEffect(() => {
|
||||
localStorage.setItem('selectedModel', selectedModel);
|
||||
}, [selectedModel]);
|
||||
|
||||
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">
|
||||
<div className="models">
|
||||
<div className="titel">
|
||||
<h1>Different AI models</h1>
|
||||
<div className="title">
|
||||
<h3>Different AI models</h3>
|
||||
</div>
|
||||
|
||||
{/* Model Selection Dropdown */}
|
||||
<div className="model-dropdown">
|
||||
<label htmlFor="model-select">Select AI Model:</label>
|
||||
<select id="model-select" value={selectedModel} onChange={handleModelChange}>
|
||||
{modelOptions.map((model) => (
|
||||
{filteredModels.map((model) => (
|
||||
<option key={model} value={model}>
|
||||
{model}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Model Grid with Cards */}
|
||||
<div className="grid">
|
||||
<button className="code-model model-box">
|
||||
<div className="overlay">
|
||||
|
|
|
@ -6,7 +6,17 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
|
||||
const getItemFromLocalStorage = (key: string) => {
|
||||
const item = localStorage.getItem(key);
|
||||
return item ? JSON.parse(item) : false; // Default to false if item is null
|
||||
|
||||
if (item) {
|
||||
try {
|
||||
return JSON.parse(item); // Attempt to parse the item
|
||||
} catch (e) {
|
||||
console.error(`Error parsing JSON for key "${key}":`, e);
|
||||
return false; // Return false if parsing fails
|
||||
}
|
||||
}
|
||||
|
||||
return false; // Default to false if item is null or empty
|
||||
};
|
||||
|
||||
// Active section
|
||||
|
@ -24,8 +34,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT');
|
||||
|
||||
// Online AI and chat history settings
|
||||
// State declarations
|
||||
const [disableOnlineAI, setDisableOnlineAI] = useState(() => getItemFromLocalStorage('disableOnlineAI'));
|
||||
const [selectedOption, setSelectedOption] = useState('Offline'); // Default to 'Offline'
|
||||
const [disableChatHistory, setDisableChatHistory] = useState(() => getItemFromLocalStorage('disableChatHistory'));
|
||||
const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory'));
|
||||
const [openSourceMode, setOpenSourceMode] = useState(() => getItemFromLocalStorage('openSourceMode'));
|
||||
|
@ -58,7 +67,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
const [inputBorderColor, setInputBorderColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--input-border-color').trim());
|
||||
const [fontFamily, setFontFamily] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-family').trim());
|
||||
const [fontSize, setFontSize] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim());
|
||||
const [burgerMenu, setBurgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color:').trim());
|
||||
const [burgerMenu, setBurgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim());
|
||||
|
||||
// Theme selection
|
||||
const [selectedTheme, setSelectedTheme] = useState(() => localStorage.getItem('selectedTheme') || 'default');
|
||||
|
@ -69,162 +78,112 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
const [anthropic, setAnthropic] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-anthropic').trim());
|
||||
const [google, setGoogle] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-google').trim());
|
||||
|
||||
|
||||
// Effect hooks to update localStorage whenever any state changes
|
||||
useEffect(() => {
|
||||
localStorage.setItem('activeSection', activeSection);
|
||||
}, [activeSection]);
|
||||
const settings = {
|
||||
activeSection,
|
||||
preferredLanguage,
|
||||
preferredCurrency,
|
||||
dateFormat,
|
||||
timeFormat,
|
||||
timeZone,
|
||||
selectedOption,
|
||||
disableChatHistory,
|
||||
disableAIMemory,
|
||||
openSourceMode,
|
||||
newName,
|
||||
newEmail,
|
||||
newPassword,
|
||||
preferredMeasurement,
|
||||
backgroundColor,
|
||||
textColor,
|
||||
inputBackgroundColor,
|
||||
inputButtonColor,
|
||||
inputButtonHoverColor,
|
||||
userMessageBackgroundColor,
|
||||
userMessageTextColor,
|
||||
aiMessageBackgroundColor,
|
||||
aiMessageTextColor,
|
||||
buttonBackgroundColor,
|
||||
buttonHoverBackgroundColor,
|
||||
modelsBackgroundColor,
|
||||
historyBackgroundColor,
|
||||
leftPanelBackgroundColor,
|
||||
conversationBackgroundColor,
|
||||
popUpTextColor,
|
||||
inputBorderColor,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
burgerMenu,
|
||||
selectedTheme,
|
||||
laPlateforme,
|
||||
openAI,
|
||||
anthropic,
|
||||
google,
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('preferredLanguage', preferredLanguage);
|
||||
}, [preferredLanguage]);
|
||||
// Update local storage
|
||||
for (const [key, value] of Object.entries(settings)) {
|
||||
if (typeof value === 'boolean') {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
} else {
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
activeSection,
|
||||
preferredLanguage,
|
||||
preferredCurrency,
|
||||
dateFormat,
|
||||
timeFormat,
|
||||
timeZone,
|
||||
selectedOption,
|
||||
disableChatHistory,
|
||||
disableAIMemory,
|
||||
openSourceMode,
|
||||
newName,
|
||||
newEmail,
|
||||
newPassword,
|
||||
preferredMeasurement,
|
||||
backgroundColor,
|
||||
textColor,
|
||||
inputBackgroundColor,
|
||||
inputButtonColor,
|
||||
inputButtonHoverColor,
|
||||
userMessageBackgroundColor,
|
||||
userMessageTextColor,
|
||||
aiMessageBackgroundColor,
|
||||
aiMessageTextColor,
|
||||
buttonBackgroundColor,
|
||||
buttonHoverBackgroundColor,
|
||||
modelsBackgroundColor,
|
||||
historyBackgroundColor,
|
||||
leftPanelBackgroundColor,
|
||||
conversationBackgroundColor,
|
||||
popUpTextColor,
|
||||
inputBorderColor,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
burgerMenu,
|
||||
selectedTheme,
|
||||
laPlateforme,
|
||||
openAI,
|
||||
anthropic,
|
||||
google,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('preferredCurrency', preferredCurrency);
|
||||
}, [preferredCurrency]);
|
||||
useEffect(() => {
|
||||
const savedOption = localStorage.getItem('radioSelection');
|
||||
if (savedOption) {
|
||||
setSelectedOption(savedOption); // Set saved selection
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('dateFormat', dateFormat);
|
||||
}, [dateFormat]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('timeFormat', timeFormat);
|
||||
}, [timeFormat]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('timeZone', timeZone);
|
||||
}, [timeZone]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('disableOnlineAI', JSON.stringify(disableOnlineAI));
|
||||
}, [disableOnlineAI]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('disableChatHistory', JSON.stringify(disableChatHistory));
|
||||
}, [disableChatHistory]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('disableAIMemory', JSON.stringify(disableAIMemory));
|
||||
}, [disableAIMemory]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('openSourceMode', JSON.stringify(openSourceMode));
|
||||
}, [openSourceMode]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('newName', newName);
|
||||
}, [newName]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('newEmail', newEmail);
|
||||
}, [newEmail]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('newPassword', newPassword);
|
||||
}, [newPassword]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('preferredMeasurement', preferredMeasurement);
|
||||
}, [preferredMeasurement]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('backgroundColor', backgroundColor);
|
||||
}, [backgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('textColor', textColor);
|
||||
}, [textColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('inputBackgroundColor', inputBackgroundColor);
|
||||
}, [inputBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('inputButtonColor', inputButtonColor);
|
||||
}, [inputButtonColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('inputButtonHoverColor', inputButtonHoverColor);
|
||||
}, [inputButtonHoverColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('userMessageBackgroundColor', userMessageBackgroundColor);
|
||||
}, [userMessageBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('userMessageTextColor', userMessageTextColor);
|
||||
}, [userMessageTextColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('aiMessageBackgroundColor', aiMessageBackgroundColor);
|
||||
}, [aiMessageBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('aiMessageTextColor', aiMessageTextColor);
|
||||
}, [aiMessageTextColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('buttonBackgroundColor', buttonBackgroundColor);
|
||||
}, [buttonBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('buttonHoverBackgroundColor', buttonHoverBackgroundColor);
|
||||
}, [buttonHoverBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('modelsBackgroundColor', modelsBackgroundColor);
|
||||
}, [modelsBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('historyBackgroundColor', historyBackgroundColor);
|
||||
}, [historyBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('leftPanelBackgroundColor', leftPanelBackgroundColor);
|
||||
}, [leftPanelBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('conversationBackgroundColor', conversationBackgroundColor);
|
||||
}, [conversationBackgroundColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('popUpTextColor', popUpTextColor);
|
||||
}, [popUpTextColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('inputBorderColor', inputBorderColor);
|
||||
}, [inputBorderColor]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('fontFamily', fontFamily);
|
||||
}, [fontFamily]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('fontSize', fontSize);
|
||||
}, [fontSize]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('burgerMenu', burgerMenu);
|
||||
}, [fontSize]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('selectedTheme', selectedTheme);
|
||||
}, [selectedTheme]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('laPlateforme', laPlateforme);
|
||||
}, [laPlateforme]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('openAI', openAI);
|
||||
}, [openAI]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('anthropic', anthropic);
|
||||
}, [anthropic]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('google', google);
|
||||
}, [google]);
|
||||
const handleRadioChange = (newValue: string) => {
|
||||
setSelectedOption(newValue); // Update the state with the selected option
|
||||
localStorage.setItem('radioSelection', newValue); // Save the selection for persistence
|
||||
};
|
||||
|
||||
// Apply imported settings to the CSS variables
|
||||
const applySettings = (settings: any) => {
|
||||
|
@ -439,16 +398,33 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
return (
|
||||
<div className="settings-section">
|
||||
<h2>Privacy Settings</h2>
|
||||
|
||||
{/* AI Mode Radio Options */}
|
||||
<div className="settings-option">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={disableOnlineAI}
|
||||
onChange={() => setDisableOnlineAI(!disableOnlineAI)}
|
||||
/>
|
||||
Disable Online AI
|
||||
</label>
|
||||
<p>Disable Options:</p>
|
||||
<div className="slider">
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'Offline' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('Offline')} // Handle selection
|
||||
>
|
||||
Offline tools
|
||||
</div>
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'AI Online' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('AI Online')}
|
||||
>
|
||||
Online tools
|
||||
</div>
|
||||
<div
|
||||
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
|
||||
onClick={() => handleRadioChange('None')}
|
||||
>
|
||||
None
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Disable Chat History Checkbox */}
|
||||
<div className="settings-option">
|
||||
<label>
|
||||
<input
|
||||
|
@ -459,6 +435,8 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
Disable Chat History
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Disable AI Memory Checkbox */}
|
||||
<div className="settings-option">
|
||||
<label>
|
||||
<input
|
||||
|
@ -941,7 +919,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
dateFormat,
|
||||
timeFormat,
|
||||
timeZone,
|
||||
disableOnlineAI,
|
||||
selectedOption,
|
||||
disableChatHistory,
|
||||
disableAIMemory,
|
||||
openSourceMode,
|
||||
|
|
|
@ -160,3 +160,28 @@
|
|||
padding: 10px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.slider {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.slider-option {
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.slider-option.active {
|
||||
background-color: #007bff; /* Change to your active color */
|
||||
color: white;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
display: none; /* Hide the default radio buttons */
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
header{
|
||||
position: absolute;
|
||||
padding: 0 20px;
|
||||
top: 2em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 5em;
|
||||
|
|
Before Width: | Height: | Size: 555 KiB After Width: | Height: | Size: 392 KiB |
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.1 MiB |