Files
markitect-main/markitect/llm/__init__.py
tegwick fecc2fd4fa feat(llm): add LLM integration module with OpenRouter and Claude Code adapters
Implements markitect/llm/ package with concrete LLMAdapter implementations:
- OpenRouterAdapter: HTTP via urllib with retry/backoff on 429/5xx
- ClaudeCodeAdapter: subprocess-based Claude CLI with stdin piping
- Factory pattern: create_adapter("openrouter") or create_adapter("claude-code")
- API key resolution chain: constructor > env var > project-root key file
- 42 unit tests, 2 integration tests (gated on API key / CLI availability)

Also adds the infospace-with-history example with Wealth of Nations VSM
analysis pipeline, templates, schemas, source chapters, and processed
output for chapters 1-2. process_chapters.py now supports --provider
and --model flags for automatic LLM-driven processing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 01:17:58 +01:00

41 lines
1.0 KiB
Python

"""
markitect.llm — LLM integration adapters for MarkiTect.
Provides concrete :class:`LLMAdapter` implementations backed by
OpenRouter (HTTP) and Claude Code CLI (subprocess).
Quick start::
from markitect.llm import create_adapter
adapter = create_adapter("openrouter", model="anthropic/claude-sonnet-4")
response = adapter.execute_prompt(prompt, run_config)
"""
from markitect.llm.factory import create_adapter
from markitect.llm.openrouter import OpenRouterAdapter
from markitect.llm.claude_code import ClaudeCodeAdapter
from markitect.llm.config import LLMConfig, load_config
from markitect.llm.exceptions import (
LLMError,
LLMConfigurationError,
LLMAPIError,
LLMRateLimitError,
LLMTimeoutError,
LLMSubprocessError,
)
__all__ = [
"create_adapter",
"OpenRouterAdapter",
"ClaudeCodeAdapter",
"LLMConfig",
"load_config",
"LLMError",
"LLMConfigurationError",
"LLMAPIError",
"LLMRateLimitError",
"LLMTimeoutError",
"LLMSubprocessError",
]