@tiens.nguyen/gonext-local-worker 1.0.143 → 1.0.144
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_agent_chat.py +14 -0
- package/package.json +1 -1
package/gonext_agent_chat.py
CHANGED
|
@@ -1872,10 +1872,13 @@ def run_agent_chat(cfg):
|
|
|
1872
1872
|
# Ollama honors it). Harmless if the server ignores it — usage stays 0.
|
|
1873
1873
|
completion_kwargs["stream_options"] = {"include_usage": True}
|
|
1874
1874
|
self._apply_rate_limit()
|
|
1875
|
+
t0 = time.monotonic()
|
|
1876
|
+
_log("streamed generate: request issued (stream=True), awaiting first token…")
|
|
1875
1877
|
stream = self.client.chat.completions.create(**completion_kwargs)
|
|
1876
1878
|
parts = []
|
|
1877
1879
|
role = "assistant"
|
|
1878
1880
|
in_tok = out_tok = 0
|
|
1881
|
+
first_token_at = None
|
|
1879
1882
|
for chunk in stream:
|
|
1880
1883
|
usage = getattr(chunk, "usage", None)
|
|
1881
1884
|
if usage is not None:
|
|
@@ -1891,6 +1894,17 @@ def run_agent_chat(cfg):
|
|
|
1891
1894
|
role = delta.role
|
|
1892
1895
|
piece = getattr(delta, "content", None)
|
|
1893
1896
|
if piece:
|
|
1897
|
+
if first_token_at is None:
|
|
1898
|
+
# First streamed byte. The gap t0→here is pure prompt-eval time
|
|
1899
|
+
# (server sent nothing before this); everything after is token
|
|
1900
|
+
# generation with bytes flowing, so the proxy idle timer resets.
|
|
1901
|
+
# If this line never appears in the log, the request died in
|
|
1902
|
+
# prompt-eval BEFORE any token — streaming can't help there
|
|
1903
|
+
# (shrink the model / warm the prompt cache instead).
|
|
1904
|
+
first_token_at = time.monotonic()
|
|
1905
|
+
_log(f"streamed generate: FIRST token after {first_token_at - t0:.1f}s "
|
|
1906
|
+
"(prompt-eval done; tokens now flowing)")
|
|
1907
|
+
_emit({"type": "step", "text": "Model is responding…"})
|
|
1894
1908
|
parts.append(piece)
|
|
1895
1909
|
content = "".join(parts)
|
|
1896
1910
|
if stop_sequences and not self.supports_stop_parameter:
|
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.144",
|
|
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",
|