include:
- core/tools/create-mock.yaml
- core/tools/create-chat-message.yaml
- core/tools/create-document.yaml
pipelines:
- name: factory_example
title: "Example 2: Pipeline Factory"
type: root
workspace: examples
sequence:
- workflow: create_topics_workflow # Step 1: Setup topic list
- pipeline: article_processor_pipeline # Step 2: Process topics in parallel
- name: article_processor_pipeline
title: "Batch Article Processor"
type: factory
parallel: true # Run all instances in parallel. Defaults to false.
factory:
workflow: generate_article_workflow # Template workflow to execute
iterator:
source: ${ context.variables.TOPIC_LIST } # Array of topics to process
label: ${ item.topic } # Property to use for label. Defaults to ${ item }
namespace:
label: Articles # Namespace for organization
workflows:
- name: create_topics_workflow
title: "Setup Topics"
type: stateMachine
transitions:
- name: mock_topic_list
from: start
to: topics_ready
call:
- tool: create_mock
arguments:
input: 'Generate topic list for batch processing'
output:
- topic: "AI in Healthcare"
category: "technology"
- topic: "Sustainable Energy"
category: "environment"
- topic: "Quantum Computing"
category: "technology"
- topic: "Mental Health Apps"
category: "health"
exportContext: TOPIC_LIST
- name: display_topics
from: topics_ready
to: end
call:
- tool: create_chat_message
arguments:
role: 'assistant'
content: |
π **Batch Processing Started**
Processing {{ context.variables.TOPIC_LIST.length }} topics in parallel:
{{#each context.variables.TOPIC_LIST}}
- {{ this.topic }} ({{ this.category }})
{{/each}}
- name: generate_article_workflow
title: "Generate Article"
type: stateMachine
transitions:
- name: generate_content
from: start
to: content_generated
call:
- tool: create_mock
arguments:
input: |
Topic: {{ context.item.topic }}
Category: {{ context.item.category }}
output: |
This article explores the fascinating world of {{ context.item.topic }}...
as: ARTICLE_CONTENT
- name: create_article
from: content_generated
to: article_created
call:
- tool: create_document
arguments:
document: article_document
content:
topic: ${ context.item.topic }
category: ${ context.item.category }
article: ${ ARTICLE_CONTENT }
processed_at: "{{ currentDate }}"
- name: display_result
from: article_created
to: end
call:
- tool: create_chat_message
arguments:
role: 'assistant'
content: |
β
{{ context.item.topic }} Article Completed
documents:
- name: article_document
schema:
type: object
properties:
topic:
type: string
category:
type: string
article:
type: string
processed_at:
type: string
ui:
order:
- topic
- category
- article
- processed_at
properties:
article:
widget: textarea-expand
Last updated on