agnes-the-ai-analyst/connectors/llm/__init__.py
ZdenekSrotyr bbb04ac041 fix(setup): seed default ai: block + env-var fallback (#176)
POST /api/admin/configure now writes a default ai: block into the
instance.yaml overlay when the request leaves it untouched and either
ANTHROPIC_API_KEY or LLM_API_KEY is set in the environment. The block
references the env var via ${VAR} syntax — secrets never land in YAML.

connectors.llm.factory grows create_extractor_from_env_or_config which
falls back to ANTHROPIC_API_KEY / LLM_API_KEY when ai_config is empty
and raises a clear ValueError when neither is available. Both
services/corporate_memory and services/verification_detector switch to
the new helper, replacing the old 'silently skip when ai: missing'
path that was the silent-failure root cause.

Tests:
- tests/test_setup_ai_block.py — overlay seeding contract.
- tests/test_llm_provider_env_fallback.py — fallback + fail-fast.
2026-05-04 23:55:19 +02:00

15 lines
489 B
Python

"""LLM connector module for structured extraction.
Provides a provider-agnostic interface for extracting structured JSON
from language models. Supports Anthropic (native) and OpenAI-compatible
providers with automatic fallback strategies for structured output.
"""
from .base import StructuredExtractor
from .factory import create_extractor, create_extractor_from_env_or_config
__all__ = [
"StructuredExtractor",
"create_extractor",
"create_extractor_from_env_or_config",
]