{"record":{"id":"b44d6e59461b6e37","repo":"binary-husky/gpt_academic","slug":"taichu-api-key","errorCode":null,"errorMessage":"请配置 TAICHU_API_KEY","messagePattern":"请配置 TAICHU_API_KEY","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_taichu.py","lineNumber":28,"sourceCode":"def validate_key():\n    TAICHU_API_KEY = get_conf(\"TAICHU_API_KEY\")\n    if TAICHU_API_KEY == '': return False\n    return True\n\ndef predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], sys_prompt:str=\"\",\n                                  observe_window:list=[], console_silence:bool=False):\n    \"\"\"\n        ⭐多线程方法\n        函数的说明请见 request_llms/bridge_all.py\n    \"\"\"\n    watch_dog_patience = 5\n    response = \"\"\n\n    # if llm_kwargs[\"llm_model\"] == \"taichu\":\n    #     llm_kwargs[\"llm_model\"] = \"taichu\"\n\n    if validate_key() is False:\n        raise RuntimeError('请配置 TAICHU_API_KEY')\n\n    # 开始接收回复\n    from .com_taichu import TaichuChatInit\n    zhipu_bro_init = TaichuChatInit()\n    for chunk, response in zhipu_bro_init.generate_chat(inputs, llm_kwargs, history, sys_prompt):\n        if len(observe_window) >= 1:\n            observe_window[0] = response\n        if len(observe_window) >= 2:\n            if (time.time() - observe_window[1]) > watch_dog_patience:\n                raise RuntimeError(\"程序终止。\")\n    return response\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        ⭐单线程方法\n        函数的说明请见 request_llms/bridge_all.py","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_taichu.py#L10-L46","documentation":"Configuration guard of the Taichu (太极/taichu) LLM bridge: predict_no_ui_long_connection raises RuntimeError('请配置 TAICHU_API_KEY') when validate_key() finds the TAICHU_API_KEY config value empty. It fires before TaichuChatInit is imported, so no network traffic has occurred.","triggerScenarios":"Calling request_llms/bridge_taichu.py:28 predict_no_ui_long_connection() (used by background/plugin threads) with TAICHU_API_KEY == '' as resolved by get_conf from config.py, config_private.py or the environment.","commonSituations":"Default config.py ships with an empty TAICHU_API_KEY; user selected the taichu model without registering on the Taichu open platform; key placed in config.py but a config_private.py or env var overrides it with an empty string.","solutions":["Obtain an API key from the Taichu open platform and set TAICHU_API_KEY in config_private.py (or env / docker-compose), then restart","Confirm the loaded value: from toolbox import get_conf; assert get_conf('TAICHU_API_KEY') != ''","If using docker, add TAICHU_API_KEY to the container environment"],"exampleFix":"# before\nTAICHU_API_KEY = ''\n\n# after (config_private.py)\nTAICHU_API_KEY = 'your-taichu-key'","handlingStrategy":"validation","validationCode":"from toolbox import get_conf\nassert get_conf('TAICHU_API_KEY'), 'TAICHU_API_KEY not configured'","typeGuard":null,"tryCatchPattern":"try:\n    predict_no_ui_long_connection(...)\nexcept RuntimeError as e:\n    if 'TAICHU_API_KEY' in str(e):\n        raise ConfigurationError(str(e)) from e\n    raise","preventionTips":["Configure only the providers you actually use; keep a checklist per model","Validate keys in a preflight hook before dispatching to a bridge"],"tags":["config","authentication","taichu","llm-bridge"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}