Asynchronous Tasks
Celery tasks for prompt app.
These tasks are i/o intensive operations for creating prompt and plugin history records with Celery workers in order to avoid blocking the main app thread. This is advance work to lay groundwork for future high-traffic scenarios.
purge_prompt_history()deletes the prompt history (PromptHistory, PromptToolCall, PromptPluginUsage, and idle Prompts) older thansmarter_settings.prompt_history_max_agedays. Celery Beat runs it daily.
- smarter.apps.prompt.tasks.PROMPT_HISTORY_PURGE_BATCH_SIZE = 1000
The most rows that
purge_prompt_history()deletes from a table in one statement.
- smarter.apps.prompt.tasks.delete_in_batches(queryset)[source]
Delete the rows of
querysetin batches ofPROMPT_HISTORY_PURGE_BATCH_SIZE.A large table isn’t locked in one long delete, e.g. on the first purge of a platform that has kept its prompt history for years.
- smarter.apps.prompt.tasks.should_log(level)[source]
Check if logging should be done based on the waffle switch.