{"record":{"id":"9d3a43701173be78","repo":"binary-husky/gpt_academic","slug":"endpoint-azure-endpoint-endpoint-9d3a43","errorCode":null,"errorMessage":"Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:","messagePattern":"Endpoint不正确, 请检查AZURE_ENDPOINT的配置! 当前的Endpoint为:","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_cohere.py","lineNumber":68,"sourceCode":"    try:\n        chunkjson = json.loads(chunk_decoded)\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    发送，等待回复，一次性完成，不显示中间过程。但内部用stream的方法避免中途网线被掐。\n    inputs：\n        是本次问询的输入\n    sys_prompt:\n        系统静默prompt\n    llm_kwargs：\n        内部调优参数\n    history：\n        是之前的对话列表\n    observe_window = None：\n        用于负责跨越线程传递已经输出的部分，大部分时候仅仅为了fancy的视觉效果，留空即可。observe_window[0]：观测窗。observe_window[1]：看门狗\n    \"\"\"\n    watch_dog_patience = 5 # 看门狗的耐心, 设置5秒即可\n    headers, payload = generate_payload(inputs, llm_kwargs, history, system_prompt=sys_prompt, stream=True)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_cohere.py#L50-L86","documentation":"The Cohere bridge copies the ChatGPT bridge's verify_endpoint guard: an lru_cache function that raises ValueError if the endpoint string still contains the template placeholder '你亲手写的api名称' from config.py's Azure example. It fires before any request when an azure-* model was selected but the endpoint (or AZURE_CFG_ARRAY entry) was never actually filled in. Purpose: fail fast on unfinished Azure configuration rather than getting a confusing 404 later.","triggerScenarios":"Selecting an azure- model routed to the Cohere bridge while AZURE_ENDPOINT still contains '你亲手写的api名称'; copying config.py to config_private.py and filling the key but not the endpoint URL; AZURE_CFG_ARRAY retaining placeholder values after a config merge.","commonSituations":"Incomplete Azure setup for Cohere models via Azure gateways; config template placeholders surviving upgrades; users assuming the key alone is enough for azure- model names.","solutions":["Fill AZURE_ENDPOINT and the model's AZURE_CFG_ARRAY entry in config_private.py with the real deployment URL.","Confirm the deployment name and api-version query parameter match your Azure portal deployment.","Grep your config for the literal placeholder '你亲手写的api名称' to catch every unfilled field.","Restart gpt_academic so verify_endpoint's lru_cache doesn't serve stale state."],"exampleFix":"# config_private.py — before\nAZURE_ENDPOINT = \"https://你亲手写的api名称.openai.azure.com/...\"\n\n# after\nAZURE_ENDPOINT = \"https://cohere-resource.openai.azure.com/openai/deployments/cohere/chat/completions?api-version=2023-05-15\"","handlingStrategy":"validation","validationCode":"endpoint = AZURE_CFG_ARRAY[model][\"AZURE_ENDPOINT\"]\nassert \"你亲手写的api名称\" not in endpoint, \"Azure endpoint still contains the template placeholder\"","typeGuard":null,"tryCatchPattern":"try:\n    verify_endpoint(endpoint)\nexcept ValueError as e:\n    fail_fast_with_config_hint(str(e))","preventionTips":["Lint all AZURE_CFG_ARRAY entries for placeholder text at startup.","Copy working Azure endpoint examples rather than editing the template in place.","Restart after config changes to clear verify_endpoint's lru_cache.","Keep deployment names consistent between the portal and the URL."],"tags":["cohere","azure","configuration","endpoint","placeholder"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}