Build an agent with memory

Create an AI agent that remembers important information across conversations.

Agents · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

This pattern is inspired by Pixelbot and Pixelmemory.

What it covers

  • Store memories with embeddings for semantic search
  • Retrieve relevant memories based on conversation context
  • Use @pxt.query for retrieval functions

What it uses

Install
terminal
pip install pixeltable openai
Environment variables it names
OPENAI_API_KEY
Pixeltable calls
openai.chat_completions()pxt.create_table()@pxt.query@pxt.udfadd_embedding_index()similarity()insert()add_computed_column()

A look at the code

pattern-agent-memory.ipynb
# Add embedding index for semantic search on content
memories.add_embedding_index(
column='content',
string_embed=embeddings.using(model='text-embedding-3-small'),
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103