mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
Update PruneDataDialog.svelte
This commit is contained in:
parent
5aa93ab97d
commit
544f8b72dc
1 changed files with 62 additions and 26 deletions
|
|
@ -39,8 +39,8 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
const confirm = () => {
|
const preview = () => {
|
||||||
dispatch('confirm', {
|
dispatch('preview', {
|
||||||
days: deleteChatsByAge ? days : null,
|
days: deleteChatsByAge ? days : null,
|
||||||
exempt_archived_chats,
|
exempt_archived_chats,
|
||||||
exempt_chats_in_folders,
|
exempt_chats_in_folders,
|
||||||
|
|
@ -60,28 +60,64 @@
|
||||||
show = false;
|
show = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate API call preview
|
// Generate API call preview with helpful comments
|
||||||
$: apiCallPreview = `POST /api/v1/admin/prune
|
$: apiCallPreview = `# Open WebUI Data Pruning API Call
|
||||||
Content-Type: application/json
|
# Use this template for automated maintenance scripts (cron jobs, etc.)
|
||||||
Authorization: Bearer <your-api-key>
|
|
||||||
|
|
||||||
{
|
# AUTHENTICATION: Use API Key (not JWT token) for automation
|
||||||
"days": ${deleteChatsByAge ? days : null},
|
# Get your API key from: Settings → Account → API Key → Generate new key
|
||||||
"exempt_archived_chats": ${exempt_archived_chats},
|
# Format: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
"exempt_chats_in_folders": ${exempt_chats_in_folders},
|
|
||||||
"delete_orphaned_chats": ${delete_orphaned_chats},
|
curl -X POST "${window.location.origin}/api/v1/prune/" \\
|
||||||
"delete_orphaned_tools": ${delete_orphaned_tools},
|
-H "Content-Type: application/json" \\
|
||||||
"delete_orphaned_functions": ${delete_orphaned_functions},
|
-H "Authorization: Bearer <your-api-key>" \\
|
||||||
"delete_orphaned_prompts": ${delete_orphaned_prompts},
|
-d '{
|
||||||
"delete_orphaned_knowledge_bases": ${delete_orphaned_knowledge_bases},
|
// SAFETY: Always test with dry_run=true first to preview results
|
||||||
"delete_orphaned_models": ${delete_orphaned_models},
|
"dry_run": false,
|
||||||
"delete_orphaned_notes": ${delete_orphaned_notes},
|
|
||||||
"delete_orphaned_folders": ${delete_orphaned_folders},
|
// AGE-BASED CHAT DELETION (null = disabled)
|
||||||
"audio_cache_max_age_days": ${cleanupAudioCache ? audio_cache_max_age_days : null},
|
"days": ${deleteChatsByAge ? days : null},
|
||||||
"delete_inactive_users_days": ${deleteInactiveUsers ? delete_inactive_users_days : null},
|
"exempt_archived_chats": ${exempt_archived_chats}, // Keep archived chats even if old
|
||||||
"exempt_admin_users": ${exempt_admin_users},
|
"exempt_chats_in_folders": ${exempt_chats_in_folders}, // Keep organized/pinned chats
|
||||||
"exempt_pending_users": ${exempt_pending_users}
|
|
||||||
}`;
|
// INACTIVE USER DELETION (null = disabled, VERY DESTRUCTIVE)
|
||||||
|
"delete_inactive_users_days": ${deleteInactiveUsers ? delete_inactive_users_days : null},
|
||||||
|
"exempt_admin_users": ${exempt_admin_users}, // Strongly recommended: true
|
||||||
|
"exempt_pending_users": ${exempt_pending_users}, // Recommended for user approval workflows
|
||||||
|
|
||||||
|
// ORPHANED DATA CLEANUP (from deleted users)
|
||||||
|
"delete_orphaned_chats": ${delete_orphaned_chats},
|
||||||
|
"delete_orphaned_tools": ${delete_orphaned_tools},
|
||||||
|
"delete_orphaned_functions": ${delete_orphaned_functions}, // Actions, Pipes, Filters
|
||||||
|
"delete_orphaned_prompts": ${delete_orphaned_prompts},
|
||||||
|
"delete_orphaned_knowledge_bases": ${delete_orphaned_knowledge_bases},
|
||||||
|
"delete_orphaned_models": ${delete_orphaned_models},
|
||||||
|
"delete_orphaned_notes": ${delete_orphaned_notes},
|
||||||
|
"delete_orphaned_folders": ${delete_orphaned_folders},
|
||||||
|
|
||||||
|
// AUDIO CACHE CLEANUP (null = disabled)
|
||||||
|
"audio_cache_max_age_days": ${cleanupAudioCache ? audio_cache_max_age_days : null} // TTS/STT files
|
||||||
|
}'
|
||||||
|
|
||||||
|
# API KEY vs JWT TOKEN:
|
||||||
|
# - API Key: Persistent, use for automation (sk-xxxxxxxx...)
|
||||||
|
# - JWT Token: Session-bound, temporary, use for web UI only
|
||||||
|
# - ALWAYS use API Key for scripts/cron jobs
|
||||||
|
|
||||||
|
# AUTOMATION TIPS:
|
||||||
|
# 1. Run with dry_run=true first to preview what will be deleted
|
||||||
|
# 2. Schedule during low-usage hours to minimize performance impact
|
||||||
|
# 3. Monitor logs: tail -f /path/to/open-webui/logs
|
||||||
|
# 4. Consider database backup before large cleanup operations
|
||||||
|
# 5. Test on staging environment with similar data size first
|
||||||
|
|
||||||
|
# EXAMPLE CRON JOB (runs weekly on Sunday at 2 AM):
|
||||||
|
# 0 2 * * 0 /path/to/your/prune-script.sh >> /var/log/openwebui-prune.log 2>&1
|
||||||
|
|
||||||
|
# RESPONSE HANDLING:
|
||||||
|
# - dry_run=true: Returns counts object with preview numbers
|
||||||
|
# - dry_run=false: Returns true on success, throws error on failure
|
||||||
|
# - Always check HTTP status code and response for errors`;
|
||||||
|
|
||||||
// Warning for short inactive user deletion periods
|
// Warning for short inactive user deletion periods
|
||||||
$: shortUserDeletionWarning = deleteInactiveUsers && delete_inactive_users_days < 30;
|
$: shortUserDeletionWarning = deleteInactiveUsers && delete_inactive_users_days < 30;
|
||||||
|
|
@ -778,10 +814,10 @@ Authorization: Bearer <your-api-key>
|
||||||
{$i18n.t('Cancel')}
|
{$i18n.t('Cancel')}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="px-4 py-2 text-sm font-medium text-white bg-yellow-600 border border-transparent rounded-lg hover:bg-yellow-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-yellow-500 transition-colors"
|
class="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors"
|
||||||
on:click={confirm}
|
on:click={preview}
|
||||||
>
|
>
|
||||||
{$i18n.t('Prune Data')}
|
{$i18n.t('Preview')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue