import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; import Prompts from './Prompts'; import { useDarkTheme } from '../hooks'; import Dropdown from '../components/Dropdown'; import { selectPrompt, setPrompt, setChunks, selectChunks, setTokenLimit, selectTokenLimit, setModalStateDeleteConv, } from '../preferences/preferenceSlice'; const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; const General: React.FC = () => { const themes = ['Light', 'Dark']; const languages = ['English']; const chunks = ['0', '2', '4', '6', '8', '10']; const token_limits = new Map([ [0, 'None'], [100, 'Low'], [1000, 'Medium'], [2000, 'Default'], [4000, 'High'], [1e9, 'Unlimited'], ]); const [prompts, setPrompts] = React.useState< { name: string; id: string; type: string }[] >([]); const selectedChunks = useSelector(selectChunks); const selectedTokenLimit = useSelector(selectTokenLimit); const [isDarkTheme, toggleTheme] = useDarkTheme(); const [selectedTheme, setSelectedTheme] = React.useState( isDarkTheme ? 'Dark' : 'Light', ); const dispatch = useDispatch(); const [selectedLanguage, setSelectedLanguage] = React.useState(languages[0]); const selectedPrompt = useSelector(selectPrompt); React.useEffect(() => { const fetchPrompts = async () => { try { const response = await fetch(`${apiHost}/api/get_prompts`); if (!response.ok) { throw new Error('Failed to fetch prompts'); } const promptsData = await response.json(); setPrompts(promptsData); } catch (error) { console.error(error); } }; fetchPrompts(); }, []); return (

Select Theme

{ setSelectedTheme(option); option !== selectedTheme && toggleTheme(); }} size="w-56" rounded="3xl" border="border" />

Select Language

Chunks processed per query

dispatch(setChunks(value))} size="w-56" rounded="3xl" border="border" />

Conversational history

({ value: value, description: desc, }))} selectedValue={{ value: selectedTokenLimit, description: token_limits.get(selectedTokenLimit) as string, }} onSelect={({ value, description, }: { value: number; description: string; }) => dispatch(setTokenLimit(value))} size="w-56" rounded="3xl" border="border" />
dispatch(setPrompt({ name: name, id: id, type: type })) } setPrompts={setPrompts} apiHost={apiHost} />

Delete all conversations

); }; export default General;