{"record":{"id":"89c8ad00aaaa1130","repo":"binary-husky/gpt_academic","slug":"azure","errorCode":null,"errorMessage":"由于提问含不合规内容被Azure过滤。","messagePattern":"由于提问含不合规内容被Azure过滤。","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_openrouter.py","lineNumber":202,"sourceCode":"        json_data = chunkjson['choices'][0]\n        delta = json_data[\"delta\"]\n        if len(delta) == 0: break\n        if (not has_content) and has_role: continue\n        if (not has_content) and (not has_role): continue # raise RuntimeError(\"发现不标准的第三方接口：\"+delta)\n        if has_content: # has_role = True/False\n            result += delta[\"content\"]\n            if not console_silence: print(delta[\"content\"], end='')\n            if observe_window is not None:\n                # 观测窗，把已经获取的数据显示出去\n                if len(observe_window) >= 1:\n                    observe_window[0] += delta[\"content\"]\n                # 看门狗，如果超过期限没有喂狗，则终止\n                if len(observe_window) >= 2:\n                    if (time.time()-observe_window[1]) > watch_dog_patience:\n                        raise RuntimeError(\"用户取消了程序。\")\n        else: raise RuntimeError(\"意外Json结构：\"+delta)\n    if json_data and json_data['finish_reason'] == 'content_filter':\n        raise RuntimeError(\"由于提问含不合规内容被Azure过滤。\")\n    if json_data and json_data['finish_reason'] == 'length':\n        raise ConnectionAbortedError(\"正常结束，但显示Token不足，导致输出不完整，请削减单次输入的文本量。\")\n    return result\n\n\ndef predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWithCookies,\n            history:list=[], system_prompt:str='', stream:bool=True, additional_fn:str=None):\n    \"\"\"\n    发送至chatGPT，流式获取输出。\n    用于基础的对话功能。\n    inputs 是本次问询的输入\n    top_p, temperature是chatGPT的内部调优参数\n    history 是之前的对话列表（注意无论是inputs还是history，内容太长了都会触发token数量溢出的错误）\n    chatbot 为WebUI中显示的对话列表，修改它，然后yield出去，可以直接修改对话界面内容\n    additional_fn代表点击的哪个按钮，按钮见functional.py\n    \"\"\"\n    from request_llms.bridge_all import model_info\n    if is_any_api_key(inputs):","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_openrouter.py#L184-L220","documentation":"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.","triggerScenarios":"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.","commonSituations":"Academic/medical/violence-adjacent text triggering false positives; strict default Azure content filters on a new deployment; prompt-injection-like payloads being filtered.","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"],"exampleFix":"# before\nresp = predict(inputs, llm_kwargs, ...)\n\n# after\ntry:\n    resp = predict(inputs, llm_kwargs, ...)\nexcept RuntimeError as e:\n    if '不合规内容' in str(e):\n        chatbot[-1] = (chatbot[-1][0], '[Local Message] 请求被内容安全策略拦截，请改写后重试。')\n        yield from update_ui(chatbot)\n        return","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def finish_reason_is_filter(json_data) -> bool:\n    return bool(json_data) and json_data.get('finish_reason') == 'content_filter'","tryCatchPattern":"try:\n    result = predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history)\nexcept RuntimeError as e:\n    if '不合规内容' in str(e):\n        chatbot[-1] = (chatbot[-1][0], '[Local Message] 内容被安全过滤，请改写提问后重试。')\n        yield from update_ui(chatbot)\n        return\n    raise","preventionTips":["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"],"tags":["azure","content-filter","moderation","openrouter"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}