This commit is contained in:
Timothy Jaeryang Baek
2026-08-17 00:51:04 -07:00
parent 6e468c5b95
commit 87d9b7e84e
3 changed files with 48 additions and 41 deletions
+8 -3
View File
@@ -188,6 +188,8 @@ type OpenAIConfigForm = {
url: string;
};
type OllamaConfigForm = OpenAIConfigForm;
type AzureOpenAIConfigForm = {
key: string;
url: string;
@@ -196,10 +198,13 @@ type AzureOpenAIConfigForm = {
type EmbeddingModelUpdateForm = {
openai_config?: OpenAIConfigForm;
ollama_config?: OllamaConfigForm;
azure_openai_config?: AzureOpenAIConfigForm;
embedding_engine: string;
embedding_model: string;
embedding_batch_size?: number;
RAG_EMBEDDING_ENGINE: string;
RAG_EMBEDDING_MODEL: string;
RAG_EMBEDDING_BATCH_SIZE?: number;
ENABLE_ASYNC_EMBEDDING?: boolean;
RAG_EMBEDDING_CONCURRENT_REQUESTS?: number;
};
export const updateEmbeddingConfig = async (token: string, payload: EmbeddingModelUpdateForm) => {
@@ -122,26 +122,33 @@
});
updateEmbeddingModelLoading = true;
const res = await updateEmbeddingConfig(localStorage.token, {
const payload: Parameters<typeof updateEmbeddingConfig>[1] = {
RAG_EMBEDDING_ENGINE: RAG_EMBEDDING_ENGINE,
RAG_EMBEDDING_MODEL: RAG_EMBEDDING_MODEL,
RAG_EMBEDDING_BATCH_SIZE: RAG_EMBEDDING_BATCH_SIZE,
ENABLE_ASYNC_EMBEDDING: ENABLE_ASYNC_EMBEDDING,
RAG_EMBEDDING_CONCURRENT_REQUESTS: RAG_EMBEDDING_CONCURRENT_REQUESTS,
ollama_config: {
RAG_EMBEDDING_CONCURRENT_REQUESTS: RAG_EMBEDDING_CONCURRENT_REQUESTS
};
if (RAG_EMBEDDING_ENGINE === 'ollama') {
payload.ollama_config = {
key: OllamaKey,
url: OllamaUrl
},
openai_config: {
};
} else if (RAG_EMBEDDING_ENGINE === 'openai') {
payload.openai_config = {
key: OpenAIKey,
url: OpenAIUrl
},
azure_openai_config: {
};
} else if (RAG_EMBEDDING_ENGINE === 'azure_openai') {
payload.azure_openai_config = {
key: AzureOpenAIKey,
url: AzureOpenAIUrl,
version: AzureOpenAIVersion
}
}).catch(async (error) => {
};
}
const res = await updateEmbeddingConfig(localStorage.token, payload).catch(async (error) => {
toast.error(`${error}`);
await setEmbeddingConfig();
return null;
@@ -300,15 +307,15 @@
ENABLE_ASYNC_EMBEDDING = embeddingConfig.ENABLE_ASYNC_EMBEDDING ?? true;
RAG_EMBEDDING_CONCURRENT_REQUESTS = embeddingConfig.RAG_EMBEDDING_CONCURRENT_REQUESTS ?? 0;
OpenAIKey = embeddingConfig.openai_config.key;
OpenAIUrl = embeddingConfig.openai_config.url;
OpenAIKey = embeddingConfig.openai_config.key ?? '';
OpenAIUrl = embeddingConfig.openai_config.url ?? '';
OllamaKey = embeddingConfig.ollama_config.key;
OllamaUrl = embeddingConfig.ollama_config.url;
OllamaKey = embeddingConfig.ollama_config.key ?? '';
OllamaUrl = embeddingConfig.ollama_config.url ?? '';
AzureOpenAIKey = embeddingConfig.azure_openai_config.key;
AzureOpenAIUrl = embeddingConfig.azure_openai_config.url;
AzureOpenAIVersion = embeddingConfig.azure_openai_config.version;
AzureOpenAIKey = embeddingConfig.azure_openai_config.key ?? '';
AzureOpenAIUrl = embeddingConfig.azure_openai_config.url ?? '';
AzureOpenAIVersion = embeddingConfig.azure_openai_config.version ?? '';
}
};
onMount(async () => {