Core Components and Structured I/O
Use this sub-skill when a task needs AdalFlow's service-free building blocks:
Component, DataComponent, Sequential, nested component/parameter registration, state dictionaries, and lifecycle methods.
DataClass, required_field, JSON/YAML/schema/signature helpers, and nested dataclass serialization.
DataClassParser, string parsers, output parser selection, and Jinja Prompt rendering.
- Small deterministic task-pipeline prototypes that do not call a live provider.
Do not use this sub-skill for live model calls, provider clients, or Generator internals; route those to model-client-and-generator-workflows. Route tool/agent/streaming work to agents-tools-and-streaming, and trainer/optimizer work to evaluation-and-optimization.
Load order
- Read core API reference for verified signatures, lifecycle rules, object relationships, and routing boundaries.
- Read structured I/O and parsers for copyable DataClass, parser, prompt, and mini-pipeline recipes.
- If behavior is surprising, read troubleshooting before changing code.
- For a deterministic environment check, run structured IO smoke or core component smoke. These scripts do not use provider credentials, network, datasets, or model calls.
Operating rules
- Always call
super().__init__() before assigning child Component or Parameter attributes in a custom Component.
- Implement
call for synchronous inference. Implement acall only when the component genuinely has async work. Implement forward or bicall only for training-mode behavior.
- In
train() mode, Component.__call__ expects a Parameter output; in eval() mode, it rejects Parameter outputs. DataComponent is intentionally non-trainable and dispatches directly to call.
- Decorate every
DataClass subclass with @dataclass; use field(metadata={"desc": ...}) or metadata={"description": ...} to make prompt schemas useful.
- Prefer
default_factory for mutable fields, and use required_field() when a required field must appear after optional fields.
- For structured model outputs, generate prompt instructions with
DataClassParser.get_output_format_str() and parse service-free strings with the same parser before connecting a Generator elsewhere.
1---2name: core-components-and-structured-io3description: "Build service-free AdalFlow Component, DataClass, Prompt, parser,4 and structured-output pipelines."5disable-model-invocation: true6metadata:7 source: https://skillmd.com/skills/vectorspacelab/core-components-and-structured-io8 disco-role: operating9license: MIT10---1112# Core Components and Structured I/O1314Use this sub-skill when a task needs AdalFlow's service-free building blocks:1516- `Component`, `DataComponent`, `Sequential`, nested component/parameter registration, state dictionaries, and lifecycle methods.17- `DataClass`, `required_field`, JSON/YAML/schema/signature helpers, and nested dataclass serialization.18- `DataClassParser`, string parsers, output parser selection, and Jinja `Prompt` rendering.19- Small deterministic task-pipeline prototypes that do not call a live provider.2021Do **not** use this sub-skill for live model calls, provider clients, or `Generator` internals; route those to `model-client-and-generator-workflows`. Route tool/agent/streaming work to `agents-tools-and-streaming`, and trainer/optimizer work to `evaluation-and-optimization`.2223## Load order24251. Read [core API reference](references/core-api-reference.md) for verified signatures, lifecycle rules, object relationships, and routing boundaries.262. Read [structured I/O and parsers](references/structured-io-and-parsers.md) for copyable DataClass, parser, prompt, and mini-pipeline recipes.273. If behavior is surprising, read [troubleshooting](references/troubleshooting.md) before changing code.284. For a deterministic environment check, run [structured IO smoke](scripts/structured_io_smoke.py) or [core component smoke](scripts/core_component_smoke.py). These scripts do not use provider credentials, network, datasets, or model calls.2930## Operating rules3132- Always call `super().__init__()` before assigning child `Component` or `Parameter` attributes in a custom `Component`.33- Implement `call` for synchronous inference. Implement `acall` only when the component genuinely has async work. Implement `forward` or `bicall` only for training-mode behavior.34- In `train()` mode, `Component.__call__` expects a `Parameter` output; in `eval()` mode, it rejects `Parameter` outputs. `DataComponent` is intentionally non-trainable and dispatches directly to `call`.35- Decorate every `DataClass` subclass with `@dataclass`; use `field(metadata={"desc": ...})` or `metadata={"description": ...}` to make prompt schemas useful.36- Prefer `default_factory` for mutable fields, and use `required_field()` when a required field must appear after optional fields.37- For structured model outputs, generate prompt instructions with `DataClassParser.get_output_format_str()` and parse service-free strings with the same parser before connecting a `Generator` elsewhere.