summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMichael Peter Christen <mc@yacy.net>2026-07-05 12:43:45 +0200
committerMichael Peter Christen <mc@yacy.net>2026-07-05 12:43:45 +0200
commit6c6148c77360321b0a02568358598f315e66ee55 (patch)
tree12107b44af94af35333ae252c8702d7edc90c1bc /source
parente6d5aed331a190334e6a105af8b6b00e71d07fa1 (diff)
setting max_tokens per model
Diffstat (limited to 'source')
-rw-r--r--source/net/yacy/ai/LLM.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/net/yacy/ai/LLM.java b/source/net/yacy/ai/LLM.java
index 5af3cd276..6bdeaef38 100644
--- a/source/net/yacy/ai/LLM.java
+++ b/source/net/yacy/ai/LLM.java
@@ -370,6 +370,12 @@ public class LLM {
data.put("model", model);
data.put("temperature", 0.1);
data.put("max_tokens", max_tokens);
+ // Best-effort hint for Ollama's context window (num_ctx). Ollama's
+ // OpenAI-compatible endpoint does not read this today and pure-OpenAI
+ // backends ignore unknown fields, so it is a harmless forward-looking
+ // hedge; the reliable way to raise the context window remains
+ // OLLAMA_CONTEXT_LENGTH or a Modelfile PARAMETER num_ctx.
+ data.put("num_ctx", max_tokens);
data.put("messages", context);
data.put("stop", new JSONArray(STOPTOKENS));
data.put("stream", false);
@@ -448,6 +454,8 @@ public class LLM {
data.put("model", model);
data.put("temperature", 0.1);
data.put("max_tokens", max_tokens);
+ // best-effort num_ctx hint, see chat(); harmless to non-Ollama backends
+ data.put("num_ctx", max_tokens);
data.put("messages", context);
data.put("stop", new JSONArray(STOPTOKENS));
data.put("stream", true);