MCPcopy Create free account

hub / github.com/Emmimal/control-layer / types & classes

Types & classes31 in github.com/Emmimal/control-layer

↓ 20 callersClassControlLayerConfig
All tunable parameters in one validated place. Pass a config dict or load from YAML/env — never hardcode in prod.
control_layer.py:99
↓ 20 callersClassResponseSchema
Output contract the LLM response must satisfy.
control_layer.py:127
↓ 17 callersClassValidationResult
control_layer.py:156
↓ 10 callersClassControlLayer
The orchestrator. Sits between your application logic and the LLM. Composes all eight components: InputGuard → TokenBudget → PromptBui
control_layer.py:829
↓ 9 callersClassTokenBudget
Slot-based token allocator using tiktoken for accurate counts. Production fix over v1: char/4 heuristic replaced with the actual tokeniz
control_layer.py:297
↓ 6 callersClassAuditLogger
Records every attempt with its failure mode, latency, and outcome. Production fix over v1: - Thread-safe writes via lock - Persi
control_layer.py:698
↓ 6 callersClassAuditRecord
control_layer.py:164
↓ 6 callersClassCircuitBreaker
Stops hammering a failing LLM backend. States: CLOSED (normal) → OPEN (failing) → HALF_OPEN (testing) → CLOSED Production fix over v1:
control_layer.py:525
↓ 5 callersClassFallbackRouter
When the primary strategy exhausts all retries, routes to a registered fallback handler. Fallbacks are called in registration order. Fir
control_layer.py:659
↓ 4 callersClassMockLLM
Simulates an LLM with configurable failure behavior. Swap this for your real LLM in production: layer = ControlLayer(llm_fn=your_open
demo.py:69
↓ 3 callersClassLLMCaller
Wraps any callable LLM function with timeout enforcement. Production fix over v1: without a timeout, a hung LLM call blocks the thread f
control_layer.py:788
↓ 3 callersClassPromptBuilder
Assembles the final prompt within a hard token budget. Reservation order (priority, highest first): 1. System prompt — fixed overhead
control_layer.py:354
↓ 2 callersClassInputGuard
Validates and sanitizes user input before it reaches the prompt builder. Three checks, in order: 1. Empty / whitespace-only input.
control_layer.py:235
↓ 2 callersClassResponseValidator
Validates model output against a schema and rule set. Prompts ask. Validators enforce. That's the whole difference.
control_layer.py:425
↓ 2 callersClassRetryEngine
Retries failed LLM calls with prompt mutation targeted at the specific failure mode detected. Production fix over v1: - Uses tenac
control_layer.py:615
↓ 1 callersClassControlPacket
control_layer.py:190
↓ 1 callersClassLLMTimeoutError
Raised when the LLM call exceeds the configured timeout.
control_layer.py:784
ClassCircuitState
control_layer.py:519
ClassFailureMode
control_layer.py:77
ClassRetryStrategy
control_layer.py:88
ClassTestAuditLogger
tests/test_control_layer.py:393
ClassTestCircuitBreaker
tests/test_control_layer.py:252
ClassTestControlLayerIntegration
tests/test_control_layer.py:472
ClassTestFallbackRouter
tests/test_control_layer.py:338
ClassTestInputGuard
tests/test_control_layer.py:62
ClassTestLLMCaller
tests/test_control_layer.py:372
ClassTestPromptBuilder
tests/test_control_layer.py:150
ClassTestPydanticConfig
tests/test_control_layer.py:586
ClassTestResponseValidator
tests/test_control_layer.py:188
ClassTestRetryEngine
tests/test_control_layer.py:302
ClassTestTokenBudget
tests/test_control_layer.py:114