Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state management access to static functions #72

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ There are two types of actions available:

Learn more about built-in actions and defining your own action in the docs.

#### State Management

Flows can maintain state across nodes using two approaches:

1. **Static Flows with State References**

```python
"task_messages": [
{
"role": "system",
"content": "Current order: $state.orders" # Access state in messages
}
]
```

2. **Dynamic Flows with State Management**

```python
async def handle_order(args: Dict, flow_manager: FlowManager):
flow_manager.state["orders"].append(args) # Manage state in transitions
await flow_manager.set_node("confirm", create_confirm_node())
```

State can be used to track conversation progress, store user data, or maintain context across nodes.

#### Provider-Specific Formats

Pipecat Flows automatically handles format differences between LLM providers:
Expand Down Expand Up @@ -295,7 +320,8 @@ The repository includes several complete example implementations in the `example

In the `examples/static` directory, you'll find these examples:

- `food_ordering.py` - A restaurant order flow demonstrating node and edge functions
- `food_ordering_basic.py` - A simple restaurant order flow demonstrating node and edge functions
- `food_ordering_state.py` - The same flow enhanced with state management for tracking orders
- `movie_explorer_openai.py` - Movie information bot demonstrating real API integration with TMDB
- `movie_explorer_anthropic.py` - The same movie information demo adapted for Anthropic's format
- `movie_explorer_gemini.py` - The same movie explorer demo adapted for Google Gemini's format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
# SPDX-License-Identifier: BSD 2-Clause License
#

"""
Basic Food Ordering Example (without state)

This example demonstrates:
- Basic static flow configuration
- Simple node transitions
- Function handlers
- LLM interactions

A simpler starting point for learning Pipecat Flows.

Requirements:
- Daily room URL
- OpenAI API key
- Deepgram API key
- Cartesia API key
"""

import asyncio
import os
import sys
Expand Down
Loading
Loading