Implementation:Ucbepic Docetl OpDescriptions
| Knowledge Sources | |
|---|---|
| Domains | Data_Processing, Optimization, Documentation |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for structured descriptions of all DocETL operators used in LLM prompts during optimization provided by DocETL.
Description
The op_descriptions module defines the Operator Pydantic model and instantiates structured descriptions for every DocETL operator type. Each Operator instance includes the operator name, whether it is LLM-powered, a description, usage guidance, required/optional parameters, return specification, and a minimal YAML example. The module provides pre-built instances including op_map, op_extract, op_parallel_map, op_filter, op_reduce, and others. These descriptions are serialized via the to_string() method and injected into LLM prompts during MCTS expansion and directive instantiation.
Usage
Use this module when constructing LLM prompts that need to describe available DocETL operators, such as during the MOAR optimizer's expansion phase or when generating pipeline configurations from natural language.
Code Reference
Source Location
- Repository: Ucbepic_Docetl
- File: docetl/reasoning_optimizer/op_descriptions.py
- Lines: 1-638
Signature
class Operator(BaseModel):
name: str
type_llm_or_not: str
description: str
when_to_use: str
required_parameters: str
optional_parameters: Optional[str] = None
returns: str
minimal_example_configuration: str
def to_string(self) -> str: ...
# Pre-built operator instances:
op_map: Operator
op_extract: Operator
op_parallel_map: Operator
op_filter: Operator
op_reduce: Operator
# ... additional operator instances
Import
from docetl.reasoning_optimizer.op_descriptions import Operator, op_map, op_reduce, op_filter
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | The name of the operator (e.g., "Map", "Reduce", "Filter") |
| type_llm_or_not | str | Yes | Whether the operator is "LLM-powered" or "Not LLM-powered" |
| description | str | Yes | Multi-sentence description of what the operator does |
| when_to_use | str | Yes | Guidance on when to select this operator |
| required_parameters | str | Yes | Formatted string of required YAML parameters |
| optional_parameters | Optional[str] | No | Formatted string of optional YAML parameters |
| returns | str | Yes | Description of what the operator returns |
| minimal_example_configuration | str | Yes | YAML snippet showing minimal operator usage |
Outputs
| Name | Type | Description |
|---|---|---|
| formatted_string | str | Markdown-formatted operator description ready for LLM prompt injection |
Usage Examples
from docetl.reasoning_optimizer.op_descriptions import op_map, op_reduce
# Get formatted description for use in an LLM prompt
map_description = op_map.to_string()
reduce_description = op_reduce.to_string()
# Inject into a system prompt
system_prompt = f"""
Available operators:
{map_description}
{reduce_description}
"""