Large Language Models are excellent at transforming unstructured text into structured data, but they face challenges when it comes to accurately retrieving that data over extended conversations. In this post, we'll leverage this core strength and combine it with Postgres, along with several complementary tools, to build a personalized AI assistant capable of long-term memory retention.

At a high level, the system's flexibility is created by combining these core building blocks: An LLM owned database schema through an execute_sql tool, scheduled tasks for autonomy, web searches for real-time information, and MCP integrations for extended actions that may integrate with external tools.

See it at work in the video below.

Scoped Database Control#

The assistant uses a dedicated Postgres schema called memories to store all of its structured data. To ensure security, the LLM operates under a specific role, memories_role, which is granted permissions only within this schema.