配置全面迁移数据库:PromptConfig、TaskConfig动态调度、敏感词/清洗规则/趋势映射/平台标签/痛点模板全部可编辑
- 新增 PromptConfig 模型 + API,支持提示词在线编辑(16条默认) - 调度器动态读取 TaskConfig.schedule,admin 可调执行时间 - 新增 KeywordDomainMap、SensitiveWord、ContentCleanRule、TrendFieldMapping 表 - DOMAINS、TREND_DOMAIN_MAP、PLATFORM_TAGS、china_pains、RSS关键词、priority_weights 全部迁移到 DB - tasks.html 重构:卡片网格+配置/产出/历史/提示词四个Tab,折叠显示 - 清理冗余代码:DEFAULT_PROMPTS死代码、collector.py unreachable代码、compliance_checker bug - strip_thinking_html 改用 DB 规则优先
This commit is contained in:
@@ -61,6 +61,49 @@ def init_db():
|
||||
("platform_configs", "min_words", "INTEGER DEFAULT 0"),
|
||||
("platform_configs", "max_words", "INTEGER DEFAULT 0"),
|
||||
("platform_configs", "website_url", "VARCHAR"),
|
||||
("task_logs", "module_id", "VARCHAR"),
|
||||
("task_logs", "error_trace", "TEXT"),
|
||||
("task_logs", "triggered_by", "VARCHAR DEFAULT 'scheduler'"),
|
||||
("task_logs", "result_data", "JSON DEFAULT '{}'::json"),
|
||||
("task_logs", "next_run_time", "TIMESTAMP"),
|
||||
("task_configs", "module_id", "VARCHAR UNIQUE"),
|
||||
("task_configs", "enabled", "BOOLEAN DEFAULT TRUE"),
|
||||
("task_configs", "params", "JSON DEFAULT '{}'::json"),
|
||||
("task_configs", "schedule", "VARCHAR"),
|
||||
("task_configs", "last_modified_by", "VARCHAR"),
|
||||
("prompt_configs", "key", "VARCHAR UNIQUE"),
|
||||
("prompt_configs", "module_id", "VARCHAR"),
|
||||
("prompt_configs", "category", "VARCHAR DEFAULT 'prompt'"),
|
||||
("prompt_configs", "version", "VARCHAR DEFAULT 'v1'"),
|
||||
("prompt_configs", "content", "TEXT"),
|
||||
("prompt_configs", "variables", "JSON DEFAULT '[]'::json"),
|
||||
("prompt_configs", "description", "VARCHAR"),
|
||||
("prompt_configs", "enabled", "BOOLEAN DEFAULT TRUE"),
|
||||
("prompt_configs", "temperature", "FLOAT"),
|
||||
("prompt_configs", "max_tokens", "INTEGER"),
|
||||
("prompt_configs", "created_by", "VARCHAR"),
|
||||
("keyword_domain_map", "id", "INTEGER PRIMARY KEY"),
|
||||
("keyword_domain_map", "pattern", "VARCHAR"),
|
||||
("keyword_domain_map", "domain", "VARCHAR"),
|
||||
("keyword_domain_map", "sort_order", "INTEGER DEFAULT 0"),
|
||||
("keyword_domain_map", "is_active", "BOOLEAN DEFAULT TRUE"),
|
||||
("sensitive_words", "id", "INTEGER PRIMARY KEY"),
|
||||
("sensitive_words", "word", "VARCHAR"),
|
||||
("sensitive_words", "category", "VARCHAR DEFAULT 'general'"),
|
||||
("sensitive_words", "is_active", "BOOLEAN DEFAULT TRUE"),
|
||||
("sensitive_words", "added_by", "VARCHAR"),
|
||||
("content_clean_rules", "id", "INTEGER PRIMARY KEY"),
|
||||
("content_clean_rules", "rule_type", "VARCHAR"),
|
||||
("content_clean_rules", "pattern", "TEXT"),
|
||||
("content_clean_rules", "description", "VARCHAR"),
|
||||
("content_clean_rules", "is_active", "BOOLEAN DEFAULT TRUE"),
|
||||
("content_clean_rules", "sort_order", "INTEGER DEFAULT 0"),
|
||||
("collector_categories", "pain_template", "TEXT"),
|
||||
("trend_field_mappings", "id", "INTEGER PRIMARY KEY"),
|
||||
("trend_field_mappings", "trend_keyword", "VARCHAR"),
|
||||
("trend_field_mappings", "field_name", "VARCHAR"),
|
||||
("trend_field_mappings", "sort_order", "INTEGER DEFAULT 0"),
|
||||
("trend_field_mappings", "is_active", "BOOLEAN DEFAULT TRUE"),
|
||||
]:
|
||||
try:
|
||||
conn.execute(text(f"ALTER TABLE {table} ADD COLUMN IF NOT EXISTS {col} {typ}"))
|
||||
|
||||
Reference in New Issue
Block a user