{"record":{"id":"0b48d73c2312a3c8","repo":"binary-husky/gpt_academic","slug":"xfyun-appid-xfyun-api-key-xfyun-api-s","errorCode":null,"errorMessage":"请配置讯飞星火大模型的XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET","messagePattern":"请配置讯飞星火大模型的XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_spark.py","lineNumber":26,"sourceCode":"model_name = '星火认知大模型'\n\ndef validate_key():\n    XFYUN_APPID = get_conf('XFYUN_APPID')\n    if XFYUN_APPID == '00000000' or XFYUN_APPID == '':\n        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 validate_key() is False:\n        raise RuntimeError('请配置讯飞星火大模型的XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET')\n\n    from .com_sparkapi import SparkRequestInstance\n    sri = SparkRequestInstance()\n    for response in sri.generate(inputs, llm_kwargs, history, sys_prompt, use_image_api=False):\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: raise RuntimeError(\"程序终止。\")\n    return response\n\ndef predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):\n    \"\"\"\n        ⭐单线程方法\n        函数的说明请见 request_llms/bridge_all.py\n    \"\"\"\n    chatbot.append((inputs, \"\"))\n    yield from update_ui(chatbot=chatbot, history=history)\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_spark.py#L8-L44","documentation":"Raised by the multi-thread entry point of the iFlytek Spark (讯飞星火) bridge when validate_key() returns False, i.e. the XFYUN_APPID / XFYUN_API_KEY / XFYUN_API_SECRET configuration values read via get_conf() are empty. It is a fail-fast configuration guard thrown before any network call to the Spark WebSocket API is made.","triggerScenarios":"Calling predict_no_ui_long_connection() from request_llms/bridge_spark.py when one or more of the XFYUN_APPID, XFYUN_API_KEY, XFYUN_API_SECRET keys resolve to '' in config.py / config_private.py / environment variables. This path is used by plugins that run the LLM in a worker thread.","commonSituations":"Fresh clone where config.py still holds placeholder empty keys; docker-compose deployed without the XFYUN_* env vars; user set keys in the wrong file (e.g. a config_private.py that is gitignored but not created); typos in the variable names so get_conf falls back to the empty default.","solutions":["Set XFYUN_APPID, XFYUN_API_KEY and XFYUN_API_SECRET in config_private.py (or as environment variables / docker-compose env), then restart the service","Verify the values are non-empty at runtime: from toolbox import get_conf; assert all(get_conf('XFYUN_APPID','XFYUN_API_KEY','XFYUN_API_KEY'))","If running under docker, add the three variables to docker-compose.yml environment section and recreate the container","Make sure you edited the config actually loaded (config_private.py overrides config.py; env vars are read through shared_utils/config_loader.get_conf)"],"exampleFix":"# before (config_private.py)\nXFYUN_APPID = ''\nXFYUN_API_KEY = ''\nXFYUN_API_SECRET = ''\n\n# after\nXFYUN_APPID = 'your-app-id'\nXFYUN_API_KEY = 'your-api-key'\nXFYUN_API_SECRET = 'your-api-secret'","handlingStrategy":"validation","validationCode":"from toolbox import get_conf\nappid, sec, key = get_conf('XFYUN_APPID', 'XFYUN_API_SECRET', 'XFYUN_API_KEY')\nassert appid and sec and key, 'XFYUN credentials missing - set them in config_private.py'","typeGuard":null,"tryCatchPattern":"try:\n    predict_no_ui_long_connection(...)\nexcept RuntimeError as e:\n    if 'XFYUN' in str(e):\n        raise ConfigurationError('Spark credentials missing') from e\n    raise","preventionTips":["Keep all provider keys in config_private.py, never edit config.py defaults","Add a startup assertion that walks required keys per selected model","If using docker, template env vars so missing keys fail the container at boot"],"tags":["config","authentication","xfyun-spark","llm-bridge"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}