Skip to main content

Smaran Pipecat SDK

Memory-enhanced conversational AI pipelines with Smaran and Pipecat.

Installation

pip install smaran-pipecat

Quick Start

import os
from pipecat.pipeline.pipeline import Pipeline
from smaran_pipecat import SmaranPipecatService

# Create memory service
memory = SmaranPipecatService(
    api_key=os.getenv("SMARAN_API_KEY"),
    base_url=os.getenv("SMARAN_URL"),
    user_id="user-123",
    session_id="conversation-456",  # Optional: groups saved memories by session
)

# Add to Pipecat pipeline
pipeline = Pipeline([
    transport.input(),
    stt,
    context_aggregator.user(),
    memory,  # Automatically recalls and injects relevant memories
    llm,
    transport.output(),
    context_aggregator.assistant(),
])

Configuration

Parameters

Parameter Type Required Description
user_id str Yes User identifier memories are scoped to
session_id str No Session/conversation ID for grouping saved memories
api_key str No Smaran API key (or set SMARAN_API_KEY env var)
base_url str No Smaran API base URL (or set SMARAN_URL env var)
params InputParams No Advanced configuration

Advanced Configuration

from smaran_pipecat import SmaranPipecatService

memory = SmaranPipecatService(
    user_id="user-123",
    session_id="conv-456",
    params=SmaranPipecatService.InputParams(
        search_limit=5,             # Max memories to recall per turn
        system_prompt="Based on previous conversations, I recall:\n\n",
        inject_mode="auto",         # "auto", "system", or "user"
        save_memory=True,           # Save new memories after each turn
    ),
)

How It Works

  1. Intercepts context frames — listens for LLMContextFrame in the pipeline
  2. Recalls memories — queries Smaran's /v1/recall API with the user's latest message
  3. Injects memories — formats recalled facts and adds them to the LLM context
  4. Saves messages — sends new user/assistant turns to Smaran's /v1/memories API in the background, non-blocking

Full Example

import asyncio
import os
from fastapi import FastAPI, WebSocket
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.task import PipelineTask
from pipecat.pipeline.runner import PipelineRunner
from pipecat.processors.aggregators.llm_context import LLMContext, LLMContextAggregatorPair
from pipecat.transports.websocket.fastapi import (
    FastAPIWebsocketTransport,
    FastAPIWebsocketParams,
)
from smaran_pipecat import SmaranPipecatService

app = FastAPI()

@app.websocket("/chat")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()

    transport = FastAPIWebsocketTransport(
        websocket=websocket,
        params=FastAPIWebsocketParams(audio_in_enabled=True, audio_out_enabled=True),
    )

    context = LLMContext([{"role": "system", "content": "You are a helpful assistant."}])
    context_aggregator = LLMContextAggregatorPair(context)

    memory = SmaranPipecatService(
        user_id="alice",
        session_id="session-123",
    )

    pipeline = Pipeline([
        transport.input(),
        context_aggregator.user(),
        memory,
        llm,
        transport.output(),
        context_aggregator.assistant(),
    ])

    runner = PipelineRunner()
    task = PipelineTask(pipeline)
    await runner.run(task)

Check Pipecat's own docs for the current LLM service and context-aggregator setup for your provider — that surface moves fast between Pipecat versions.

License

MIT

Download files

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

Source Distribution

smaran_pipecat-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

smaran_pipecat-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file smaran_pipecat-0.1.1.tar.gz.

File metadata

  • Download URL: smaran_pipecat-0.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for smaran_pipecat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 09334f5978754351d917f271ad88333e4bd3d45a36949b9f51fa803ab9cb8efb
MD5 9836fc7f024ff0e28a656bf6bb5cf771
BLAKE2b-256 b83e8c0c56dade66620d754044ecadc6a3c434a091bae317d00d2fa9ee5e5014

See more details on using hashes here.

Provenance

The following attestation bundles were made for smaran_pipecat-0.1.1.tar.gz:

Publisher: publish-pipecat-sdk-python.yml on Ayushpani/smaran

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smaran_pipecat-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: smaran_pipecat-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for smaran_pipecat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7fc078c663f8b2f23fc9b83f331e5f5e8a557825001af3ce9645a2036aa7573d
MD5 93c4ffbb0ea655dc127251057bf030ab
BLAKE2b-256 3fb1e0fca0df0b04de9945eecbbe0f592108cdbecf5114a03fbcdec4597dc444

See more details on using hashes here.

Provenance

The following attestation bundles were made for smaran_pipecat-0.1.1-py3-none-any.whl:

Publisher: publish-pipecat-sdk-python.yml on Ayushpani/smaran

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page