@tiens.nguyen/gonext-local-worker 1.0.138 → 1.0.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gonext-local-worker.mjs +9 -8
- package/gonext_agent_chat.py +33 -4
- package/package.json +1 -1
package/gonext-local-worker.mjs
CHANGED
|
@@ -1526,14 +1526,15 @@ async function runAgentChatJob(job) {
|
|
|
1526
1526
|
emailFrom: payload?.emailFrom ?? "",
|
|
1527
1527
|
emailAllowList: payload?.emailAllowList ?? "",
|
|
1528
1528
|
});
|
|
1529
|
-
//
|
|
1530
|
-
// or a remote Ollama box cold-loading a big model — can
|
|
1531
|
-
// stay BELOW the web client's hard WS deadline
|
|
1532
|
-
// reaches the user instead of a generic
|
|
1533
|
-
// SIGKILLed, which also shows up as a
|
|
1534
|
-
// (expected). Liveness during long model
|
|
1535
|
-
// (a keepalive step chunk every 45s), not
|
|
1536
|
-
|
|
1529
|
+
// 30 min max for an agent run: multi-step ReAct on a 14B/31B with a cold prompt
|
|
1530
|
+
// cache — or a remote Ollama box on slow GPU cold-loading a big model — can run
|
|
1531
|
+
// for many minutes per step. Must stay BELOW the web client's hard WS deadline
|
|
1532
|
+
// (1_860_000 ms) so our clean timeout error reaches the user instead of a generic
|
|
1533
|
+
// WS timeout. On expiry the python child is SIGKILLed, which also shows up as a
|
|
1534
|
+
// BrokenPipeError in the model server log (expected). Liveness during long model
|
|
1535
|
+
// calls comes from the python heartbeat (a keepalive step chunk every 45s), not
|
|
1536
|
+
// from this cap.
|
|
1537
|
+
const timeoutMs = 1_800_000;
|
|
1537
1538
|
|
|
1538
1539
|
let inThink = false;
|
|
1539
1540
|
let finalText = "";
|
package/gonext_agent_chat.py
CHANGED
|
@@ -398,6 +398,24 @@ def _list_model_ids(base_url, api_key=""):
|
|
|
398
398
|
if isinstance(d, dict) and isinstance(d.get("id"), str) and d["id"].strip()]
|
|
399
399
|
|
|
400
400
|
|
|
401
|
+
def _is_ollama_server(base_url):
|
|
402
|
+
"""True if the OpenAI-compatible base URL is an Ollama server.
|
|
403
|
+
|
|
404
|
+
Ollama's root path answers GET / with the plain-text banner "Ollama is
|
|
405
|
+
running". Used to gate Ollama-only request params (reasoning_effort) that an
|
|
406
|
+
MLX server might reject.
|
|
407
|
+
"""
|
|
408
|
+
root = re.sub(r"/v1/?$", "", (base_url or "").rstrip("/"))
|
|
409
|
+
if not root:
|
|
410
|
+
return False
|
|
411
|
+
req = urllib.request.Request(root, headers={"User-Agent": "gonext-agent/1.0"})
|
|
412
|
+
try:
|
|
413
|
+
with urllib.request.urlopen(req, timeout=6, context=_ssl_context()) as resp:
|
|
414
|
+
return b"ollama" in resp.read(200).lower()
|
|
415
|
+
except Exception: # noqa: BLE001
|
|
416
|
+
return False
|
|
417
|
+
|
|
418
|
+
|
|
401
419
|
def _detect_model_id(base_url, api_key=""):
|
|
402
420
|
"""Ask an OpenAI-compatible server which model it serves (first reported id).
|
|
403
421
|
|
|
@@ -1948,16 +1966,27 @@ def run_agent_chat(cfg):
|
|
|
1948
1966
|
return ChatMessage(role=MessageRole.ASSISTANT, content=text)
|
|
1949
1967
|
|
|
1950
1968
|
try:
|
|
1969
|
+
# Ollama's OpenAI-compat endpoint ignores Qwen3's /no_think soft-switch (its
|
|
1970
|
+
# template forces thinking mode; "think": false is also ignored there) but DOES
|
|
1971
|
+
# honor reasoning_effort="none". Thinking burned ~430 of 487 output tokens in
|
|
1972
|
+
# the live test — minutes per step on a slow GPU — so disable it explicitly.
|
|
1973
|
+
# Sniffed per-server because MLX might reject the unknown param.
|
|
1974
|
+
extra_model_kwargs = {}
|
|
1975
|
+
if _is_ollama_server(coding_base_url):
|
|
1976
|
+
_log("coding server is Ollama → sending reasoning_effort='none' to disable thinking")
|
|
1977
|
+
extra_model_kwargs["reasoning_effort"] = "none"
|
|
1951
1978
|
model = _LoggingModel(
|
|
1952
1979
|
model_id=coding_model_id,
|
|
1953
1980
|
api_base=coding_base_url,
|
|
1954
1981
|
api_key=agent_api_key,
|
|
1955
|
-
# Cap each HTTP attempt at
|
|
1956
|
-
#
|
|
1957
|
-
# the
|
|
1982
|
+
# Cap each HTTP attempt at 600s so a genuinely slow single call (a
|
|
1983
|
+
# remote M6000/Vulkan box doing a cold ~4-5min prompt-eval) can finish
|
|
1984
|
+
# on the first try, while a truly hung request still fails into OUR
|
|
1985
|
+
# retry loop rather than eating the whole 30min worker budget.
|
|
1958
1986
|
# max_retries=0: the openai client's own silent retries would otherwise
|
|
1959
1987
|
# stack multiplicatively with ours (3 × 3 attempts).
|
|
1960
|
-
client_kwargs={"timeout":
|
|
1988
|
+
client_kwargs={"timeout": 600.0, "max_retries": 0},
|
|
1989
|
+
**extra_model_kwargs,
|
|
1961
1990
|
)
|
|
1962
1991
|
agent_tools = [http_request, web_search, fetch_url, calculate,
|
|
1963
1992
|
get_current_datetime, create_pdf]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gonext-local-worker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.140",
|
|
4
4
|
"description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|