diff --git a/core/src/main/java/com/google/adk/models/OllamaBaseLM.java b/core/src/main/java/com/google/adk/models/OllamaBaseLM.java index cdd7834a9..8a42cf9e4 100644 --- a/core/src/main/java/com/google/adk/models/OllamaBaseLM.java +++ b/core/src/main/java/com/google/adk/models/OllamaBaseLM.java @@ -63,6 +63,9 @@ public class OllamaBaseLM extends BaseLlm { public static String OLLAMA_EP = "OLLAMA_API_BASE"; public String D_URL = null; + private int numCtx = 32768; + private boolean think = false; + // Corrected the logger name to use OllamaBaseLM.class private static final Logger logger = LoggerFactory.getLogger(OllamaBaseLM.class); @@ -81,6 +84,22 @@ public OllamaBaseLM(String model, String OLLAMA_EP) { this.D_URL = OLLAMA_EP; } + public int getNumCtx() { + return numCtx; + } + + public void setNumCtx(int numCtx) { + this.numCtx = numCtx; + } + + public boolean isThink() { + return think; + } + + public void setThink(boolean think) { + this.think = think; + } + @Override public Flowable generateContent(LlmRequest llmRequest, boolean stream) { if (stream) { @@ -665,10 +684,10 @@ public BufferedReader callLLMChatStream(String model, JSONArray messages, JSONAr JSONObject payload = new JSONObject(); payload.put("model", model); payload.put("stream", true); - payload.put("think", false); + payload.put("think", this.think); JSONObject options = new JSONObject(); - options.put("num_ctx", 4096); + options.put("num_ctx", this.numCtx); payload.put("options", options); payload.put("messages", messages); @@ -835,10 +854,10 @@ public JSONObject callLLMChat( payload.put("model", model); payload.put( "stream", false); // Assuming non-streaming as per current generateContent implementation - payload.put("think", false); + payload.put("think", this.think); JSONObject options = new JSONObject(); - options.put("num_ctx", 4096); + options.put("num_ctx", this.numCtx); payload.put("options", options); payload.put("temperature", temperature);