refac
This commit is contained in:
1 parent
25802c048e
commit
e1acd7e7ca
2 files changed
+18
-13
No files matched your search
@@ -1793,6 +1793,22 @@
|
|||||||
|
|
||||||
const defaultModels = $config?.default_models ? $config?.default_models.split(',') : [];
|
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')) {
|
if ($page.url.searchParams.get('models') || $page.url.searchParams.get('model')) {
|
||||||
const urlModels = (
|
const urlModels = (
|
||||||
$page.url.searchParams.get('models') ||
|
$page.url.searchParams.get('models') ||
|
||||||
@@ -1803,18 +1819,7 @@
|
|||||||
if (urlModels.length === 1) {
|
if (urlModels.length === 1) {
|
||||||
if (!$models.find((m) => m.id === urlModels[0])) {
|
if (!$models.find((m) => m.id === urlModels[0])) {
|
||||||
// Model not found; open model selector and prefill
|
// Model not found; open model selector and prefill
|
||||||
const modelSelectorButton = document.getElementById('model-selector-0-button');
|
await openModelSelectorWithSearch(urlModels[0]);
|
||||||
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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Model found; set it as selected
|
// Model found; set it as selected
|
||||||
selectedModels = urlModels;
|
selectedModels = urlModels;
|
||||||
|
|||||||
@@ -338,7 +338,7 @@
|
|||||||
} else if (shortcut === Shortcut.OPEN_MODEL_SELECTOR) {
|
} else if (shortcut === Shortcut.OPEN_MODEL_SELECTOR) {
|
||||||
console.log('Shortcut triggered: OPEN_MODEL_SELECTOR');
|
console.log('Shortcut triggered: OPEN_MODEL_SELECTOR');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
document.getElementById('model-selector-0-button')?.click();
|
document.getElementById('model-selector-model-button')?.click();
|
||||||
} else if (shortcut === Shortcut.NEW_TEMPORARY_CHAT) {
|
} else if (shortcut === Shortcut.NEW_TEMPORARY_CHAT) {
|
||||||
console.log('Shortcut triggered: NEW_TEMPORARY_CHAT');
|
console.log('Shortcut triggered: NEW_TEMPORARY_CHAT');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in new issue
Block a user