{"record":{"id":"89af705ecd9d9bda","repo":"binary-husky/gpt_academic","slug":"error-89af70","errorCode":null,"errorMessage":"error","messagePattern":"error","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"request_llms/bridge_jittorllms_pangualpha.py","lineNumber":122,"sourceCode":"        self.threadLock.release()\n\nglobal pangu_glm_handle\npangu_glm_handle = None\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    global pangu_glm_handle\n    if pangu_glm_handle is None:\n        pangu_glm_handle = GetGLMHandle()\n        if len(observe_window) >= 1: observe_window[0] = load_message + \"\\n\\n\" + pangu_glm_handle.info\n        if not pangu_glm_handle.success:\n            error = pangu_glm_handle.info\n            pangu_glm_handle = None\n            raise RuntimeError(error)\n\n    # jittorllms 没有 sys_prompt 接口，因此把prompt加入 history\n    history_feedin = []\n    for i in range(len(history)//2):\n        history_feedin.append([history[2*i], history[2*i+1]] )\n\n    watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可\n    response = \"\"\n    for response in pangu_glm_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=sys_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):\n        print(response)\n        if len(observe_window) >= 1:  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\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_jittorllms_pangualpha.py#L104-L140","documentation":"In pangu_predict_no_ui_long_connection, when pangu_glm_handle is first created its loader subprocess runs; if loading failed, GetGLMHandle().success is False and handle.info holds the loader's status text (e.g. '[Local Message] Call jittorllms fail ...'). The code resets the global handle to None and re-raises that info as RuntimeError(error), so the message 'error' is just whatever info contained.","triggerScenarios":"Calling pangu_predict_no_ui_long_connection for the first time in a process while the JittorLLMs PanGu-Alpha loader fails (bad deps, weights, device) — handle.success stays False and handle.info is re-raised verbatim.","commonSituations":"Same root causes as the loader failure: missing jittorllms environment, failed checkpoint download, CUDA issue; the user sees an opaque message because info was empty/generic at that point.","solutions":["Inspect newbing/pangu handle.info printed into observe_window[0] (load_message + handle.info) — it carries the actual loader message.","Run the loader manually (from request_llms.jittorllms.models import get_model) to get the true traceback and fix it.","Verify deps, weights, LOCAL_MODEL_DEVICE, and GPU memory.","If the model is unusable in your environment, select a different LLM in the UI instead of the pangualpha entry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = pangu_predict_no_ui_long_connection(...)\nexcept RuntimeError as e:\n    # e.args[0] is handle.info from the failed loader; log and surface to chatbot\n    chatbot.append(('system', f'pangualpha unavailable: {e}'))","preventionTips":["Read observe_window[0] — it carries load_message + handle.info before the raise","Validate the loader at startup, not lazily at first request","Keep the global handle reset-to-None semantics so the next call retries the load"],"tags":["jittorllms","pangualpha","local-model","model-loading","error-propagation"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}