AgenticFlow AI: ChatGPT in the Flow of Work
HomeCommunityDiscordLogin
  • Get Started
    • AgenticFlow - the OS for your AI Workforce
    • llms.txt
    • FAQs
    • Key Concepts
      • Workflows
      • Templates
      • Data
      • Agent
      • API Keys
      • AgenticFlow MCP
    • Workflows quickstart
    • Agents quickstart
    • Introduction to Large Language Models
    • Plans and Credits
    • System Quotas
    • Affiliate program 💵
  • AGENTS
    • Introduction to agents
    • Agent Templates
    • Create an Agent
    • Customize an Agent
    • FAQ
  • Workflows
    • Introduction
    • Workflow Templates
    • Creating a Workflow
    • User Inputs - Get Started
      • Text Input
      • Long text input
      • Drop-down
      • Numeric Input
      • File to URL
      • File to Text
      • Checkbox
      • Image Input
      • Audio Input
      • Video Input
      • Multiple Media Input
      • Carousel Select Input
    • Actions - Get Started
      • LLM
        • LLM - Advanced Settings
        • Validators
        • Too Much Text
        • LLM Prompt
        • LLM Output
      • Code - JavaScript
      • Code - Python
      • Python Helper Functions
      • PDF to text
      • Extract Website Content
      • Knowledge Search
      • Audio/Video to Text
      • Insert Data into a Dataset
    • Knowledge
    • Workflow Single Run
    • Workflow Table Run
    • Export Results
    • API Run
    • FAQ
    • Parameter Substitution Utility
  • Data
    • Introduction
    • Data Table
    • FAQ
  • Use Cases
    • Summarization
      • GPT on My Files
      • GPT on My Website
      • Question-Answering on Data
    • Research
      • Sentiment Analysis
      • Anonymize Text
      • Audio Transcription + High-Level Analysis
  • Sales
    • Teach LLMs to Mimic Your Style
  • Marketing
    • SEO Optimize
    • Automating Creativity Transforming Workflow with AgenticFlow AI (PDF)
  • Policies
    • Security Overview
      • AI Policy
      • Reporting bugs and vulnerabilities
      • Subprocessors
      • DPA
    • Privacy Policy
    • Terms of Service
    • Cookies Policy
Powered by GitBook
On this page

Was this helpful?

  1. Workflows

Parameter Substitution Utility

A Python utility for flexible variable substitution in templates, supporting complex data structures and nested access patterns.

The Parameter Substitution Utility provides a flexible way to substitute variables into templates using a familiar {{ variable_name }} syntax. It supports nested dictionaries, list indexing, and complex data navigation, along with error handling and a stringify filter.


Features

  • Simple variable substitution

  • Nested dictionary access using dot notation

  • Array indexing with zero-based indices

  • Complex data structure navigation (nested arrays and dictionaries)

  • JSON stringify filter

  • Robust error handling


Usage Examples

1. Basic String Substitution

from shared.utils.param_substitute import substitute_params

data = {"name": "John", "age": 30}
template = "Hello {{ name }}, you are {{ age }} years old"
result = substitute_params(data, template)
# => "Hello John, you are 30 years old"

2. Nested Dictionary Access

data = {"user": {"info": {"name": "Alice", "age": 25}}}
template = "{{ user.info.name }} is {{ user.info.age }}"
result = substitute_params(data, template)
# => "Alice is 25"

3. Array Operations

data = {"items": ["apple", "banana", "orange"]}
template = "{{ items[1] }}"
result = substitute_params(data, template)
# => "banana"

4. Complex Data Structure Navigation

data = {
    "teams": [
        {
            "members": [
                {"name": "Alice", "roles": ["dev", "lead"]},
                {"name": "Bob", "roles": ["dev"]}
            ]
        }
    ]
}
template = "{{ teams[0].members[0].roles[0] }}"
result = substitute_params(data, template)
# => "dev"

5. Using the Stringify Filter

data = {"obj": {"name": "John", "age": 30}}
template = "{{ obj | stringify }}"
result = substitute_params(data, template)
# => '{"name": "John", "age": 30}'

6. List Template

data = {"name": "John", "hobbies": ["reading", "gaming"]}
template = ["Hello {{ name }}", "{{ hobbies[0] }}", "{{ hobbies[1] }}"]
result = substitute_params(data, template)
# => ["Hello John", "reading", "gaming"]

7. Dictionary Template

data = {"user": "admin", "role": "superuser"}
template = {"username": "{{ user }}", "access": "{{ role }}"}
result = substitute_params(data, template)
# => {"username": "admin", "access": "superuser"}

Error Handling

  • Returns None for undefined variables

  • Preserves non-template strings as-is

  • Type-safe implementation using Python type hints

PreviousFAQNextIntroduction

Last updated 1 month ago

Was this helpful?