mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-13 01:02:25 -06:00
refac
This commit is contained in:
@@ -1793,6 +1793,22 @@
|
||||
|
||||
const defaultModels = $config?.default_models ? $config?.default_models.split(',') : [];
|
||||
|
||||
const openModelSelectorWithSearch = async (modelId: string) => {
|
||||
const modelSelectorButton = document.getElementById('model-selector-model-button');
|
||||
modelSelectorButton?.click();
|
||||
|
||||
await tick();
|
||||
|
||||
const modelSelectorInput = document.getElementById(
|
||||
'model-search-input'
|
||||
) as HTMLInputElement | null;
|
||||
if (modelSelectorInput) {
|
||||
modelSelectorInput.focus();
|
||||
modelSelectorInput.value = modelId;
|
||||
modelSelectorInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
};
|
||||
|
||||
if ($page.url.searchParams.get('models') || $page.url.searchParams.get('model')) {
|
||||
const urlModels = (
|
||||
$page.url.searchParams.get('models') ||
|
||||
@@ -1803,18 +1819,7 @@
|
||||
if (urlModels.length === 1) {
|
||||
if (!$models.find((m) => m.id === urlModels[0])) {
|
||||
// Model not found; open model selector and prefill
|
||||
const modelSelectorButton = document.getElementById('model-selector-0-button');
|
||||
if (modelSelectorButton) {
|
||||
modelSelectorButton.click();
|
||||
await tick();
|
||||
|
||||
const modelSelectorInput = document.getElementById('model-search-input');
|
||||
if (modelSelectorInput) {
|
||||
modelSelectorInput.focus();
|
||||
modelSelectorInput.value = urlModels[0];
|
||||
modelSelectorInput.dispatchEvent(new Event('input'));
|
||||
}
|
||||
}
|
||||
await openModelSelectorWithSearch(urlModels[0]);
|
||||
} else {
|
||||
// Model found; set it as selected
|
||||
selectedModels = urlModels;
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
} else if (shortcut === Shortcut.OPEN_MODEL_SELECTOR) {
|
||||
console.log('Shortcut triggered: OPEN_MODEL_SELECTOR');
|
||||
event.preventDefault();
|
||||
document.getElementById('model-selector-0-button')?.click();
|
||||
document.getElementById('model-selector-model-button')?.click();
|
||||
} else if (shortcut === Shortcut.NEW_TEMPORARY_CHAT) {
|
||||
console.log('Shortcut triggered: NEW_TEMPORARY_CHAT');
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user