This commit is contained in:
Timothy Jaeryang Baek 2025-02-11 22:33:03 -08:00
parent afe92fd227
commit 153413dc54

View File

@ -101,6 +101,17 @@
} }
}; };
const updateDirectAPIHandler = async () => {
const res = await setDirectApiConfig(localStorage.token, directApiConfig).catch((error) => {
toast.error(`${error}`);
});
if (res) {
toast.success($i18n.t('Direct API settings updated'));
await models.set(await getModels());
}
};
const addOpenAIConnectionHandler = async (connection) => { const addOpenAIConnectionHandler = async (connection) => {
OPENAI_API_BASE_URLS = [...OPENAI_API_BASE_URLS, connection.url]; OPENAI_API_BASE_URLS = [...OPENAI_API_BASE_URLS, connection.url];
OPENAI_API_KEYS = [...OPENAI_API_KEYS, connection.key]; OPENAI_API_KEYS = [...OPENAI_API_KEYS, connection.key];
@ -180,8 +191,7 @@
const submitHandler = async () => { const submitHandler = async () => {
updateOpenAIHandler(); updateOpenAIHandler();
updateOllamaHandler(); updateOllamaHandler();
updateDirectAPIHandler();
setDirectApiConfig(localStorage.token, directApiConfig);
dispatch('save'); dispatch('save');
}; };
@ -353,7 +363,7 @@
<Switch <Switch
bind:state={directApiConfig.ENABLE_DIRECT_API} bind:state={directApiConfig.ENABLE_DIRECT_API}
on:change={async () => { on:change={async () => {
updateOpenAIHandler(); updateDirectAPIHandler();
}} }}
/> />
</div> </div>