拦截逻辑收回 Lua 层,宿主代码恢复原样
还原 middleware/errors.py、runtime.py、proxy.py:不再依赖宿主渲染错误体,宿主按原样返回 403。网关代码零改动。 response_guard.lua:请求侧判定不通过时,把发往上游的请求体换成最小 stub(原文不出网关),在响应侧用 replace 输出 OpenAI 错误体 400 content_policy_violation;审核不可用时 503 safety_review_unavailable。拦截响应形态完全由插件自己控制。 tools/verify_plugins.py:断言同步回 stub 流程,57 项。
This commit is contained in:
1 parent
554a36cf05
commit
c76972c623
6 files changed
+97
-90
No files matched your search
@@ -7,15 +7,7 @@ class PluginFailure(MiddlewareError):
|
||||
|
||||
|
||||
class PolicyBlocked(MiddlewareError):
|
||||
"""A plugin rejected the request.
|
||||
|
||||
``code`` is one of a closed set of tokens (see runtime.BLOCK_CODES). Plugin-supplied
|
||||
text must never reach the response body, so anything outside that set is normalised.
|
||||
"""
|
||||
|
||||
def __init__(self, code: str = "content_policy_violation") -> None:
|
||||
super().__init__(code)
|
||||
self.code = code
|
||||
pass
|
||||
|
||||
|
||||
class Overloaded(MiddlewareError):
|
||||
|
||||
Reference in new issue
Block a user