@tiens.nguyen/gonext-local-worker 1.0.79 → 1.0.80

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.
@@ -204,18 +204,27 @@ def _summarize_result(task_text: str, agent_output: str,
204
204
  return agent_output
205
205
 
206
206
 
207
- def _plain_reply(task_text: str, base_url: str, api_key: str, model_id: str) -> str:
208
- """Plain chat completion without any tools."""
207
+ def _plain_reply(messages: list, base_url: str, api_key: str, model_id: str) -> str:
208
+ """Plain chat completion using the full conversation history."""
209
+ _THINK_RE_LOCAL = re.compile(r"<think>.*?</think>", re.DOTALL | re.IGNORECASE)
210
+ chat_messages = [{"role": "system", "content": "You are a helpful assistant."}]
211
+ for m in messages:
212
+ role = m.get("role", "")
213
+ content = m.get("content", "")
214
+ if role not in ("user", "assistant"):
215
+ continue
216
+ if role == "assistant":
217
+ content = _THINK_RE_LOCAL.sub("", content).strip()
218
+ if not content:
219
+ continue
220
+ chat_messages.append({"role": role, "content": content})
209
221
  try:
210
222
  from openai import OpenAI
211
223
  client = OpenAI(base_url=base_url, api_key=api_key or "local",
212
224
  max_retries=0, timeout=60)
213
225
  resp = client.chat.completions.create(
214
226
  model=model_id,
215
- messages=[
216
- {"role": "system", "content": "You are a helpful assistant."},
217
- {"role": "user", "content": task_text},
218
- ],
227
+ messages=chat_messages,
219
228
  temperature=0.7,
220
229
  max_tokens=512,
221
230
  )
@@ -268,7 +277,7 @@ def run_agent_chat(cfg):
268
277
 
269
278
  if not needs_agent:
270
279
  _log("router: plain chat (no HTTP needed)")
271
- answer = _plain_reply(task_text, agent_base_url, agent_api_key, agent_model_id)
280
+ answer = _plain_reply(messages, agent_base_url, agent_api_key, agent_model_id)
272
281
  _log(f"plain reply: {len(answer)} chars")
273
282
  _emit({"type": "final", "text": answer})
274
283
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
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",