feat(moderation): add Tencent TMS as fallback for AI content moderation
Some checks failed
Build Backend / build (push) Failing after 45s
Build Backend / build-docker (push) Has been skipped

Add Tencent Cloud Text Moderation System (TMS) as a fallback moderation
service when OpenAI is unavailable or returns an error. The service
now checks OpenAI first, and falls back to Tencent TMS if it fails,
providing better reliability for content moderation.

Features:
- New Tencent TMS configuration in config.yaml with environment variable overrides
- New tencent package in internal/pkg/tencent/ with TMS client implementation
- PostAIService now uses dual moderation with OpenAI primary and Tencent fallback
- Strict mode configuration passed to PostAIService for consistent behavior

BREAKING CHANGE: NewPostAIService now requires tencentClient and strictMode
parameters - update wire configuration accordingly.
This commit is contained in:
lafay
2026-04-21 22:31:30 +08:00
parent 90495385cd
commit 38d628c696
10 changed files with 546 additions and 48 deletions

View File

@@ -176,6 +176,19 @@ openai:
request_timeout: 30
strict_moderation: false
# 腾讯云文本内容安全配置(作为 OpenAI 备用)
# 当 OpenAI 不可用或审核失败时使用腾讯TMS进行文本审核
# 环境变量:
# APP_TENCENT_TMS_ENABLED, APP_TENCENT_TMS_SECRET_ID, APP_TENCENT_TMS_SECRET_KEY
# APP_TENCENT_TMS_REGION, APP_TENCENT_TMS_BIZ_TYPE, APP_TENCENT_TMS_TIMEOUT
tencent_tms:
enabled: false
secret_id: ""
secret_key: ""
region: "ap-guangzhou"
biz_type: "" # 可选,使用控制台配置的自定义策略
timeout: 30
# SMTP发信配置gomail.v2
# 环境变量:
# APP_EMAIL_ENABLED, APP_EMAIL_HOST, APP_EMAIL_PORT