feat(sensitive): 敏感词命中时返回明确拒绝回答#12
Merged
Merged
Conversation
- 新增 service/sensitive_refusal.go:按 relayFormat × stream 构造 200 正常响应 - OpenAI chat/completions(含流式)→ chat.completion / SSE chunk - Claude /v1/messages(含流式)→ message / SSE 五事件序列(符合 Anthropic SSE 规范) - 其他格式(embedding/rerank/image/audio/gemini/responses/task/mj)→ 退回 400 明确错误 - OpenAI 分支通过 len(r.Messages) > 0 区分 /chat/completions 与 /completions、/moderations - 新增 setting.SensitiveRefusalText 配置项(默认「很抱歉,你输入的内容含有敏感信息,我无法回答。」) - model/option.go 纳入 SensitiveRefusalText 的持久化读写 - classic 前端「屏蔽词过滤设置」新增拒绝文案输入框 + 各语言 i18n 翻译
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
service/sensitive_refusal.go,按 relayFormat × stream 构造合规响应:/chat/completions(含流式)→chat.completion/ SSE chunk/v1/messages(含流式)→message/ SSE 五事件序列(符合 Anthropic SSE 规范)len(r.Messages) > 0区分/chat/completions与/completions、/moderations,避免返回不兼容的 schemaSensitiveRefusalText配置项(默认「很抱歉,你输入的内容含有敏感信息,我无法回答。」),支持后台持久化自定义Test plan