{"record":{"id":"e43d46fc750267e6","repo":"binary-husky/gpt_academic","slug":"error-e43d46","errorCode":null,"errorMessage":"程序终止。","messagePattern":"程序终止。","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"request_llms/bridge_newbingfree.py","lineNumber":249,"sourceCode":"        history_feedin.append([history[2 * i], history[2 * i + 1]])\n\n    watch_dog_patience = 5  # 看门狗 (watchdog) 的耐心, 设置5秒即可\n    response = \"\"\n    if len(observe_window) >= 1:\n        observe_window[0] = \"[Local Message] 等待NewBing响应中 ...\"\n    for response in newbingfree_handle.stream_chat(\n        query=inputs,\n        history=history_feedin,\n        system_prompt=sys_prompt,\n        max_length=llm_kwargs[\"max_length\"],\n        top_p=llm_kwargs[\"top_p\"],\n        temperature=llm_kwargs[\"temperature\"],\n    ):\n        if len(observe_window) >= 1:\n            observe_window[0] = preprocess_newbing_out_simple(response)\n        if len(observe_window) >= 2:\n            if (time.time() - observe_window[1]) > watch_dog_patience:\n                raise RuntimeError(\"程序终止。\")\n    return preprocess_newbing_out_simple(response)\n\n\ndef predict(\n    inputs,\n    llm_kwargs,\n    plugin_kwargs,\n    chatbot,\n    history=[],\n    system_prompt=\"\",\n    stream=True,\n    additional_fn=None,\n):\n    \"\"\"\n    单线程方法\n    函数的说明请见 request_llms/bridge_all.py\n    \"\"\"\n    chatbot.append((inputs, \"[Local Message] 等待NewBing响应中 ...\"))","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/bridge_newbingfree.py#L231-L267","documentation":"Watchdog abort for the NewBing stream: while iterating newbingfree_handle.stream_chat, if time.time() - observe_window[1] exceeds watch_dog_patience (5s) between yields, RuntimeError('程序终止。') is raised. The NewBing/Sydney protocol relies on websocket pushes that can be silent >5s (handshake, throttling, captcha challenges), tripping the dog.","triggerScenarios":"NewBing generation goes >5s without yielding a chunk: slow websocket to Microsoft endpoints, proxy latency, Bing throttling/challenge, or the loader thread's async loop stalled.","commonSituations":"Overseas proxy with high latency, Bing rate-limiting the account, stale cookies accepted at load then rejected mid-stream, patience left at 5s.","solutions":["Check the proxy route to bing.com and the handle's child messages for network errors; retry once.","Increase watch_dog_patience (30–60s) or update observe_window[1] on each received event.","Refresh NEWBING_COOKIES — stale sessions cause mid-stream hangs.","If it keeps tripping, move to a maintained backend; NewBing support is archived."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import time\nwindow = ['', time.time()]\n# refresh window[1] per poll; websocket pushes can be silent >5s","typeGuard":null,"tryCatchPattern":"try:\n    resp = newbing_predict_no_ui_long_connection(..., observe_window=window)\nexcept RuntimeError as e:\n    if '程序终止' in str(e):\n        window[1] = time.time()\n        resp = newbing_predict_no_ui_long_connection(..., observe_window=window)","preventionTips":["watch_dog_patience 30–60s for websocket-backed streams","Refresh cookies when streams hang mid-generation","Verify low-latency proxy route to bing.com"],"tags":["newbing","watchdog","timeout","streaming","network"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}