feat(07-02): registry-based get_provider(config: ProviderConfig) — D-06

- Rewrites ai/__init__.py with _REGISTRY dict (10 entries) replacing the if/elif chain
- get_provider() accepts ProviderConfig (not raw dict), raises ValueError on unknown
- Resolves effective values: api_key fallback to "not-needed", model/base_url/context_chars
  from PROVIDER_DEFAULTS when config fields are empty/zero
- SUPPORTS_JSON_MODE lookup sets supports_json_mode on GenericOpenAIProvider instances
- AnthropicProvider instantiated without base_url (Plan 03 will widen the ctor)
- provider_config.py: context_chars default changed to 0 (sentinel for PROVIDER_DEFAULTS
  resolution); 8000 default was inconsistent with O(1) factory pattern (Rule 1 fix)
This commit is contained in:
curo1305
2026-06-04 19:01:26 +02:00
parent 02bcbb9143
commit 13eef371bc
2 changed files with 82 additions and 28 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ class ProviderConfig(BaseModel):
api_key: str = ""
base_url: Optional[str] = None
model: str = ""
context_chars: int = 8000
context_chars: int = 0 # 0 means "unset — use PROVIDER_DEFAULTS in get_provider()"
# Named preset defaults for all 10 supported providers.