feat(meituan): 政治类文章拦截 + 写'无可奉告' + Angel 并发 3→1
- llm_settings 加 meituan_blocked_topics / blocked_keywords / no_comment_text - alembic 0006 迁移,默认 topics=[时政/国际/军事/政治/战争/冲突/制裁/选举], 默认文案='无可奉告' - enrichment._is_meituan_blocked 预检:category 命中 topic 或 关键词 → 直接写'无可奉告',不调美团 API - 命中后 commentary_meituan_model='policy-block' 标识非真实生成 - enrichment_loop Semaphore(3)→(1),Agnes 免费 plan 不再 429 - 前端 AdminLlmSettings 美团卡片加 3 字段 UI(主题/关键词/固定文案)
This commit is contained in:
64
backend/alembic/versions/0006_meituan_blocked_topics.py
Normal file
64
backend/alembic/versions/0006_meituan_blocked_topics.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""美团"无可奉告"主题清单 — 命中则不调美团 API,直接写固定文案
|
||||
|
||||
- llm_settings.meituan_blocked_topics JSONB (默认 ["时政", "国际", "军事", "政治", "战争", "冲突", "制裁", "选举"])
|
||||
- llm_settings.meituan_blocked_keywords JSONB (默认 [])
|
||||
- llm_settings.meituan_no_comment_text TEXT (默认 "无可奉告")
|
||||
|
||||
Revision ID: 0006
|
||||
Revises: 0005
|
||||
Create Date: 2026-06-12
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
|
||||
revision: str = "0006"
|
||||
down_revision: Union[str, None] = "0005"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
DEFAULT_TOPICS = ["时政", "国际", "军事", "政治", "战争", "冲突", "制裁", "选举"]
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
import json
|
||||
default_topics_json = sa.text(repr(json.dumps(DEFAULT_TOPICS, ensure_ascii=False)))
|
||||
|
||||
op.add_column(
|
||||
"llm_settings",
|
||||
sa.Column(
|
||||
"meituan_blocked_topics",
|
||||
JSONB,
|
||||
nullable=False,
|
||||
server_default=default_topics_json,
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"llm_settings",
|
||||
sa.Column(
|
||||
"meituan_blocked_keywords",
|
||||
JSONB,
|
||||
nullable=False,
|
||||
server_default=sa.text("'[]'::jsonb"),
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"llm_settings",
|
||||
sa.Column(
|
||||
"meituan_no_comment_text",
|
||||
sa.Text,
|
||||
nullable=False,
|
||||
server_default="无可奉告",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("llm_settings", "meituan_no_comment_text")
|
||||
op.drop_column("llm_settings", "meituan_blocked_keywords")
|
||||
op.drop_column("llm_settings", "meituan_blocked_topics")
|
||||
Reference in New Issue
Block a user