mirror of
https://github.com/Nikhil-Doye/workflow-builder.git
synced 2026-07-22 02:01:56 +02:00
ba52bd6eeb
- Updated workflowStore to implement variable substitution for node outputs, allowing dynamic input handling across different node types. - Modified processing functions for LLM, data output, web scraping, embedding, similarity search, and structured output nodes to utilize the new variable substitution mechanism. - Adjusted demo-workflows.json to reflect changes in node configurations, including format updates for web scraping and model changes for LLM tasks.
3.9 KiB
3.9 KiB
Variable Substitution Example
This document demonstrates how the {{input-1.output}} variable substitution works in the workflow system.
How It Works
1. Data Flow Process
Testing Panel Input → Data Input Node → Web Scraping Node → LLM Node → Data Output Node
2. Variable Substitution Examples
Example 1: Web Scraping Node
{
"config": {
"url": "{{input-1.output}}",
"formats": ["markdown", "html"]
}
}
What happens:
- User enters
"https://github.com"in testing panel - Data Input Node stores:
{ output: "https://github.com" } - Web Scraping Node processes:
"{{input-1.output}}"→"https://github.com" - Firecrawl scrapes the actual GitHub URL
Example 2: LLM Task Node
{
"config": {
"prompt": "Analyze this content: {{scraper-1.output}}",
"model": "deepseek-chat"
}
}
What happens:
- Web Scraping Node outputs:
{ output: "[scraped content]" } - LLM Node processes:
"{{scraper-1.output}}"→"[scraped content]" - AI analyzes the actual scraped content
3. Supported Variable Patterns
| Pattern | Description | Example |
|---|---|---|
{{nodeId}} |
Entire output of the node | {{input-1}} |
{{nodeId.output}} |
Output property | {{input-1.output}} |
{{nodeId.data}} |
Data property | {{scraper-1.data}} |
{{nodeId.status}} |
Status property | {{llm-1.status}} |
{{nodeId.error}} |
Error property | {{scraper-1.error}} |
4. Complete Workflow Example
{
"nodes": [
{
"id": "input-1",
"type": "dataInput",
"config": {
"dataType": "url",
"defaultValue": "https://example.com"
}
},
{
"id": "scraper-1",
"type": "webScraping",
"config": {
"url": "{{input-1.output}}",
"formats": ["markdown", "html"]
}
},
{
"id": "llm-1",
"type": "llmTask",
"config": {
"prompt": "Summarize: {{scraper-1.output}}",
"model": "deepseek-chat"
}
},
{
"id": "output-1",
"type": "dataOutput",
"config": {
"format": "json",
"filename": "analysis.json"
}
}
]
}
5. Execution Flow
-
Testing Panel: User enters
"https://github.com" -
Data Input Node (
input-1):- Receives:
"https://github.com" - Stores:
{ output: "https://github.com" } - Status:
"success"
- Receives:
-
Web Scraping Node (
scraper-1):- Config URL:
"{{input-1.output}}" - Variable substitution:
"{{input-1.output}}"→"https://github.com" - Calls Firecrawl with:
"https://github.com" - Returns:
{ output: "[GitHub page content]", markdown: "...", html: "..." }
- Config URL:
-
LLM Task Node (
llm-1):- Config prompt:
"Summarize: {{scraper-1.output}}" - Variable substitution:
"{{scraper-1.output}}"→"[GitHub page content]" - Calls AI with:
"Summarize: [GitHub page content]" - Returns:
{ output: "[AI summary of GitHub page]" }
- Config prompt:
-
Data Output Node (
output-1):- Receives:
"[AI summary of GitHub page]" - Formats as JSON and saves to
analysis.json
- Receives:
6. Error Handling
If a variable reference doesn't exist:
{{nonexistent-node.output}}→{{nonexistent-node.output}}(unchanged)- Warning logged to console
- Node continues with original string
7. Testing the Feature
- Create a new workflow
- Add a Data Input node with URL as default value
- Add a Web Scraping node with URL set to
{{input-1.output}} - Add an LLM Task node with prompt containing
{{scraper-1.output}} - Run the workflow with a test URL
- Observe how variables are substituted with actual data
This variable substitution system enables powerful data flow between nodes, making workflows dynamic and flexible!