{"record":{"id":"9dc91df1c8a8f586","repo":"binary-husky/gpt_academic","slug":"endpoint-azure-endpoint-endpoint","errorCode":null,"errorMessage":"Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:","messagePattern":"Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_chatgpt.py","lineNumber":125,"sourceCode":"    try:\n        chunkjson = json.loads(chunk_decoded[6:])\n        has_choices = 'choices' in chunkjson\n        if has_choices: choice_valid = (len(chunkjson['choices']) > 0)\n        if has_choices and choice_valid: has_content = (\"content\" in chunkjson['choices'][0][\"delta\"])\n        if has_content: has_content = (chunkjson['choices'][0][\"delta\"][\"content\"] is not None)\n        if has_choices and choice_valid: has_role = \"role\" in chunkjson['choices'][0][\"delta\"]\n    except:\n        pass\n    return chunk_decoded, chunkjson, has_choices, choice_valid, has_content, has_role\n\nfrom functools import lru_cache\n@lru_cache(maxsize=32)\ndef verify_endpoint(endpoint):\n    \"\"\"\n        检查endpoint是否可用\n    \"\"\"\n    if \"你亲手写的api名称\" in endpoint:\n        raise ValueError(\"Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:\" + endpoint)\n    return endpoint\n\ndef predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], sys_prompt:str=\"\", observe_window:list=None, console_silence:bool=False):\n    \"\"\"\n    发送至chatGPT，等待回复，一次性完成，不显示中间过程。但内部用stream的方法避免中途网线被掐。\n    inputs：\n        是本次问询的输入\n    sys_prompt:\n        系统静默prompt\n    llm_kwargs：\n        chatGPT的内部调优参数\n    history：\n        是之前的对话列表\n    observe_window = None：\n        用于负责跨越线程传递已经输出的部分，大部分时候仅仅为了fancy的视觉效果，留空即可。observe_window[0]：观测窗。observe_window[1]：看门狗\n    \"\"\"\n    from request_llms.bridge_all import model_info\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_chatgpt.py#L107-L143","documentation":"verify_endpoint is an lru_cache-decorated guard in the ChatGPT bridge that rejects Azure OpenAI endpoints still containing the literal placeholder text '你亲手写的api名称' ('the api name you wrote by hand') from config.py's AZURE_ENDPOINT template. It throws ValueError to force the user to finish editing their Azure configuration before any HTTP request is made. The error exists because Azure deployments require a fully specified deployment URL and unfilled placeholders are a very common copy-paste mistake.","triggerScenarios":"Selecting an 'azure-*' model in gpt_academic while AZURE_ENDPOINT (or the AZURE_CFG_ARRAY entry for that model in config_private.py) still contains the placeholder string '你亲手写的api名称' that ships in the default config.py; verify_endpoint(endpoint) is then called before the request and raises.","commonSituations":"User copies config.py to config_private.py, fills in AZURE_API_KEY but forgets to replace the endpoint template; switching from OpenAI official API to an Azure deployment without reading the Azure config section; config upgraded and the old placeholder survived.","solutions":["Open config_private.py and set AZURE_ENDPOINT (and the model's entry in AZURE_CFG_ARRAY) to your real deployment URL, e.g. https://your-resource.openai.azure.com/openai/deployments/your-deployment/chat/completions?api-version=2023-05-15.","Make sure the deployment name in the URL matches the deployment you created in the Azure portal.","Verify no AZURE_CFG_ARRAY key still holds the placeholder string '你亲手写的api名称'.","Restart gpt_academic after saving config_private.py so the lru_cache on verify_endpoint is cleared."],"exampleFix":"# before\nAZURE_ENDPOINT = \"https://你亲手写的api名称.openai.azure.com/openai/deployments/你亲手写的api名称/chat/completions?api-version=2023-05-15\"\n\n# after\nAZURE_ENDPOINT = \"https://my-resource.openai.azure.com/openai/deployments/gpt35/chat/completions?api-version=2023-05-15\"","handlingStrategy":"validation","validationCode":"from request_llms.bridge_chatgpt import verify_endpoint\nendpoint = AZURE_CFG_ARRAY[model][\"AZURE_ENDPOINT\"]\nassert \"你亲手写的api名称\" not in endpoint, \"fill in the real Azure deployment URL first\"","typeGuard":null,"tryCatchPattern":"try:\n    verify_endpoint(endpoint)\nexcept ValueError as e:\n    print(f\"config incomplete: {e}\"); exit(1)","preventionTips":["Never ship config_private.py containing template placeholders — grep for 你亲手写的api名称 before startup.","Add a startup config lint that walks AZURE_CFG_ARRAY and fails fast with the offending key name.","Document the exact Azure URL shape (resource/deployment/api-version) next to the config entry.","Restart the app after config edits so lru_cache caches don't hide fixes."],"tags":["azure","openai","configuration","endpoint","placeholder"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}