Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ucbepic Docetl Directive Registry

From Leeroopedia


Knowledge Sources
Domains Pipeline_Optimization, LLM_Operations
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete registry module for all available reasoning optimizer directives provided by the DocETL reasoning optimizer.

Description

The __init__.py module serves as the central registry for all directive classes in the reasoning optimizer. It imports all directive implementations, maintains several registries (ALL_DIRECTIVES, ALL_COST_DIRECTIVES, DIRECTIVE_GROUPS, MULTI_INSTANCE_DIRECTIVES), and provides a DIRECTIVE_REGISTRY name-to-instance mapping. It also exposes utility functions like get_all_directive_strings(), get_all_cost_directive_strings(), and instantiate_directive() for centralized directive lookup and instantiation.

Usage

This module is used by the MOAR agent and optimization pipeline to discover available directives, generate prompt descriptions of all directives, and instantiate directives by name. It is the single entry point for the directive subsystem.

Code Reference

Source Location

Signature

ALL_DIRECTIVES = [
    ChainingDirective(), GleaningDirective(), ReduceGleaningDirective(),
    ReduceChainingDirective(), ChangeModelCostDirective(), DocSummarizationDirective(),
    IsolatingSubtasksDirective(), DeterministicDocCompressionDirective(),
    OperatorFusionDirective(), DocumentChunkingDirective(), DocumentChunkingTopKDirective(),
    ChunkHeaderSummaryDirective(), TakeHeadTailDirective(), ClarifyInstructionsDirective(),
    SwapWithCodeDirective(), MapReduceFusionDirective(), HierarchicalReduceDirective(),
    CascadeFilteringDirective(), ArbitraryRewriteDirective(),
    MapToMapResolveReduceDirective(), MapResolveToMapWithCategoriesDirective(),
]

DIRECTIVE_REGISTRY = {directive.name: directive for directive in ALL_DIRECTIVES}

def get_all_directive_strings() -> str: ...
def get_all_cost_directive_strings() -> str: ...
def instantiate_directive(directive_name: str, operators: List[Dict], target_ops: List[str],
                          agent_llm: str, message_history: list, **kwargs): ...

Import

from docetl.reasoning_optimizer.directives import ALL_DIRECTIVES, DIRECTIVE_REGISTRY, instantiate_directive

I/O Contract

Inputs

Name Type Required Description
directive_name str Yes Name of the directive to instantiate
operators List[Dict] Yes List of pipeline operators
target_ops List[str] Yes List of target operation names
agent_llm str Yes LLM model to use for instantiation
message_history list Yes Conversation history

Outputs

Name Type Description
new_ops_list list Transformed operation configurations
updated_message_history list Updated conversation history after instantiation

Usage Examples

# Using the registry to instantiate a directive by name
from docetl.reasoning_optimizer.directives import instantiate_directive

new_ops, history = instantiate_directive(
    directive_name="chaining",
    operators=pipeline_operators,
    target_ops=["extract_contract_terms"],
    agent_llm="gpt-4.1",
    message_history=[]
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment