Implementation:Ucbepic Docetl Generate Pipeline Config
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Portability |
| Last Updated | 2026-02-08 01:40 GMT |
Overview
Concrete API route and utility function for generating YAML pipeline configurations from the DocETL playground state.
Description
The POST /api/getPipelineConfig Next.js API route calls generatePipelineConfig() to convert UI state (operations, datasets, model settings) into a YAML configuration string. The function handles operation schema conversion, sample size injection, system prompt configuration, optimizer settings, and intermediate directory setup.
Usage
Called automatically when the user clicks Export/Download in the playground. Can also be called programmatically via the API to generate YAML from UI state.
Code Reference
Source Location
- Repository: docetl
- File: website/src/app/api/getPipelineConfig/route.ts (L4-62), website/src/app/api/utils.ts (L107+)
Signature
// API Route
export async function POST(request: Request): Promise<NextResponse>
// Returns: { pipelineConfig: string }
// Config generator
export function generatePipelineConfig(
namespace: string,
default_model: string,
data: { path: string },
operations: Operation[],
operation_id: string,
name: string,
homeDir: string,
sample_size: number | null,
optimize?: boolean,
clear_intermediate?: boolean,
system_prompt?: { datasetDescription: string | null; persona: string | null } | null,
apiKeys?: APIKey[],
docetl_encryption_key?: string,
enable_observability?: boolean,
optimizerModel?: string,
extraPipelineSettings?: Record<string, unknown> | null,
): { yamlString: string }
Import
import { generatePipelineConfig } from "@/app/api/utils";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| default_model | string | Yes | LLM model for operations |
| data | {path: string} | Yes | Dataset file path |
| operations | Operation[] | Yes | UI operation objects |
| name | string | Yes | Pipeline name |
| namespace | string | Yes | File isolation namespace |
| sample_size | number or null | No | Optional dataset sampling |
Outputs
| Name | Type | Description |
|---|---|---|
| pipelineConfig | string | Generated YAML configuration |
Usage Examples
// Frontend API call
const response = await fetch("/api/getPipelineConfig", {
method: "POST",
body: JSON.stringify({
default_model: "gpt-4o",
data: { path: "/path/to/data.json" },
operations: [...operationsFromUI],
name: "my_pipeline",
namespace: "project1",
}),
});
const { pipelineConfig } = await response.json();
// pipelineConfig is a YAML string ready for docetl run