{#if models !== null && taskConfig}
{ updateInterfaceHandler(); dispatch('save'); }} >
{$i18n.t('Tasks')}
{$i18n.t('Task Model')}
{$i18n.t('Local Task Model')}
{ if (taskConfig.TASK_MODEL) { const model = models.find((m) => m.id === taskConfig.TASK_MODEL); if (model) { if (model?.access_control !== null) { toast.error( $i18n.t( 'This model is not publicly available. Please select another model.' ) ); } taskConfig.TASK_MODEL = model.id; } else { taskConfig.TASK_MODEL = ''; } } }} >
{$i18n.t('Current Model')}
{#each models as model}
{model.name} {model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
{/each}
{$i18n.t('External Task Model')}
{ if (taskConfig.TASK_MODEL_EXTERNAL) { const model = models.find((m) => m.id === taskConfig.TASK_MODEL_EXTERNAL); if (model) { if (model?.access_control !== null) { toast.error( $i18n.t( 'This model is not publicly available. Please select another model.' ) ); } taskConfig.TASK_MODEL_EXTERNAL = model.id; } else { taskConfig.TASK_MODEL_EXTERNAL = ''; } } }} >
{$i18n.t('Current Model')}
{#each models as model}
{model.name} {model?.connection_type === 'local' ? `(${$i18n.t('Local')})` : ''}
{/each}
{$i18n.t('Title Generation')}
{#if taskConfig.ENABLE_TITLE_GENERATION}
{$i18n.t('Title Generation Prompt')}
{/if}
{$i18n.t('Tags Generation')}
{#if taskConfig.ENABLE_TAGS_GENERATION}
{$i18n.t('Tags Generation Prompt')}
{/if}
{$i18n.t('Retrieval Query Generation')}
{$i18n.t('Web Search Query Generation')}
{$i18n.t('Query Generation Prompt')}
{$i18n.t('Autocomplete Generation')}
{#if taskConfig.ENABLE_AUTOCOMPLETE_GENERATION}
{$i18n.t('Autocomplete Generation Input Max Length')}
{/if}
{$i18n.t('Image Prompt Generation Prompt')}
{$i18n.t('Tools Function Calling Prompt')}
{$i18n.t('UI')}
{$i18n.t('Banners')}
{ if (banners.length === 0 || banners.at(-1).content !== '') { banners = [ ...banners, { id: uuidv4(), type: '', title: '', content: '', dismissible: true, timestamp: Math.floor(Date.now() / 1000) } ]; } }} >
{#if $user?.role === 'admin'}
{$i18n.t('Default Prompt Suggestions')}
{ if (promptSuggestions.length === 0 || promptSuggestions.at(-1).content !== '') { promptSuggestions = [...promptSuggestions, { content: '', title: ['', ''] }]; } }} >
{#each promptSuggestions as prompt, promptIdx}
{ promptSuggestions.splice(promptIdx, 1); promptSuggestions = promptSuggestions; }} >
{/each}
{#if promptSuggestions.length > 0}
{$i18n.t('Adjusting these settings will apply changes universally to all users.')}
{/if}
{ const files = e.target.files; if (!files || files.length === 0) { return; } console.log(files); let reader = new FileReader(); reader.onload = async (event) => { try { let suggestions = JSON.parse(event.target.result); suggestions = suggestions.map((s) => { if (typeof s.title === 'string') { s.title = [s.title, '']; } else if (!Array.isArray(s.title)) { s.title = ['', '']; } return s; }); promptSuggestions = [...promptSuggestions, ...suggestions]; } catch (error) { toast.error($i18n.t('Invalid JSON file')); return; } }; reader.readAsText(files[0]); e.target.value = ''; // Reset the input value }} />
{ const input = document.getElementById('prompt-suggestions-import-input'); if (input) { input.click(); } }} >
{$i18n.t('Import Prompt Suggestions')}
{#if promptSuggestions.length}
{ let blob = new Blob([JSON.stringify(promptSuggestions)], { type: 'application/json' }); saveAs(blob, `prompt-suggestions-export-${Date.now()}.json`); }} >
{$i18n.t('Export Prompt Suggestions')} ({promptSuggestions.length})
{/if}
{/if}
{$i18n.t('Save')}
{:else}
{/if}