mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-30 01:51:28 +00:00
examples/voice_agent.py runs in console mode or joins LiveKit rooms. It scopes memory from dispatch metadata, SUPERMEMORY_CONTAINER_TAG, or the participant, preloads the caller's profile, and greets returning callers by name. Tested on LiveKit Cloud: a second call greeted the caller by name and used a fact from the first call. The example is not included in the wheel or sdist.
1.6 KiB
1.6 KiB
Voice agent example
A LiveKit voice agent that remembers each caller. Tell it something on one call, hang up, and it knows it on the next.
Setup
pip install supermemory-livekit python-dotenv
cp .env.example .env
Fill in .env with your LiveKit Cloud project keys and a Supermemory API key. LiveKit Inference provides speech-to-text, the LLM, and text-to-speech, so no other keys are needed.
From a checkout of this repo, install the local package instead: pip install -e .. python-dotenv.
Talk to it
In your terminal, through your mic:
python voice_agent.py console
In the browser: run python voice_agent.py dev, open the Agents Playground, and connect to your project.
Try memory
- Say "My name is Priya, and please remember I'm vegetarian."
- Hang up and start a new call.
- The agent greets you by name. Ask "What should I order for dinner?"
Memory is scoped per caller:
- Console mode uses the container tag
console_user. - In rooms, the agent uses the participant attribute
supermemory_container_tag, or else the participant identity. The Playground gives each session a new identity, so setSUPERMEMORY_CONTAINER_TAGin.envto keep one caller across Playground calls. - In production, dispatch the agent from your backend with
{"container_tag": "<your user id>"}as job metadata, and setLIVEKIT_AGENT_NAME.
Each call is stored as one document, and facts the caller asks it to remember are saved right away. See the integration docs for configuration.