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>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: extraction-rules
|
||||
name: extraction_rules
|
||||
artifact_type: content
|
||||
description: Guidelines for extracting economic entities from source text
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# Entity Extraction Rules
|
||||
|
||||
## What Constitutes an Entity
|
||||
|
||||
An economic entity is a distinct concept, actor, mechanism, or institution
|
||||
that plays a functional role in Adam Smith's economic analysis. Extract
|
||||
entities at the level of specificity where they carry independent meaning.
|
||||
|
||||
## Extraction Criteria
|
||||
|
||||
1. **Concepts**: Abstract economic ideas (e.g., "division of labour",
|
||||
"effectual demand", "natural price"). Extract when Smith defines,
|
||||
explains, or argues about the concept.
|
||||
|
||||
2. **Actors**: Economic agents with defined roles (e.g., "the labourer",
|
||||
"the merchant", "the sovereign"). Extract when the actor performs
|
||||
a distinct economic function.
|
||||
|
||||
3. **Mechanisms**: Processes or dynamics that produce economic effects
|
||||
(e.g., "accumulation of stock", "market price adjustment",
|
||||
"foreign trade"). Extract when the mechanism is described as
|
||||
producing specific outcomes.
|
||||
|
||||
4. **Institutions**: Organised structures that shape economic behaviour
|
||||
(e.g., "the corporation", "the guild", "the joint-stock company").
|
||||
Extract when the institution's economic function is described.
|
||||
|
||||
## Granularity Rules
|
||||
|
||||
- Extract at the level of a single coherent concept.
|
||||
- Do NOT extract synonyms as separate entities — choose the primary term
|
||||
Smith uses and note variations.
|
||||
- DO extract distinct aspects of a broad concept as separate entities when
|
||||
Smith treats them independently (e.g., "wages of labour" and "profits
|
||||
of stock" are separate from "price of commodities" even though they
|
||||
compose it).
|
||||
- If an entity appears across multiple chapters, extract it on first
|
||||
significant appearance and note cross-references in later chapters.
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
- Use Smith's own terminology where possible.
|
||||
- Normalise to lowercase except for proper nouns.
|
||||
- Use the most common form Smith uses (e.g., "division of labour" not
|
||||
"divided labour").
|
||||
|
||||
## Quality Checks
|
||||
|
||||
- Each entity must have a definition that would be comprehensible without
|
||||
reading the source chapter.
|
||||
- Each entity must cite the specific book and chapter of first appearance.
|
||||
- Economic Domain must be one of: Production, Distribution, Exchange,
|
||||
Consumption, Accumulation, Regulation, or General Theory.
|
||||
Reference in New Issue
Block a user