Commit 2fe220b
authored
refactor: split ollama vendor into ollama_local + ollama_cloud (#483)
* refactor(vendor): split VendorType.OLLAMA into OLLAMA_LOCAL + OLLAMA_CLOUD
Replace single OLLAMA enum member with OLLAMA_LOCAL ("ollama_local") and
OLLAMA_CLOUD ("ollama_cloud"). Add OllamaCloudDefaults with base URL
https://ollama.com. Replace OllamaConfig with OllamaLocalConfig (no key
required) and OllamaCloudConfig (requires OLLAMA_API_KEY). Update
VendorConfig union and __all__ exports.
* refactor(validation): resolution service + validators for both ollama slugs
Update _VENDOR_CONFIG_MAP to map ollama_local and ollama_cloud to their
respective config classes. Fix pre-existing bug: add both ollama slugs to
_VALID_BATCH_VENDORS (ollama was previously absent entirely).
* refactor(ollama): shared kernel + OllamaLocalClient + OllamaCloudClient
Replace OllamaClient with shared module-level helpers parameterized by
cloud bool and vendor_slug string, plus two thin client classes:
- OllamaLocalClient: overrides invoke() to skip get_api_key, passes
format=schema to client.chat() for API-enforced structured output
- OllamaCloudClient: uses default BaseClient.invoke() (requires key),
omits format param (schema injected into prompt by MessageBuilder)
Shared kernel has one forward-compatible seam: the 'if not cloud' guard
on the format kwarg. When Ollama Cloud adds structured output support
(ollama/ollama#12362), remove this guard.
Also adds vendor_slug param to maybe_inject_online_failure for accurate
error context.
* refactor(invocation): CLIENT_REGISTRY entries for both ollama slugs
Register ollama_local and ollama_cloud in CLIENT_REGISTRY with lazy
import strings pointing to OllamaLocalClient and OllamaCloudClient.
Both map to the 'ollama' pip package in _VENDOR_PACKAGES.
* refactor(ollama): batch client vendor_slug + cloud params
Parameterize OllamaBatchClient with vendor_slug and cloud flag. Cloud
branch validates API key at construction and attaches Bearer header.
Format param only passed to client.chat() when not cloud (structured
outputs not supported on Ollama Cloud — ollama/ollama#12362).
All hard-coded "ollama" strings replaced with self.vendor_slug for
JSONL labels, MessageBuilder calls, and error context.
* refactor(batch): factory dual registration ollama_local + ollama_cloud
Replace _create_ollama with _create_ollama_local (base_url only) and
_create_ollama_cloud (api_key + base_url via SecretStr pattern).
Register both in _BATCH_CLIENT_REGISTRY.
* fix(batch): resolver base_url pass-through + cache-key policy
Pass base_url from agent_config into client_config so batch factory
honors the same host as online invocation (prevents split-brain FM5).
Extend cache key to hash both api_key and base_url — different hosts
with the same key must not share a cached client.
Update supported_clients list to include ollama_local and ollama_cloud.
* refactor(pipeline): message + response + schema for both ollama slugs
Register ollama_local and ollama_cloud in PROVIDER_MESSAGE_CONFIGS,
PROVIDER_RESPONSE_CONFIGS, and compile_unified_schema.
Key design: ollama_cloud uses SchemaInjection.PROMPT (schema injected
into prompt text) because Ollama Cloud does not support structured
outputs via format param (ollama/ollama#12362). ollama_local keeps
SchemaInjection.NONE (API-enforced). Both share UsageShape.OLLAMA.
Update _serialise_context to handle both slugs.
* refactor(meta): metadata aliases + scanners + context_data
Update PROVIDER_ALIASES for both ollama slugs. Update component_scanners
config_map (OLLAMA_LOCAL → OllamaLocalConfig, OLLAMA_CLOUD →
OllamaCloudConfig). Update context_data vendor list string.
* fix(prompt): add SchemaInjection.PROMPT enum member
Add missing PROMPT variant to SchemaInjection enum for providers
without native structured output support (e.g., Ollama Cloud).
Required by ollama_cloud's ProviderMessageConfig added in prior commit.
* test: migrate ollama fixtures + mock targets
Update 10 test files: replace OllamaClient with OllamaLocalClient,
retarget mock patches from _get_client to _build_ollama_client,
replace vendor string "ollama" with "ollama_local" in all fixtures,
assertions, and parametrize lists.
UsageShape.OLLAMA intentionally kept — it names the extraction shape,
not a vendor string.
6337 passed, 2 skipped, 0 failures.
* test: behavioral tests for local/cloud split
22 tests across 3 classes verifying the behavioral contract between
OllamaLocalClient and OllamaCloudClient:
- Local: invoke skips get_api_key, no auth header, passes format param
- Cloud: invoke requires key, Bearer header, omits format param
- Batch: cloud validates key at construction, vendor_slug in labels
Every assertion can fail on wrong input. No tautologies.
* docs: examples + changie breaking change entry
Update all example YAMLs, READMEs, and docs referencing model_vendor:
ollama to use ollama_local. Update config_schema description, schema
docstring, frontend DAG transformer vendor detection.
Add Breaking Change changie entry: model_vendor: ollama removed,
use ollama_local or ollama_cloud.
* fix: address review findings — manifest, test gaps, minor fixes
- Update llm/providers/_MANIFEST.md to describe both ollama_local and
ollama_cloud with env vars and structured output limitation
- Add ollama_cloud to schema dispatch audit and prompt caching test loops
- Add 3 batch base_url tests (local config, cloud default, cloud env)
- Fix failure_injection default vendor_slug from "ollama" to "ollama_local"
- Fix batch error type from hard-coded "ollama_error" to vendor_slug-based
6362 passed, 2 skipped, 0 failures.
* simplify: deduplicate schema extraction, use module-level error mappings
- Remove duplicated _extract_ollama_schema from batch_client.py, import
the canonical version from client.py (fixes silent fallback bug where
batch silently accepted malformed schemas instead of raising)
- Replace _error_mapping() function with two module-level constants
(_ERROR_MAPPING_LOCAL, _ERROR_MAPPING_CLOUD) matching codebase convention
- Replace hardcoded supported-clients list in resolver with
BatchClientFactory.get_supported_clients() to prevent stale lists
* fix(prompt): implement SchemaInjection.PROMPT for cloud structured output
SchemaInjection.PROMPT was declared on ollama_cloud's config but
_assemble_body returned "" for PromptStyle.RAW before any injection
branch could fire, and had no PROMPT branch at all. Cloud JSON calls
received no schema signal — models returned unstructured text, causing
VendorAPIError on parse.
Fix: inject schema into prompt_config before _wrap_in_roles, so it
lands in the system message. Cloud models now see the schema as a
JSON instruction in the prompt text.
Add two tests:
- test_cloud_schema_injected_into_prompt (positive: schema in system msg)
- test_local_schema_not_in_prompt (negative: local uses format param)
* fix: skip schema extraction for cloud, move json import to module scope
- Short-circuit _extract_ollama_schema for cloud (avoids wasted work and
false ConfigurationError on malformed schemas cloud never sends)
- Move json import to module scope in message_builder.py, remove two
redundant function-scope imports1 parent 04ecb0f commit 2fe220b
44 files changed
Lines changed: 1109 additions & 454 deletions
File tree
- .changes/unreleased
- agent_actions
- config
- llm
- batch/infrastructure
- config
- providers
- ollama
- realtime/services
- output/response
- prompt
- tooling/docs
- frontend/lib
- scanner
- utils/metadata
- validation
- preflight
- utils
- docs.agent-actions/docs
- guides
- reference
- configuration
- data-io
- tutorials
- examples
- book_catalog_enrichment
- agent_workflow/book_catalog_enrichment/agent_config
- review_analyzer
- agent_workflow/review_analyzer
- support_resolution
- agent_workflow/support_resolution
- tests
- core/parser
- integration
- unit
- llm_invocation/providers
- llm/providers
- ollama
- output/response
- prompt
- tooling
- validation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
184 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
117 | 132 | | |
118 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
119 | 136 | | |
120 | 137 | | |
121 | 138 | | |
| |||
159 | 176 | | |
160 | 177 | | |
161 | 178 | | |
162 | | - | |
| 179 | + | |
| 180 | + | |
163 | 181 | | |
164 | 182 | | |
165 | 183 | | |
| |||
214 | 232 | | |
215 | 233 | | |
216 | 234 | | |
217 | | - | |
| 235 | + | |
| 236 | + | |
218 | 237 | | |
219 | 238 | | |
220 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
94 | 109 | | |
95 | 110 | | |
96 | 111 | | |
| |||
139 | 154 | | |
140 | 155 | | |
141 | 156 | | |
142 | | - | |
| 157 | + | |
| 158 | + | |
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
0 commit comments