Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions core/src/main/java/com/google/adk/models/OllamaBaseLM.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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<LlmResponse> generateContent(LlmRequest llmRequest, boolean stream) {
if (stream) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
Loading