topicality
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTopicality
话题合规性
A guardrail automatically enforces conversation topic boundaries. Messages
matching forbidden topics are blocked. Messages outside allowed topics are
flagged. Gradual off-topic drift across multiple turns is detected.
这一防护机制可自动强制管控对话的话题边界。匹配禁止话题的消息会被拦截,超出允许话题范围的消息会被标记。同时可检测多轮对话中逐渐偏离主题的情况。
When to Use check_topic
何时使用check_topic
- To verify if RAG retrieval results are relevant to allowed topics
- Before presenting user-submitted content to the agent
- In content moderation workflows
- 验证RAG检索结果是否与允许话题相关
- 在将用户提交的内容呈现给Agent之前
- 用于内容审核工作流
What It Enforces
其管控规则
- Allowed topics: messages must be semantically related to at least one allowed topic
- Forbidden topics: messages matching a forbidden topic are blocked
- Drift detection: gradual off-topic steering across multiple turns is caught
- 允许话题:消息必须与至少一个允许话题在语义上相关
- 禁止话题:匹配禁止话题的消息会被拦截
- 漂移检测:可捕捉多轮对话中逐渐偏离主题的引导行为
Constraints
限制条件
- Requires an embedding provider (OpenAI, etc.) to be configured
- Topic embeddings are computed lazily on first evaluation
- Drift detection tracks per-session state (cleaned up after 1 hour of inactivity)
- 需要配置嵌入服务提供商(如OpenAI等)
- 话题嵌入会在首次评估时延迟计算
- 漂移检测会跟踪每个会话的状态(会话闲置1小时后会被清理)