Files
DECNET/decnet/orchestrator/emailgen/llm/__init__.py
anti 6d520eaa6f refactor(emailgen): pluggable LLM backend (base/factory/impl)
Lift the Ollama subprocess shell-out out of EmailDriver and into a
proper provider subpackage shape:

  decnet/orchestrator/emailgen/llm/
    base.py        — LLMBackend Protocol + LLMResult + LLMTimeout
    factory.py     — get_llm() reads DECNET_EMAILGEN_LLM
    impl/ollama.py — current 'ollama run' subprocess path
    impl/fake.py   — canned-output backend used by tests

Driver now takes an LLMBackend on construction (or inherits the
factory default).  Tests inject FakeBackend instead of monkeypatching
the subprocess layer, which is cleaner and ~10x faster.  Swapping
Ollama for the Anthropic API / vLLM / llama.cpp is now a third branch
in factory.py; no driver rewrite needed.

Mirrors the convention used by decnet.web.db.factory + decnet.bus.factory
per the provider-subpackages-from-day-one rule in memory.
2026-04-26 22:43:36 -04:00

23 lines
779 B
Python

"""LLM backend for emailgen.
Pluggable from day one (per the provider-subpackages convention used by
:mod:`decnet.web.db` and :mod:`decnet.bus`): the worker only depends on
:class:`LLMBackend` from :mod:`base`; concrete transports live under
:mod:`impl` and are selected by :func:`get_llm`.
This is the seam ANTI will pull on when swapping local Ollama for the
Anthropic API, llama.cpp, vLLM, or any other inference server — change
``DECNET_EMAILGEN_LLM`` (or pass ``llm=`` to the driver), no driver
rewrite.
"""
from __future__ import annotations
from decnet.orchestrator.emailgen.llm.base import (
LLMBackend,
LLMResult,
LLMTimeout,
)
from decnet.orchestrator.emailgen.llm.factory import get_llm
__all__ = ["LLMBackend", "LLMResult", "LLMTimeout", "get_llm"]