Skip to main content

Moss vector search integration for Pipecat

Project description

Pipecat Moss Integration

Moss delivers sub-10ms semantic retrieval, ensuring your Pipecat AI voice agents respond naturally without noticeable delays.

Installation

Install the package

pip install pipecat-moss

Prerequisites

  • Moss project ID and project key (get them from Moss Portal)
  • Deepgram, OpenAI, Cartesia API keys (to run the example)

Usage with Pipecat Pipeline

Pipecat-Moss integrates seamlessly into a Pipecat pipeline, enabling efficient retrieval-based operations. It leverages Pipecat's modular architecture to inject semantic context for Voice AI Agents.

import os
import asyncio
from pipecat_moss import MossRetrievalService

moss_service = MossRetrievalService(
    project_id=os.getenv("MOSS_PROJECT_ID"),
    project_key=os.getenv("MOSS_PROJECT_KEY"),
    system_prompt="Relevant passages from the Moss knowledge base:\n\n",
)

async def setup_indexes():
    await moss_service.load_index(os.getenv("MOSS_INDEX_NAME"))

asyncio.run(setup_indexes())

pipeline = Pipeline([
    transport.input(),               # audio/user input
    stt,                             # speech to text
    context_aggregator.user(),       # add user text to context
    moss_service.query(os.getenv("MOSS_INDEX_NAME"), top_k=5, alpha=0.8),  # retrieve relevant docs from Moss
    llm,                             # LLM generates response
    tts,                             # TTS synthesis
    transport.output(),              # stream audio back to user
    context_aggregator.assistant(),  # store assistant response
])

setup_indexes() must be awaited before the pipeline starts so the service can load the Moss index. See examples/moss-retrieval-demo.py for a complete working example.

Pipecat Compatibility

Tested with Pipecat v0.0.94. Please upgrade to this version (or newer) to ensure API compatibility with the snippets below.

Contributing

If you are contributing or want to build from source, follow the CONTRIBUTING.md setup steps.

Running the Example

Setup Environment Variables

Create a .env file in the root directory with the following content:

MOSS_PROJECT_ID= Your Moss Project ID
MOSS_PROJECT_KEY= Your Moss Project Key
MOSS_INDEX_NAME= Your Moss Index Name

DEEPGRAM_API_KEY= Your DEEPGRAM API KEY
CARTESIA_API_KEY= Your CARTESIA API KEY
OPENAI_API_KEY= Your OpenAI Key

Or pass them directly when creating the MossRetrievalService.

Creating a Moss Index (One-time Setup)

Before using Moss in your pipeline, you need to create an index and populate it with documents:

python examples/moss-create-index-demo.py

Run the Example

python examples/moss-retrieval-demo.py

Configuration Options

MossRetrievalService

  • project_id (required): Moss project ID (can use env var MOSS_PROJECT_ID)
  • project_key (required): Moss project key (can use env var MOSS_PROJECT_KEY)
  • system_prompt (default: "Here is additional context retrieved from database:\n\n"): Prefix added ahead of retrieved documents
  • load_index(index_name): Awaitable method that loads the given index before the pipeline runs
  • query(index_name, *, top_k=5): Returns a MossIndexProcessor for the specified index; top_k controls result count, alpha blends semantic vs keyword scoring (0.0 keyword-only, 1.0 semantic-only)

License

This integration is provided under a permissive open source license (BSD-2 or equivalent).

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipecat_moss-0.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipecat_moss-0.0.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pipecat_moss-0.0.1.tar.gz.

File metadata

  • Download URL: pipecat_moss-0.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pipecat_moss-0.0.1.tar.gz
Algorithm Hash digest
SHA256 382842a3ea85ebf0853d914120fb06706c5c775fbcdee408ae8324ecc7f7c4bd
MD5 051cdbc1c32d9afe2ffdffde48cd735f
BLAKE2b-256 4992409b5ab0c9e41c79a90fec3c220c164773b9d3c2092da2fa325617e22f48

See more details on using hashes here.

File details

Details for the file pipecat_moss-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pipecat_moss-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pipecat_moss-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 224680c93aa23994d5247de8befdc20f4d33ee0856c1f4c9e8c8c9ada7a5f845
MD5 c33161b46eb3a858b7056e5e5c7d7ad0
BLAKE2b-256 c6a807299757ba025c5e5043c22d3d6ac986c0cc79844610eb6f9da190110b6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page