Use with Pipecat
Integrate with the Pipecat framework from Daily.co for creating conversational voice AI agents with duohub memory
Integrating duohub memory with Pipecat
Learn how to enhance your Pipecat conversational AI agents with duohub memory capabilities for more contextual and persistent conversations.
Overview
Pipecat is a framework from Daily.co for building voice AI agents. By integrating duohub memory, your agents can maintain context across conversations and access relevant information from past interactions.
Prerequisites
Window Class Setup
First, create a Window class to manage conversation context and memory:
Integrating with Pipecat Bot
Here’s how to set up your bot with the Window class:
Key Components Explained
Window Class
- Manages conversation history
- Integrates with duohub client
- Retrieves relevant context for each user message
- Maintains conversation window size (latest 10 messages)
Context Aggregator
- Handles message flow between the Window and pipeline
- Ensures proper message ordering
- Manages user and assistant message handling
Pipeline Configuration
The pipeline is set up with the following flow:
- Input from Daily.co transport
- User context processing
- LLM processing
- Text-to-speech conversion
- Output to transport
- Assistant context processing
Memory ID Configuration
You can configure your duohub memory ID in several ways:
- Environment Variable:
- Direct Assignment:
Best Practices
-
Memory Management
- Keep memory IDs organized by conversation topic or user
- Regularly clean up unused memories
- Monitor memory usage and implement retention policies
-
Context Retrieval
- Implement retry logic for duohub queries
- Consider rate limiting for large conversation volumes
- Cache frequently accessed context
-
Error Handling
- Performance Optimization
- Implement message pruning for long conversations
- Use async/await for network operations
- Consider batching for multiple context queries
Debugging Tips
- Enable debug logging:
- Monitor duohub responses:
- Track message flow:
Common Issues and Solutions
-
Missing Context
- Verify memory ID is correct
- Check duohub API key permissions
- Ensure queries are properly formatted
-
Performance Issues
- Implement caching for frequent queries
- Optimize message window size
- Use connection pooling for API calls
-
Memory Usage
- Implement message cleanup
- Monitor context size
- Use streaming for large responses