binary-husky/gpt_academic · error · RuntimeError

程序终止。

Error message

程序终止。

What it means

Watchdog inside the Taichu bridge's long-connection generator: if the time stored in observe_window[1] lags more than watch_dog_patience (5 s) behind wall-clock while TaichuChatInit.generate_chat streams chunks, the loop aborts with RuntimeError('程序终止。').

Source

Thrown at request_llms/bridge_taichu.py:38

    """
    watch_dog_patience = 5
    response = ""

    # if llm_kwargs["llm_model"] == "taichu":
    #     llm_kwargs["llm_model"] = "taichu"

    if validate_key() is False:
        raise RuntimeError('请配置 TAICHU_API_KEY')

    # 开始接收回复
    from .com_taichu import TaichuChatInit
    zhipu_bro_init = TaichuChatInit()
    for chunk, response in zhipu_bro_init.generate_chat(inputs, llm_kwargs, history, sys_prompt):
        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:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWithCookies,
            history:list=[], system_prompt:str='', stream:bool=True, additional_fn:str=None):
    """
        ⭐单线程方法
        函数的说明请见 request_llms/bridge_all.py
    """
    chatbot.append([inputs, ""])
    yield from update_ui(chatbot=chatbot, history=history)

    if validate_key() is False:
        yield from update_ui_latest_msg(lastmsg="[Local Message] 请配置ZHIPUAI_API_KEY", chatbot=chatbot, history=history, delay=0)
        return

    if additional_fn is not None:
        from core_functional import handle_core_functionality

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Retry — transient Taichu service latency is the usual cause
  2. Test the Taichu API directly (curl) with the same key to measure time-to-first-token
  3. Increase watch_dog_patience if first-token latency is legitimately >5 s
  4. Shorten history payload so the service responds faster

Example fix

# before
watch_dog_patience = 5

# after
watch_dog_patience = 30
Defensive patterns

Strategy: retry

Try / catch

try:
    ...
except RuntimeError as e:
    if str(e) == '程序终止。':
        return retry_once(predict_no_ui_long_connection, inputs, llm_kwargs, history, sys_prompt, observe_window)
    raise

Prevention

When it happens

Trigger: TaichuChatInit.generate_chat stalls between yields for >5 s (HTTP stream hang, server-side throttling, network drop) while running predict_no_ui_long_connection from request_llms/bridge_taichu.py:38.

Common situations: Slow Taichu endpoint under load; proxy stripping streaming responses; large history making first-token latency exceed 5 s; caller thread not refreshing observe_window[1].

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/ba1bd9f9b9494435. Report an issue: GitHub.