mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-22 21:50:42 -05:00
refac
This commit is contained in:
1 parent
ab73749ca0
commit
b462a23a70
10 files changed
+33
-9
No files matched your search
@@ -41,7 +41,6 @@ from open_webui.models.tags import TagModel, Tags
|
||||
from open_webui.models.users import UserModel
|
||||
from open_webui.socket.main import get_event_emitter
|
||||
from open_webui.tasks import get_response_streams_by_chat_id, has_active_tasks, stop_item_tasks
|
||||
from open_webui.tools.visualizations import DEFAULT_VISUALIZATION_PROMPT_TEMPLATE
|
||||
from open_webui.utils.access_control import has_permission, validate_access_grants
|
||||
from open_webui.utils.access_control.folders import has_chat_move_access, has_folder_write_access
|
||||
from open_webui.utils.auth import bearer_security, get_admin_user, get_current_user, get_verified_user
|
||||
@@ -288,7 +287,6 @@ class ChatConfigForm(BaseModel):
|
||||
class ChatConfigResponse(ChatConfigForm):
|
||||
DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT: str = DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT
|
||||
DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT: str = DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT
|
||||
DEFAULT_VISUALIZATION_PROMPT_TEMPLATE: str = DEFAULT_VISUALIZATION_PROMPT_TEMPLATE
|
||||
TOOL_SEARCH_EMBEDDING_MODEL: str = ''
|
||||
|
||||
|
||||
@@ -311,7 +309,6 @@ async def get_chat_config_values() -> dict:
|
||||
config[f'TOOL_PERMISSIONS_AUTO_DECISIONS_{key.upper()}'] = auto_config[key]
|
||||
config['DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT'] = DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT
|
||||
config['DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT'] = DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT
|
||||
config['DEFAULT_VISUALIZATION_PROMPT_TEMPLATE'] = DEFAULT_VISUALIZATION_PROMPT_TEMPLATE
|
||||
config['TOOL_SEARCH_EMBEDDING_MODEL'] = values.get('rag.embedding_model') or ''
|
||||
return config
|
||||
|
||||
|
||||
@@ -406,6 +406,7 @@
|
||||
id="realtime-input-params"
|
||||
className={textareaClass}
|
||||
bind:value={REALTIME_INPUT_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional parameters in JSON format')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -414,6 +415,7 @@
|
||||
id="realtime-prompt-template"
|
||||
className={textareaClass}
|
||||
bind:value={realtime.REALTIME_CALL_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -903,6 +905,7 @@
|
||||
id="tts-openai-params"
|
||||
className={textareaClass}
|
||||
bind:value={TTS_OPENAI_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional parameters in JSON format')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -915,6 +918,7 @@
|
||||
id="realtime-tts-prompt-template"
|
||||
className={textareaClass}
|
||||
bind:value={REALTIME_TTS_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
|
||||
@@ -341,6 +341,7 @@
|
||||
'Enter a title for the pending user info overlay. Leave empty for default.'
|
||||
)}
|
||||
bind:value={adminConfig.PENDING_USER_OVERLAY_TITLE}
|
||||
maxSize={200}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
|
||||
@@ -356,6 +357,7 @@
|
||||
'Enter content for the pending user info overlay. Leave empty for default.'
|
||||
)}
|
||||
bind:value={adminConfig.PENDING_USER_OVERLAY_CONTENT}
|
||||
maxSize={200}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
</AdminSettingSection>
|
||||
|
||||
@@ -303,6 +303,7 @@
|
||||
id="code-interpreter-prompt-template"
|
||||
className={textareaClass}
|
||||
bind:value={config.CODE_INTERPRETER_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
|
||||
@@ -565,6 +565,7 @@
|
||||
id="datalab-marker-additional-config"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.DATALAB_MARKER_ADDITIONAL_CONFIG}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter JSON config (e.g., {"disable_links": true})')}
|
||||
/>
|
||||
</Tooltip>
|
||||
@@ -682,6 +683,7 @@
|
||||
id="external-document-loader-headers"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.EXTERNAL_DOCUMENT_LOADER_HEADERS}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional headers in JSON format')}
|
||||
required={false}
|
||||
/>
|
||||
@@ -773,6 +775,7 @@
|
||||
id="docling-params"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.DOCLING_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional parameters in JSON format')}
|
||||
minSize={100}
|
||||
/>
|
||||
@@ -857,6 +860,7 @@
|
||||
id="mistral-ocr-params"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.MISTRAL_OCR_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional parameters in JSON format')}
|
||||
minSize={100}
|
||||
/>
|
||||
@@ -967,6 +971,7 @@
|
||||
id="mineru-params"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.MINERU_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={`{\n "enable_ocr": false,\n "enable_formula": true,\n "enable_table": true,\n "language": "en",\n "model_version": "pipeline",\n "page_ranges": ""\n}`}
|
||||
minSize={100}
|
||||
/>
|
||||
@@ -1615,6 +1620,7 @@
|
||||
id="rag-template"
|
||||
className={textareaClass}
|
||||
bind:value={RAGConfig.RAG_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
|
||||
@@ -490,6 +490,7 @@
|
||||
className={textareaClass}
|
||||
placeholder={$i18n.t('Enter a watermark for the response. Leave empty for none.')}
|
||||
bind:value={adminConfig.RESPONSE_WATERMARK}
|
||||
maxSize={200}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
|
||||
|
||||
@@ -802,6 +802,7 @@
|
||||
id="image-connection-headers"
|
||||
className="w-full text-sm outline-hidden"
|
||||
bind:value={headers}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional headers in JSON format')}
|
||||
required={false}
|
||||
minSize={30}
|
||||
@@ -824,6 +825,7 @@
|
||||
id="image-connection-params"
|
||||
className="w-full text-sm outline-hidden"
|
||||
bind:value={params}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t('Enter additional parameters in JSON format')}
|
||||
required={false}
|
||||
minSize={30}
|
||||
|
||||
@@ -78,24 +78,20 @@
|
||||
let toolSearchAlwaysLoaded = '';
|
||||
let defaultDecisionsPrompt = '';
|
||||
let defaultPermissionsPrompt = '';
|
||||
let defaultVisualizationPrompt = '';
|
||||
let toolSearchEmbeddingModel = '';
|
||||
const readChatConfigMetadata = () => {
|
||||
const {
|
||||
DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT = '',
|
||||
DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT = '',
|
||||
DEFAULT_VISUALIZATION_PROMPT_TEMPLATE = '',
|
||||
TOOL_SEARCH_EMBEDDING_MODEL = '',
|
||||
...settings
|
||||
} = chatConfig as typeof chatConfig & {
|
||||
DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT?: string;
|
||||
DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT?: string;
|
||||
DEFAULT_VISUALIZATION_PROMPT_TEMPLATE?: string;
|
||||
TOOL_SEARCH_EMBEDDING_MODEL?: string;
|
||||
};
|
||||
defaultDecisionsPrompt = DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT;
|
||||
defaultPermissionsPrompt = DEFAULT_TOOL_PERMISSIONS_AUTO_PROMPT;
|
||||
defaultVisualizationPrompt = DEFAULT_VISUALIZATION_PROMPT_TEMPLATE;
|
||||
toolSearchEmbeddingModel = TOOL_SEARCH_EMBEDDING_MODEL;
|
||||
chatConfig = settings;
|
||||
};
|
||||
@@ -428,6 +424,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={chatConfig.CONTEXT_COMPACTION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -563,6 +560,7 @@
|
||||
id="tool-permissions-auto-prompt"
|
||||
className={textareaClass}
|
||||
bind:value={chatConfig.TOOL_PERMISSIONS_AUTO_PROMPT}
|
||||
maxSize={300}
|
||||
placeholder={defaultPermissionsPrompt}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -674,6 +672,7 @@
|
||||
id="tool-search-decisions-prompt"
|
||||
className={textareaClass}
|
||||
bind:value={chatConfig.TOOL_SEARCH_DECISIONS_PROMPT}
|
||||
maxSize={300}
|
||||
placeholder={defaultDecisionsPrompt}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -734,7 +733,8 @@
|
||||
id="visualization-prompt"
|
||||
className={textareaClass}
|
||||
bind:value={chatConfig.VISUALIZATION_PROMPT_TEMPLATE}
|
||||
placeholder={defaultVisualizationPrompt}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
</AdminSettingSection>
|
||||
@@ -756,6 +756,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.TITLE_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -779,6 +780,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.VOICE_MODE_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -802,6 +804,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.FOLLOW_UP_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -825,6 +828,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.TAGS_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -863,6 +867,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.QUERY_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -906,6 +911,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.AUTOCOMPLETE_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default prompt, or enter a custom prompt'
|
||||
)}
|
||||
@@ -920,6 +926,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
@@ -931,6 +938,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={taskConfig.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE}
|
||||
maxSize={300}
|
||||
placeholder={$i18n.t('Leave empty to use the default prompt, or enter a custom prompt')}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
|
||||
@@ -209,6 +209,7 @@
|
||||
'Your query will be sent to the configured web search provider.'
|
||||
)}
|
||||
bind:value={webConfig.WEB_SEARCH_CONFIRMATION_CONTENT}
|
||||
maxSize={200}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
{/if}
|
||||
@@ -1143,6 +1144,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={webConfig.YANDEX_WEB_SEARCH_CONFIG}
|
||||
maxSize={200}
|
||||
placeholder={$i18n.t(
|
||||
'Leave empty to use the default config, or enter a valid json (see https://yandex.cloud/en/docs/search-api/api-ref/WebSearch/search#yandex.cloud.searchapi.v2.WebSearchRequest)'
|
||||
)}
|
||||
@@ -1186,6 +1188,7 @@
|
||||
<Textarea
|
||||
className={textareaClass}
|
||||
bind:value={webConfig.LINKUP_SEARCH_PARAMS}
|
||||
maxSize={200}
|
||||
placeholder={`{\n "depth": "standard",\n "outputType": "sourcedAnswer"\n}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
{placeholder}
|
||||
aria-label={ariaLabel || placeholder}
|
||||
class={className}
|
||||
style="field-sizing: content;"
|
||||
style="field-sizing: content;{maxSize ? ` max-height: ${maxSize}px;` : ''}"
|
||||
{rows}
|
||||
{required}
|
||||
{readonly}
|
||||
|
||||
Reference in new issue
Block a user