| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Examples demonstrating different approaches to modeling conversational flows with LiveKit agents, from simple linear progressions to complex state-based interactions.
As conversational AI applications grow in complexity, the way we model agent behavior becomes increasingly important. This directory contains three examples that demonstrate different patterns for managing conversational flows, each suited to different levels of complexity.
When building conversational agents, you'll encounter a fundamental design choice: should you model your conversation as a flow (like a flowchart) or as states (like a state machine)?
Flowcharts are great for conversations that:
Example: A personality quiz that asks 3 questions and gives you a result.
State machines become valuable when conversations:
Example: An NPC in a game who remembers past interactions and responds differently based on relationship status.
Pattern: Function-based agent transitions with direct branching
This example shows the most straightforward approach where each agent directly returns the next agent in the flow. Perfect for linear conversations with minimal branching.
Key Features:
Flow:
GreetingAgent → AskColorAgent → SummaryAgent
Use Cases:
Pattern: Dictionary-based flow definition with lambda transitions
This approach separates flow logic from agent implementation, making it easier to visualize and modify the overall conversation structure.
Key Features:
Flow Definition:
flow = {
"collect_name": {
"agent": CollectNameAgent,
"next": lambda state: "collect_email"
},
"collect_email": {
"agent": CollectEmailAgent,
"next": lambda state: "summary"
},
"summary": {
"agent": SummaryAgent,
"next": None
}
}Use Cases:
Pattern: Complex branching with multiple decision points
This example demonstrates a sophisticated branching survey where each choice leads to different follow-up questions, creating a tree-like conversation structure.
Key Features:
Flow Structure:
Stage 1: A or B? ├── A → Why A? → Stage 2 └── B → Why B? → Stage 2 Stage 2: X or Y? ├── X → What about X? → Stage 3 └── Y → What about Y? → Stage 3 Stage 3: M or N? ├── M → Why M? → Summary └── N → Why N? → Summary
Use Cases:
Use simple_flow.py style:
Use declarative_flow.py style:
Consider:
Sometimes the best approach combines multiple patterns:
Each example can be run independently:
# Simple linear flow
python simple_flow.py console
# Declarative flow with config
python declarative_flow.py console
# Complex branching survey
python multi_stage_flow.py console| Back | FazBrowse Home | New Git URL |