Documentation Index
Fetch the complete documentation index at: https://docs.doclo.ai/llms.txt
Use this file to discover all available pages before exploring further.
The output node explicitly controls what data is returned from a flow, allowing you to select from artifacts, transform results, and name outputs.
Basic Usage
You can add an output node using the flow builder’s .output() method:
import { createFlow, extract } from '@doclo/flows';
const flow = createFlow()
.step('extract', extract({
provider: vlmProvider,
schema: invoiceSchema
}))
.output({ name: 'invoice_data' })
.build();
Or import the output function from @doclo/nodes and use it as a step:
import { createFlow, extract } from '@doclo/flows';
import { output } from '@doclo/nodes';
const flow = createFlow()
.step('extract', extract({
provider: vlmProvider,
schema: invoiceSchema
}))
.step('output', output({ name: 'invoice_data' }))
.build();
Configuration Options
output({
name: 'result', // Optional output name
source: 'extract', // Select from specific step
transform: 'pick', // Transform strategy
fields: ['id', 'amount'] // Fields to pick
})
Options Reference
| Option | Type | Description |
|---|
name | string | Name for this output |
source | string | string[] | Step ID(s) to pull from |
transform | string | Transform strategy |
fields | string[] | Fields to pick (for ‘pick’ transform) |
customTransform | function | Custom transform function |
Selecting Sources
Previous Step (Default)
Without configuration, returns output of previous step:
const flow = createFlow()
.step('parse', parse({ provider: ocrProvider }))
.step('extract', extract({ provider: llmProvider, schema }))
.step('output', output()) // Returns extract output
.build();
Specific Step
Select output from a specific step:
const flow = createFlow()
.step('parse', parse({ provider: ocrProvider }))
.step('extract', extract({ provider: llmProvider, schema }))
.step('output', output({ source: 'parse' })) // Returns parse output
.build();
Multiple Steps
Combine outputs from multiple steps:
const flow = createFlow()
.step('step1', extract({ provider: vlmProvider, schema: schema1 }))
.step('step2', extract({ provider: vlmProvider, schema: schema2 }))
.step('output', output({
source: ['step1', 'step2'],
transform: 'merge'
}))
.build();
Pick
Select specific fields from the output:
output({
transform: 'pick',
fields: ['invoiceNumber', 'totalAmount', 'date']
})
Input:
{
"invoiceNumber": "INV-001",
"totalAmount": 1250,
"date": "2024-01-15",
"lineItems": [...],
"vendor": {...}
}
Output:
{
"invoiceNumber": "INV-001",
"totalAmount": 1250,
"date": "2024-01-15"
}
Merge
Merge multiple sources into one object:
output({
source: ['header', 'items', 'totals'],
transform: 'merge'
})
First / Last
Return first or last non-null result:
output({
source: ['primary', 'fallback'],
transform: 'first'
})
Apply a custom transformation function:
output({
transform: 'custom',
customTransform: (input, artifacts) => {
return {
...input,
processedAt: new Date().toISOString(),
metadata: {
parseTime: artifacts['parse'].metrics?.ms,
extractTime: artifacts['extract'].metrics?.ms
}
};
}
})
Named Outputs
Name outputs for identification:
output({ name: 'invoice_extraction_result' })
Use Cases
Clean Output
Remove internal fields:
const flow = createFlow()
.step('extract', extract({ provider: vlmProvider, schema: fullSchema }))
.step('output', output({
transform: 'pick',
fields: ['id', 'amount', 'date', 'vendor']
}))
.build();
Add processing metadata:
const flow = createFlow()
.step('parse', parse({ provider: ocrProvider }))
.step('extract', extract({ provider: llmProvider, schema }))
.step('output', output({
transform: 'custom',
customTransform: (data, artifacts) => ({
result: data,
metadata: {
pageCount: artifacts['parse']?.pages?.length,
processingTime: Date.now()
}
})
}))
.build();
Create different views:
// Full output
const fullFlow = createFlow()
.step('extract', extract({ provider: vlmProvider, schema }))
.step('output', output({ name: 'full' }))
.build();
// Summary output
const summaryFlow = createFlow()
.step('extract', extract({ provider: vlmProvider, schema }))
.step('output', output({
name: 'summary',
transform: 'pick',
fields: ['id', 'total', 'status']
}))
.build();
Without Provider
The output node doesn’t require an AI provider—it performs local data selection and transformation:
output() // No provider needed
Next Steps
Flows
Learn about flow construction
extract
Extract data before output