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 ComponentUtils

From Leeroopedia


Knowledge Sources
Domains Frontend, React_UI
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for the schema conversion utility that transforms dictionary-format schemas to the internal SchemaItem format.

Description

This module exports the schemaDictToItemSet function which converts schema definitions from the dictionary format used in YAML configurations (e.g., {"themes": "list[{theme: str, viewpoints: str}]"}) to the internal SchemaItem[] format used by the frontend components. It handles nested types including lists with object subtypes, enum types with value parsing, dict types with recursive sub-schemas, and simple scalar types. The function recursively processes complex nested structures like lists of objects.

Usage

Called by useRestorePipeline and other components that need to convert YAML-sourced schema definitions into the frontend's internal schema representation.

Code Reference

Source Location

Signature

export const schemaDictToItemSet = (
  schema: Record<string, string>
): SchemaItem[]

Import

import { schemaDictToItemSet } from "@/components/utils";

I/O Contract

Inputs (Props)

Name Type Required Description
schema Record<string, string> Yes Dictionary mapping field names to type strings

Outputs

Name Type Description
items SchemaItem[] Array of structured schema items

Usage Examples

import { schemaDictToItemSet } from "@/components/utils";

const schemaItems = schemaDictToItemSet({
  themes: "list[{theme: str, viewpoints: str}]",
  summary: "string",
  score: "float",
  category: "enum[positive, negative, neutral]",
});
// Returns: [
//   { key: "themes", type: "list", subType: { key: "0", type: "dict", subType: [...] } },
//   { key: "summary", type: "string" },
//   { key: "score", type: "float" },
//   { key: "category", type: "enum", enumValues: ["positive", "negative", "neutral"] },
// ]

Related Pages

Page Connections

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