MCPcopy Create free account
hub / github.com/Emmimal/control-layer / __init__

Method __init__

control_layer.py:845–871  ·  view source on GitHub ↗
(
        self,
        llm_fn: Callable[[str], str],
        system_prompt: str,
        schema: Optional[ResponseSchema] = None,
        config: Optional[ControlLayerConfig] = None,
        # Legacy compat: accept total_tokens and max_attempts directly
        total_tokens: Optional[int] = None,
        max_attempts: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

843 """
844
845 def __init__(
846 self,
847 llm_fn: Callable[[str], str],
848 system_prompt: str,
849 schema: Optional[ResponseSchema] = None,
850 config: Optional[ControlLayerConfig] = None,
851 # Legacy compat: accept total_tokens and max_attempts directly
852 total_tokens: Optional[int] = None,
853 max_attempts: Optional[int] = None,
854 ):
855 self.config = config or ControlLayerConfig(
856 total_tokens=total_tokens or 800,
857 max_attempts=max_attempts or 3,
858 )
859 self.schema = schema or ResponseSchema()
860
861 self.input_guard = InputGuard(self.config.max_input_chars)
862 self.prompt_builder = PromptBuilder(system_prompt, self.config)
863 self.validator = ResponseValidator()
864 self.retry_engine = RetryEngine(self.config)
865 self.fallback_router = FallbackRouter()
866 self.circuit_breaker = CircuitBreaker(
867 self.config.cb_failure_threshold,
868 self.config.cb_recovery_seconds,
869 )
870 self.llm_caller = LLMCaller(llm_fn, self.config.timeout_seconds)
871 self.audit = AuditLogger(self.config.audit_log_path)
872
873 def register_fallback(self, name: str, fn: Callable[[str], str]) -> None:
874 self.fallback_router.register(name, fn)

Callers

nothing calls this directly

Calls 10

ControlLayerConfigClass · 0.85
ResponseSchemaClass · 0.85
InputGuardClass · 0.85
PromptBuilderClass · 0.85
ResponseValidatorClass · 0.85
RetryEngineClass · 0.85
FallbackRouterClass · 0.85
CircuitBreakerClass · 0.85
LLMCallerClass · 0.85
AuditLoggerClass · 0.85

Tested by

no test coverage detected