mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Fix: adjusted that only admin can download embedding/reranking models and user can select from already downloaded models
This commit is contained in:
parent
d1ed648680
commit
d26c1f553b
@ -548,7 +548,7 @@
|
|||||||
|
|
||||||
<div class=" mb-2.5 flex flex-col w-full">
|
<div class=" mb-2.5 flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs font-medium">{$i18n.t('Embedding Model')}</div>
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Embedding Model')}</div>
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
<div class="">
|
<div class="">
|
||||||
{#if embeddingEngine === 'ollama'}
|
{#if embeddingEngine === 'ollama'}
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
@ -631,7 +631,38 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="flex-1 mr-2">
|
||||||
|
<select
|
||||||
|
class="flex-1 w-full rounded-lg text-sm bg-transparent outline-hidden p-2 border border-gray-300"
|
||||||
|
bind:value={embeddingModel}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="" disabled selected>{$i18n.t('Select embedding model')}</option>
|
||||||
|
<!-- Always show the current value first if it's not empty -->
|
||||||
|
{#if embeddingModel && embeddingModel.trim() !== ''}
|
||||||
|
<option value={embeddingModel} class="py-1 font-semibold">
|
||||||
|
{embeddingModel}
|
||||||
|
{#if embeddingEngine &&
|
||||||
|
RAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine] &&
|
||||||
|
!localRAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine]?.includes(embeddingModel)}
|
||||||
|
(custom)
|
||||||
|
{/if}
|
||||||
|
</option>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Then show all downloaded models from the selected engine -->
|
||||||
|
{#if embeddingEngine && RAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine]}
|
||||||
|
{#each RAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine] as model}
|
||||||
|
{#if model !== embeddingModel} <!-- Skip the current model as it's already shown -->
|
||||||
|
<option value={model} class="py-1">{model}</option>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="mt-1 mb-1 text-xs text-gray-400 dark:text-gray-500">
|
<div class="mt-1 mb-1 text-xs text-gray-400 dark:text-gray-500">
|
||||||
{$i18n.t(
|
{$i18n.t(
|
||||||
'Warning: If you update or change your embedding model, you will need to re-import all documents.'
|
'Warning: If you update or change your embedding model, you will need to re-import all documents.'
|
||||||
@ -694,7 +725,7 @@
|
|||||||
{#if RAGConfig.ENABLE_RAG_HYBRID_SEARCH === true}
|
{#if RAGConfig.ENABLE_RAG_HYBRID_SEARCH === true}
|
||||||
<div class=" mb-2.5 flex flex-col w-full">
|
<div class=" mb-2.5 flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs font-medium">{$i18n.t('Reranking Model')}</div>
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Reranking Model')}</div>
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
<div class="flex-1 mr-2">
|
<div class="flex-1 mr-2">
|
||||||
@ -759,6 +790,37 @@
|
|||||||
</svg>
|
</svg>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="flex-1 mr-2">
|
||||||
|
<select
|
||||||
|
class="flex-1 w-full rounded-lg text-sm bg-transparent outline-hidden p-2 border border-gray-300"
|
||||||
|
bind:value={rerankingModel}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="" disabled selected>{$i18n.t('Select reranking model')}</option>
|
||||||
|
<!-- Always show the current value first if it's not empty -->
|
||||||
|
{#if rerankingModel && rerankingModel.trim() !== ''}
|
||||||
|
<option value={rerankingModel} class="py-1 font-semibold">
|
||||||
|
{rerankingModel}
|
||||||
|
{#if !RAGConfig.DOWNLOADED_RERANKING_MODELS?.includes(embeddingModel)}
|
||||||
|
(custom)
|
||||||
|
{/if}
|
||||||
|
</option>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Then show all downloaded models from the selected engine -->
|
||||||
|
{#if RAGConfig.DOWNLOADED_RERANKING_MODELS}
|
||||||
|
{#each RAGConfig.DOWNLOADED_RERANKING_MODELS as model}
|
||||||
|
{#if model !== rerankingModel} <!-- Skip the current model as it's already shown -->
|
||||||
|
<option value={model} class="py-1">{model}</option>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -232,6 +232,10 @@
|
|||||||
openai_config,
|
openai_config,
|
||||||
ollama_config,
|
ollama_config,
|
||||||
reranking_model,
|
reranking_model,
|
||||||
|
LOADED_EMBEDDING_MODELS,
|
||||||
|
DOWNLOADED_EMBEDDING_MODELS,
|
||||||
|
LOADED_RERANKING_MODELS,
|
||||||
|
DOWNLOADED_RERANKING_MODELS,
|
||||||
...filteredRAGConfig
|
...filteredRAGConfig
|
||||||
} = localRAGConfig;
|
} = localRAGConfig;
|
||||||
|
|
||||||
@ -247,6 +251,16 @@
|
|||||||
await rerankingModelUpdateHandler();
|
await rerankingModelUpdateHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update embedding and reranking to show updates in UI
|
||||||
|
localRAGConfig.embedding_engine = embeddingEngine
|
||||||
|
localRAGConfig.embedding_model = embeddingModel
|
||||||
|
localRAGConfig.embedding_batch_size = embeddingBatchSize
|
||||||
|
localRAGConfig.openai_config = {"key": OpenAIKey, "url": OpenAIUrl}
|
||||||
|
localRAGConfig.ollama_config = {"key": OllamaKey, "url": OllamaUrl}
|
||||||
|
localRAGConfig.reranking_model = rerankingModel
|
||||||
|
|
||||||
|
|
||||||
console.log('RAGConfig:', localRAGConfig);
|
console.log('RAGConfig:', localRAGConfig);
|
||||||
dispatch('update', localRAGConfig)
|
dispatch('update', localRAGConfig)
|
||||||
loading = false;
|
loading = false;
|
||||||
@ -489,7 +503,7 @@
|
|||||||
|
|
||||||
<div class=" mb-2.5 flex flex-col w-full">
|
<div class=" mb-2.5 flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs font-medium">{$i18n.t('Embedding Model')}</div>
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Embedding Model')}</div>
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
<div class="">
|
<div class="">
|
||||||
{#if embeddingEngine === 'ollama'}
|
{#if embeddingEngine === 'ollama'}
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
@ -499,6 +513,8 @@
|
|||||||
bind:value={embeddingModel}
|
bind:value={embeddingModel}
|
||||||
placeholder={$i18n.t('Set embedding model')}
|
placeholder={$i18n.t('Set embedding model')}
|
||||||
required
|
required
|
||||||
|
on:input={() => {
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -511,6 +527,8 @@
|
|||||||
model: embeddingModel.slice(-40)
|
model: embeddingModel.slice(-40)
|
||||||
})}
|
})}
|
||||||
bind:value={embeddingModel}
|
bind:value={embeddingModel}
|
||||||
|
on:input={() => {
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -572,6 +590,39 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="flex-1 mr-2">
|
||||||
|
<select
|
||||||
|
class="flex-1 w-full rounded-lg text-sm bg-transparent outline-hidden p-2 border border-gray-300"
|
||||||
|
bind:value={embeddingModel}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="" disabled selected>{$i18n.t('Select embedding model')}</option>
|
||||||
|
<!-- Always show the current value first if it's not empty -->
|
||||||
|
{#if embeddingModel && embeddingModel.trim() !== ''}
|
||||||
|
<option value={embeddingModel} class="py-1 font-semibold">
|
||||||
|
{embeddingModel}
|
||||||
|
{#if embeddingEngine &&
|
||||||
|
localRAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine] &&
|
||||||
|
!localRAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine]?.includes(embeddingModel)}
|
||||||
|
(custom)
|
||||||
|
{/if}
|
||||||
|
</option>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Then show all downloaded models from the selected engine -->
|
||||||
|
{#if embeddingEngine && localRAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine]}
|
||||||
|
{#each localRAGConfig.DOWNLOADED_EMBEDDING_MODELS[embeddingEngine] as model}
|
||||||
|
{#if model !== embeddingModel} <!-- Skip the current model as it's already shown -->
|
||||||
|
<option value={model} class="py-1">{model}</option>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mt-1 mb-1 text-xs text-gray-400 dark:text-gray-500">
|
<div class="mt-1 mb-1 text-xs text-gray-400 dark:text-gray-500">
|
||||||
{$i18n.t(
|
{$i18n.t(
|
||||||
@ -580,6 +631,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{#if embeddingEngine === 'ollama' || embeddingEngine === 'openai'}
|
{#if embeddingEngine === 'ollama' || embeddingEngine === 'openai'}
|
||||||
<div class=" mb-2.5 flex w-full justify-between">
|
<div class=" mb-2.5 flex w-full justify-between">
|
||||||
<div class=" self-center text-xs font-medium">
|
<div class=" self-center text-xs font-medium">
|
||||||
@ -635,7 +687,7 @@
|
|||||||
{#if localRAGConfig.ENABLE_RAG_HYBRID_SEARCH === true}
|
{#if localRAGConfig.ENABLE_RAG_HYBRID_SEARCH === true}
|
||||||
<div class=" mb-2.5 flex flex-col w-full">
|
<div class=" mb-2.5 flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs font-medium">{$i18n.t('Reranking Model')}</div>
|
<div class=" mb-1 text-xs font-medium">{$i18n.t('Reranking Model')}</div>
|
||||||
|
{#if $user?.role === 'admin'}
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
<div class="flex-1 mr-2">
|
<div class="flex-1 mr-2">
|
||||||
@ -702,6 +754,36 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="flex-1 mr-2">
|
||||||
|
<select
|
||||||
|
class="flex-1 w-full rounded-lg text-sm bg-transparent outline-hidden p-2 border border-gray-300"
|
||||||
|
bind:value={rerankingModel}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="" disabled selected>{$i18n.t('Select reranking model')}</option>
|
||||||
|
<!-- Always show the current value first if it's not empty -->
|
||||||
|
{#if rerankingModel && rerankingModel.trim() !== ''}
|
||||||
|
<option value={rerankingModel} class="py-1 font-semibold">
|
||||||
|
{rerankingModel}
|
||||||
|
{#if !localRAGConfig.DOWNLOADED_RERANKING_MODELS?.includes(embeddingModel)}
|
||||||
|
(custom)
|
||||||
|
{/if}
|
||||||
|
</option>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Then show all downloaded models from the selected engine -->
|
||||||
|
{#if localRAGConfig.DOWNLOADED_RERANKING_MODELS}
|
||||||
|
{#each localRAGConfig.DOWNLOADED_RERANKING_MODELS as model}
|
||||||
|
{#if model !== rerankingModel} <!-- Skip the current model as it's already shown -->
|
||||||
|
<option value={model} class="py-1">{model}</option>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user