diff --git a/README.md b/README.md index ba07e19..b63d1ed 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ Local Ollama chat completion: ```properties category=M prompts= -tokenizer=jtokkit +tokenizer=jTokkit tokenEncoding=cl100k_base maxTokens=2500 maxContextLength=32768 @@ -337,7 +337,7 @@ modelProvider=OLLAMA Use `OAI_CHAT_COMPLETION` for cloud APIs such as OpenAI itself and for local or self-hosted servers that expose a compatible `/v1/chat/completions` interface. This is the preferred default because lm-lib can send the conversation directly, supports streaming, and exposes tool calls through the standard chat-completion flow. -Use `OAI_TEXT_COMPLETION` when you need explicit prompt templating or must target instruct-style models that still depend on raw prompt construction rather than structured chat messages. This is mainly useful for older compatible backends or local servers configured around prompt templates. +Use `OAI_TEXT_COMPLETION` when you need explicit prompt templating or must target instruct-style models that still depend on raw prompt construction rather than structured chat messages. This is mainly useful for older compatible backends, local servers configured around prompt templates, or if you need full control over the raw prompt that is sent to the LLM. OpenAI-compatible deployments commonly fall into two operational patterns: @@ -403,7 +403,7 @@ lm-lib caches `/api/show` model details per resolved model. Thinking and tool de Tool calling is exposed through the same lm-lib API across providers that support it. The capability is model-aware rather than purely provider-wide, so callers should check `supportsToolCalling(modelProfile)` or `supportsToolCalling(modelCategory)` on `Client` or `ClientService` before enabling tool-aware flows. -In practice, text-completion clients do not support tools, while chat-oriented clients may support them depending on the resolved backend and model. For Ollama, lm-lib probes cached `/api/show` capability metadata. For OpenAI-compatible chat providers, support is determined by the selected client type. +In practice, text-completion clients do not support tools via api (but you have full control over the raw prompt), while chat-oriented clients may support them depending on the resolved backend and model. For Ollama, lm-lib probes cached `/api/show` capability metadata. For OpenAI-compatible chat providers, support is determined by the selected client type. The library keeps the caller-facing tool-calling flow uniform even when providers differ internally. You still pass `ToolDefinition` and `ToolCallData`, inspect `CompletionFinishReason.TOOL_CALLS`, and append tool results through the same conversation API. If a backend does not expose every request-side control, lm-lib keeps the public API stable and applies those controls on a best-effort basis. diff --git a/src/main/java/de/extio/lmlib/client/ollama/OllamaClient.java b/src/main/java/de/extio/lmlib/client/ollama/OllamaClient.java index c719f97..4b95b54 100644 --- a/src/main/java/de/extio/lmlib/client/ollama/OllamaClient.java +++ b/src/main/java/de/extio/lmlib/client/ollama/OllamaClient.java @@ -40,6 +40,7 @@ import de.extio.lmlib.client.ToolCall; import de.extio.lmlib.client.ToolCallData; import de.extio.lmlib.client.ToolDefinition; import de.extio.lmlib.client.oai.completion.FinishReasons; +import de.extio.lmlib.client.ollama.OllamaDialect.ThinkMode; import de.extio.lmlib.profile.ModelCategory; import de.extio.lmlib.profile.ModelProfile; import de.extio.lmlib.profile.ModelProfile.ModelProvider; @@ -203,7 +204,7 @@ public class OllamaClient implements Client { request.setStream(streaming); final var think = this.createThinkRequestValue(modelProfile, modelDetails); if (think != null) { - request.setThink(think); + request.setThink(think.getWireValue()); } request.setOptions(this.createOptions(modelProfile)); if (toolCallData != null && toolCallData.hasTools()) { @@ -217,9 +218,9 @@ public class OllamaClient implements Client { return request; } - private Object createThinkRequestValue(final ModelProfile modelProfile, final OllamaShowResponse modelDetails) { + private ThinkMode createThinkRequestValue(final ModelProfile modelProfile, final OllamaShowResponse modelDetails) { final var thinkMode = this.getOllamaDialect().think(modelProfile); - if (thinkMode == null || !thinkMode.isEnabled()) { + if (thinkMode == null) { return null; } if (!this.supportsThinkingCapability(modelDetails)) { diff --git a/src/main/java/de/extio/lmlib/client/ollama/OllamaDialect.java b/src/main/java/de/extio/lmlib/client/ollama/OllamaDialect.java index 0a6eb75..1ecde2b 100644 --- a/src/main/java/de/extio/lmlib/client/ollama/OllamaDialect.java +++ b/src/main/java/de/extio/lmlib/client/ollama/OllamaDialect.java @@ -23,10 +23,6 @@ public interface OllamaDialect { this.wireValue = wireValue; } - public boolean isEnabled() { - return (this.wireValue instanceof final Boolean val && val) || (this.wireValue instanceof final String str && !str.isBlank()); - } - @JsonValue public Object getWireValue() { return this.wireValue;