binary-husky/gpt_academic · critical · RuntimeError
error
Error message
error
What it means
In moss_predict_no_ui_long_connection: on first use the loader thread runs; if it failed, moss_handle.success is False and moss_handle.info holds the loader's status message (typically '[Local Message] Call MOSS fail 不能正常加载MOSS的参数。'). The code nulls the global handle and re-raises that info as RuntimeError(error).
Source
Thrown at request_llms/bridge_moss.py:187
self.threadLock.release()
global moss_handle
moss_handle = None
#################################################################################
def predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], sys_prompt:str="",
observe_window:list=[], console_silence:bool=False):
"""
多线程方法
函数的说明请见 request_llms/bridge_all.py
"""
global moss_handle
if moss_handle is None:
moss_handle = GetGLMHandle()
if len(observe_window) >= 1: observe_window[0] = load_message + "\n\n" + moss_handle.info
if not moss_handle.success:
error = moss_handle.info
moss_handle = None
raise RuntimeError(error)
# chatglm 没有 sys_prompt 接口,因此把prompt加入 history
history_feedin = []
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
response = ""
for response in moss_handle.stream_chat(query=inputs, history=history_feedin, sys_prompt=sys_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
if len(observe_window) >= 1: observe_window[0] = response
if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止。")
return response
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):View on GitHub (pinned to d6bde0fa54)
Solutions
- Read observe_window[0] (load_message + handle.info) — it carries the actual loader message shown before the raise.
- Run moss_init directly to capture the true traceback and fix env/weights/VRAM.
- Free GPU memory or use quantization; verify LOCAL_MODEL_DEVICE.
- Restart the app after fixing — the failed handle was reset to None and will retry on next call.
Defensive patterns
Strategy: try-catch
Try / catch
try:
resp = moss_predict_no_ui_long_connection(...)
except RuntimeError as e:
chatbot.append(('system', f'MOSS unavailable: {e}')) # e is handle.info Prevention
- Read observe_window[0] for the loader message
- Validate MOSS at startup, not first request
- Reset handle to None on failure so next call retries
When it happens
Trigger: First call to the MOSS streaming predict while the MOSS model failed to load in the background thread (weights/deps/VRAM), so handle.success is False at the check.
Common situations: Same as the MOSS loader failure: missing weights, incompatible transformers, CUDA OOM; the surfaced message is whatever info the thread had written when polled.
Related errors
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/8a22eb2ae1194155.
Report an issue: GitHub.