// import { useCallback, useEffect, useState } from 'react'; // import { // CTAButton, // DropdownSelect, // FormGroup, // FormInput, // FormLabel, // Input, // Spacer, // Stack, // useBoolean, // } from 'ohmy-ui'; // import { LoadingIndicator } from '@/ui/App'; // import { fetch } from '@/utils'; // interface SelectOption { // label: string; // value: string; // } // interface SettingsForm extends HTMLFormElement { // vectorDBUrl: HTMLInputElement; // vectorDBApiKey: HTMLInputElement; // llmProvider: HTMLInputElement; // llmModel: HTMLInputElement; // llmApiKey: HTMLInputElement; // llmEndpoint: HTMLInputElement; // llmApiVersion: HTMLInputElement; // } // const defaultProvider = { // label: 'OpenAI', // value: 'openai', // }; // const defaultModel = { // label: 'gpt-5-mini', // value: 'gpt-5-mini', // }; // export default function Settings({ onDone = () => {}, submitButtonText = 'Save' }) { // const [llmConfig, setLLMConfig] = useState<{ // apiKey: string; // model: string; // endpoint: string; // apiVersion: string; // provider: string; // }>(); // const [vectorDBConfig, setVectorDBConfig] = useState<{ // url: string; // apiKey: string; // provider: SelectOption; // providers: SelectOption[]; // }>(); // const { // value: isSaving, // setTrue: startSaving, // setFalse: stopSaving, // } = useBoolean(false); // const saveConfig = (event: React.FormEvent) => { // event.preventDefault(); // const formElements = event.currentTarget; // const newVectorConfig = { // provider: vectorDBConfig?.provider.value, // url: formElements.vectorDBUrl.value, // apiKey: formElements.vectorDBApiKey.value, // }; // const newLLMConfig = { // provider: formElements.llmProvider.value, // model: formElements.llmModel.value, // apiKey: formElements.llmApiKey.value, // endpoint: formElements.llmEndpoint.value, // apiVersion: formElements.llmApiVersion.value, // }; // startSaving(); // fetch('/v1/settings', { // method: 'POST', // headers: { // 'Content-Type': 'application/json', // }, // body: JSON.stringify({ // llm: newLLMConfig, // vectorDb: newVectorConfig, // }), // }) // .then(() => { // onDone(); // }) // .finally(() => stopSaving()); // }; // const handleVectorDBChange = useCallback((newVectorDBProvider: SelectOption) => { // setVectorDBConfig((config) => { // if (config?.provider !== newVectorDBProvider) { // return { // ...config, // providers: config?.providers || [], // provider: newVectorDBProvider, // url: '', // apiKey: '', // }; // } // return config; // }); // }, []); // useEffect(() => { // const fetchConfig = async () => { // const response = await fetch('/v1/settings'); // const settings = await response.json(); // if (!settings.llm.provider) { // settings.llm.provider = settings.llm.providers[0].value; // } // if (!settings.llm.model) { // settings.llm.model = settings.llm.models[settings.llm.provider][0].value; // } // if (!settings.vectorDb.provider) { // settings.vectorDb.provider = settings.vectorDb.providers[0]; // } else { // settings.vectorDb.provider = settings.vectorDb.providers.find((provider: SelectOption) => provider.value === settings.vectorDb.provider); // } // setLLMConfig(settings.llm); // setVectorDBConfig(settings.vectorDb); // }; // fetchConfig(); // }, []); // return ( //
// // // // LLM provider: // // // // // // LLM model: // // // // // // LLM endpoint: // // // // // // LLM API key: // // // // // // LLM API version: // // // // // // // // Vector DB provider: // // // // // // // // // // // // // {submitButtonText} // {isSaving && } // // // // // // //
// ) // }