binary-husky/gpt_academic · error · RuntimeError

error

Error message

error

What it means

In newbing_predict_no_ui_long_connection: if the handle is None or its previous load failed (not .success), a new NewBingHandle() is created; when loading still fails, handle.info (e.g. the cookies error from error 136, the constructor error from error 137, or '等待NewBing响应中' era network failures) is captured as `error`, the handle is reset to None, and RuntimeError(error) re-raises it in the caller's thread.

Source

Thrown at request_llms/bridge_newbingfree.py:226

    llm_kwargs,
    history=[],
    sys_prompt="",
    observe_window=[],
    console_silence=False,
):
    """
    多线程方法
    函数的说明请见 request_llms/bridge_all.py
    """
    global newbingfree_handle
    if (newbingfree_handle is None) or (not newbingfree_handle.success):
        newbingfree_handle = NewBingHandle()
        if len(observe_window) >= 1:
            observe_window[0] = load_message + "\n\n" + newbingfree_handle.info
        if not newbingfree_handle.success:
            error = newbingfree_handle.info
            newbingfree_handle = None
            raise RuntimeError(error)

    # 没有 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 = ""
    if len(observe_window) >= 1:
        observe_window[0] = "[Local Message] 等待NewBing响应中 ..."
    for response in newbingfree_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"],
    ):

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Inspect newbingfree_handle.info / observe_window[0] — the raised text is exactly the loader's last message; address that root cause (cookies JSON, proxy, deps).
  2. Validate NEWBING_COOKIES with json.loads before letting the handle start.
  3. Fix the proxy config or disable USE_PROXY.
  4. Migrate off the NewBing backend — it is declared unmaintained in the error text itself.
Defensive patterns

Strategy: try-catch

Validate before calling

import json
def newbing_ready(cfg) -> bool:
    c = cfg.get('NEWBING_COOKIES')
    if c and len(c) > 100:
        try: json.loads(c)
        except json.JSONDecodeError: return False
    return True  # plus proxy URL sanity check

Try / catch

try:
    resp = newbing_predict_no_ui_long_connection(...)
except RuntimeError as e:
    chatbot.append(('system', f'NewBing unavailable: {e}'))  # e is handle.info; fix root cause

Prevention

When it happens

Trigger: First (or retry-after-failure) call to the NewBing streaming predict while the loader thread failed — bad cookies JSON, constructor/proxy failure, or the async NewBing request loop dying with a network error, leaving success=False and info populated.

Common situations: Expired NewBing cookies, changed upstream endpoints on an unmaintained component, unreachable proxy, or a previous failure leaving newbingfree_handle None so every call re-attempts the load.

Related errors


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