feat(backends): support Ollama adapter functions - #1634
Open
planetf1 wants to merge 8 commits into
Open
Conversation
Signed-off-by: aanokh <alexander.g.anokhin@gmail.com>
Assisted-by: Codex Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
8 tasks
Assisted-by: Codex Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Assisted-by: Codex Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Assisted-by: Codex Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Assisted-by: Codex Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
psschwei
reviewed
Sep 8, 2026
psschwei
left a comment
Member
There was a problem hiding this comment.
Review of the Ollama bundled-adapter path. The uncertainty/aLoRA flow this PR tests looks correct, but the generalization to the other adapter functions has gaps, and three of them fail silently with a schema-valid score rather than raising. Details inline; openai.py already has the correct version of most of these.
…computing#1634) Fixes 8 findings from psschwei's review plus AngeloDanducci's suggestion: - Fold extra_body.documents into a message in _generate_from_intrinsic; Ollama's chat SDK has no extra_body passthrough, so answerability, citations, hallucination_detection, clarify_query, and find_context_attributions were sending zero documents. - resolve_adapter now raises if name has no adapter_models entry, instead of registering successfully and letting generation silently fall back to the base model. - resolve_adapter picks LoRA vs aLoRA from the catalog's adapter_types instead of hardcoding aLoRA; restricted context-attribution, citations, and hallucination_detection to LoRA-only (verified against the Hub). - reroute_to_alora now follows a new default_to_constraint_checking_alora flag (default True), matching OpenAIBackend/LocalHFBackend, instead of only firing for ALoraRequirement. - _generate_from_context now awaits do_generate_walk before the Requirement/Intrinsic dispatch, matching the other backends. - Fix Path(__file__).parents[2] -> parents[3] in the example script. - Constrain granite4.1:3b's context in CI before the adapter build step; only granite4.2:3b was constrained, so the new bundled tag inherited the unconstrained default and reintroduced the CI-stall risk. - Fix export VAR="$(cmd)" masking command-substitution failures under set -e in the test runner script, the build script's own usage comment, and docs/docs/advanced/intrinsics.md. - test_ollama.py's adapter-build fixture now skips on build failure instead of erroring. Added regression tests for the resolve_adapter and document-forwarding fixes; updated two existing unit tests that had encoded the old (buggy) unconditional-resolve behaviour. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
psschwei
approved these changes
Sep 9, 2026
psschwei
left a comment
Member
There was a problem hiding this comment.
There's a conflict, but otherwise LGTM
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
Contributor
Author
|
Will leave ready to merge so @jakelorocco can review on his return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Issue
Supersedes #1622. Related: #1633.
Description
This takes over the Ollama adapter-function work originally proposed in #1622. The original implementation commit remains in this branch history. The takeover rebases the feature onto the current composed-adapter API and adds a reproducible test model built from pinned official Granite artefacts instead of depending on a user-published model.
ServerMediatedBindingregistration.ALoraRequirementrouting for configured catalogue adapter models.For one adapter function, use its bundled aLoRA tag for both
model_idand the adapter route, withadapter_base_model_nameset to the matching Hugging Face base-model directory. Before its invocation tokens appear, the bundle behaves as the base model and retains one Ollama model identity. Applications that map several adapter functions to separate Ollama tags cannot share a KV cache across those tags; multi-adapter, single-model serving remains a Granite Switch use case.The broader server-mediated lifecycle and telemetry design remains tracked in #1633.
Testing
ruff,mypy, Markdown lint, shell syntax, and whitespace checks pass.Attribution
Adding a new component, requirement, sampling strategy, or tool?
NOTE: This PR supersedes an already acknowledged contribution in #1622.