Skip to main content

Integrating duohub memory with Pipecat

Learn how to enhance your Pipecat conversational AI agents with duohub memory capabilities for more contextual and persistent conversations.

Examples GitHub Repository

See how to create a voice AI bot with Pipecat and duohub memory on GitHub

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:
  1. Input from Daily.co transport
  2. User context processing
  3. LLM processing
  4. Text-to-speech conversion
  5. Output to transport
  6. Assistant context processing

Memory ID Configuration

You can configure your duohub memory ID in several ways:
  1. Environment Variable:
  1. Direct Assignment:

Best Practices

  1. Memory Management
    • Keep memory IDs organized by conversation topic or user
    • Regularly clean up unused memories
    • Monitor memory usage and implement retention policies
  2. Context Retrieval
    • Implement retry logic for duohub queries
    • Consider rate limiting for large conversation volumes
    • Cache frequently accessed context
  3. Error Handling
  1. Performance Optimization
    • Implement message pruning for long conversations
    • Use async/await for network operations
    • Consider batching for multiple context queries

Debugging Tips

  1. Enable debug logging:
  1. Monitor duohub responses:
  1. Track message flow:

Common Issues and Solutions

  1. Missing Context
    • Verify memory ID is correct
    • Check duohub API key permissions
    • Ensure queries are properly formatted
  2. Performance Issues
    • Implement caching for frequent queries
    • Optimize message window size
    • Use connection pooling for API calls
  3. Memory Usage
    • Implement message cleanup
    • Monitor context size
    • Use streaming for large responses