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
- Intercepts context frames — listens for
LLMContextFramein the pipeline - Recalls memories — queries Smaran's
/v1/recallAPI with the user's latest message - Injects memories — formats recalled facts and adds them to the LLM context
- Saves messages — sends new user/assistant turns to Smaran's
/v1/memoriesAPI 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09334f5978754351d917f271ad88333e4bd3d45a36949b9f51fa803ab9cb8efb
|
|
| MD5 |
9836fc7f024ff0e28a656bf6bb5cf771
|
|
| BLAKE2b-256 |
b83e8c0c56dade66620d754044ecadc6a3c434a091bae317d00d2fa9ee5e5014
|
Provenance
The following attestation bundles were made for smaran_pipecat-0.1.1.tar.gz:
Publisher:
publish-pipecat-sdk-python.yml on Ayushpani/smaran
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smaran_pipecat-0.1.1.tar.gz -
Subject digest:
09334f5978754351d917f271ad88333e4bd3d45a36949b9f51fa803ab9cb8efb - Sigstore transparency entry: 2726262677
- Sigstore integration time:
-
Permalink:
Ayushpani/smaran@424c5a332d6e13a2adb3c2ba6a9554ea4cb12662 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Ayushpani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pipecat-sdk-python.yml@424c5a332d6e13a2adb3c2ba6a9554ea4cb12662 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fc078c663f8b2f23fc9b83f331e5f5e8a557825001af3ce9645a2036aa7573d
|
|
| MD5 |
93c4ffbb0ea655dc127251057bf030ab
|
|
| BLAKE2b-256 |
3fb1e0fca0df0b04de9945eecbbe0f592108cdbecf5114a03fbcdec4597dc444
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smaran_pipecat-0.1.1-py3-none-any.whl -
Subject digest:
7fc078c663f8b2f23fc9b83f331e5f5e8a557825001af3ce9645a2036aa7573d - Sigstore transparency entry: 2726262711
- Sigstore integration time:
-
Permalink:
Ayushpani/smaran@424c5a332d6e13a2adb3c2ba6a9554ea4cb12662 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Ayushpani
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pipecat-sdk-python.yml@424c5a332d6e13a2adb3c2ba6a9554ea4cb12662 -
Trigger Event:
push
-
Statement type: