Skip to main content

Personal Assistant

Build an AI assistant that learns about you over time and provides personalized help.

The Problem

Generic AI assistants:

  • Give the same advice to everyone
  • Can't remember your preferences
  • Ask for context you've already provided

The Solution

A memory-enabled assistant that:

  • Learns your preferences and habits
  • Provides personalized recommendations
  • Gets smarter with every interaction

What It Remembers

Personal Assistant Memory:
├── Preferences
│ ├── "Prefers morning meetings"
│ └── "Coffee: oat milk latte"
├── Context
│ ├── "Works at Acme Corp as PM"
│ └── "Main project: Q1 Launch"
└── Important Dates
├── "Partner's birthday: March 15"
└── "Project deadline: April 1"

Implementation

from openai import OpenAI
import requests

MEMORY_API = "https://api.memory.tensorheart.com/v1"
API_KEY = "mem_live_..."
openai = OpenAI()

def query_memory(user_id: str, context: str) -> list[str]:
"""Get relevant memories for this user."""
response = requests.post(
f"{MEMORY_API}/query",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"context": context,
"space_id": f"user_{user_id}",
"max_memories": 8
}
)
return [m["text"] for m in response.json().get("data", {}).get("memories", [])]

def personal_assistant(user_id: str, message: str) -> str:
"""A personalized AI assistant."""
memories = query_memory(user_id, message)
context = "\n".join(f"- {m}" for m in memories) if memories else "New user."

system_prompt = f"""You are a helpful personal assistant.

What you know about this user:
{context}

Use this naturally in responses. Be concise and actionable."""

response = openai.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": message}
]
)
return response.choices[0].message.content

Example Conversations

Day 1: Learning

User: Hey, I need help planning my day. I have back-to-back
meetings and a deadline Friday.

Bot: I'd suggest blocking 2-hour focus time for the deadline work.
What time are your meetings?

User: Mostly afternoons. I'm a morning person anyway.

Bot: Perfect. I'll note that you prefer mornings for deep work.

The assistant learns: "User prefers morning focus time"

Week 2: Personalized

User: I have a presentation tomorrow, when should I prep?

Bot: Since you do your best work in the morning, I'd block
9-11am tomorrow for prep. That gives you focused time
before your usual afternoon meetings.

What Makes This Work

FeatureHow It Helps
Preference learningAdapts to your style over time
Context retrievalOnly fetches relevant info per query
Space isolationEach user's memories are private

Next Steps