binary-husky/gpt_academic · error · RuntimeError
由于提问含不合规内容被Azure过滤。
Error message
由于提问含不合规内容被Azure过滤。
What it means
RuntimeError raised after the OpenRouter stream completes when the final chunk's finish_reason is 'content_filter': the upstream (typically Azure OpenAI content safety) blocked the response. No partial result is returned; the exception is the only signal. Despite living in bridge_openrouter, the message text is Azure-specific because the bridge reuses Azure handling logic.
Source
Thrown at request_llms/bridge_openrouter.py:202
json_data = chunkjson['choices'][0]
delta = json_data["delta"]
if len(delta) == 0: break
if (not has_content) and has_role: continue
if (not has_content) and (not has_role): continue # raise RuntimeError("发现不标准的第三方接口:"+delta)
if has_content: # has_role = True/False
result += delta["content"]
if not console_silence: print(delta["content"], end='')
if observe_window is not None:
# 观测窗,把已经获取的数据显示出去
if len(observe_window) >= 1:
observe_window[0] += delta["content"]
# 看门狗,如果超过期限没有喂狗,则终止
if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("用户取消了程序。")
else: raise RuntimeError("意外Json结构:"+delta)
if json_data and json_data['finish_reason'] == 'content_filter':
raise RuntimeError("由于提问含不合规内容被Azure过滤。")
if json_data and json_data['finish_reason'] == 'length':
raise ConnectionAbortedError("正常结束,但显示Token不足,导致输出不完整,请削减单次输入的文本量。")
return result
def predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWithCookies,
history:list=[], system_prompt:str='', stream:bool=True, additional_fn:str=None):
"""
发送至chatGPT,流式获取输出。
用于基础的对话功能。
inputs 是本次问询的输入
top_p, temperature是chatGPT的内部调优参数
history 是之前的对话列表(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误)
chatbot 为WebUI中显示的对话列表,修改它,然后yield出去,可以直接修改对话界面内容
additional_fn代表点击的哪个按钮,按钮见functional.py
"""
from request_llms.bridge_all import model_info
if is_any_api_key(inputs):View on GitHub (pinned to d6bde0fa54)
Solutions
- Rephrase the sensitive part of the input and retry
- If you own the Azure deployment, relax the content filter categories/thresholds in Azure OpenAI Studio
- Switch to a non-Azure provider for that model via OpenRouter routing
- Catch RuntimeError and surface a friendly 'request blocked by content filter' message instead of a stack trace
Example fix
# before
resp = predict(inputs, llm_kwargs, ...)
# after
try:
resp = predict(inputs, llm_kwargs, ...)
except RuntimeError as e:
if '不合规内容' in str(e):
chatbot[-1] = (chatbot[-1][0], '[Local Message] 请求被内容安全策略拦截,请改写后重试。')
yield from update_ui(chatbot)
return Defensive patterns
Strategy: try-catch
Type guard
def finish_reason_is_filter(json_data) -> bool:
return bool(json_data) and json_data.get('finish_reason') == 'content_filter' Try / catch
try:
result = predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history)
except RuntimeError as e:
if '不合规内容' in str(e):
chatbot[-1] = (chatbot[-1][0], '[Local Message] 内容被安全过滤,请改写提问后重试。')
yield from update_ui(chatbot)
return
raise Prevention
- Do not auto-retry a filtered prompt - rewrite it instead
- If self-hosting on Azure, tune content filter thresholds per deployment
- Route sensitive-but-legitimate academic topics through a non-Azure provider
When it happens
Trigger: Prompt or generated output trips Azure's content moderation filter (finish_reason='content_filter'); sending content in a regulated category for the deployment's filter policy; routing via OpenRouter to an Azure-backed provider slot.
Common situations: Academic/medical/violence-adjacent text triggering false positives; strict default Azure content filters on a new deployment; prompt-injection-like payloads being filtered.
Related errors
- 由于提问含不合规内容被过滤。
- Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:{endpoint}
- AZURE_CFG_ARRAY中配置的模型必须以azure开头
- Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:
- Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/89c8ad00aaaa1130.
Report an issue: GitHub.