Use this file to discover all available pages before exploring further.
Imagine asking a search assistant for “coffee shops nearby” and instead of generic results, it shows remote-work-friendly cafes with great WiFi in your city because it remembers you mentioned working remotely before. Or when you search for “lunchbox ideas for kids” it knows you have a 7-year-old daughter and recommends peanut-free options that align with her allergy.That’s what we are going to build today, a Personalized Search Assistant powered by Mem0 for memory and Tavily for real-time search.
Most assistants treat every query like they’ve never seen you before. That means repeating yourself about your location, diet, or preferences, and getting results that feel generic.
With Mem0, your assistant builds a memory of the user’s world.
With Tavily, it fetches fresh and accurate results in real time.
Together, they make every interaction smarter, faster, and more personal.
We configure Mem0 with custom instructions that guide it to infer user memories tailored specifically for our usecase.
from mem0 import MemoryClientmem0_client = MemoryClient()mem0_client.project.update( custom_instructions='''INFER THE MEMORIES FROM USER QUERIES EVEN IF IT'S A QUESTION.We are building personalized search for which we need to understand about user's preferences and lifeand extract facts and memories accordingly.''')
Now, if a user casually mentions “I need to pick up my daughter” or “What’s the weather at Los Angeles”, Mem0 remembers they have a daughter or the user is interested in or connected with Los Angeles in terms of location. These details will be referenced for future searches.
To test personalization, we preload some sample conversation history for a user:
def setup_user_history(user_id): conversations = [ [{"role": "user", "content": "What will be the weather today at Los Angeles? I need to pick up my daughter from office."}, {"role": "assistant", "content": "I'll check the weather in LA for you."}], [{"role": "user", "content": "I'm looking for vegan restaurants in Santa Monica"}, {"role": "assistant", "content": "I'll find great vegan options in Santa Monica."}], [{"role": "user", "content": "My 7-year-old daughter is allergic to peanuts"}, {"role": "assistant", "content": "I'll remember to check for peanut-free options."}], [{"role": "user", "content": "I work remotely and need coffee shops with good wifi"}, {"role": "assistant", "content": "I'll find remote-work-friendly coffee shops."}], [{"role": "user", "content": "We love hiking and outdoor activities on weekends"}, {"role": "assistant", "content": "Great! I'll keep your outdoor activity preferences in mind."}], ] for conversation in conversations: mem0_client.add(conversation, user_id=user_id)
This gives the agent a baseline understanding of the user’s lifestyle and needs.
if __name__ == "__main__": user_id = "john" setup_user_history(user_id) queries = [ "good coffee shops nearby for working", "what can I make for my kid in lunch?" ] for q in queries: results = conduct_personalized_search(user_id, q) print(f"\nQuery: {q}") print(f"Personalized Response: {results['agent_response']}")
With Mem0 and Tavily, you can build a search assistant that doesn’t just fetch results but understands the person behind the query.Whether for shopping, travel, or daily life, this approach turns a generic search into a truly personalized experience.Full Code: Personalized Search GitHub
Deep Research with Mem0
Build comprehensive research agents that remember findings across sessions.
Tag and Organize Memories
Categorize search results and user preferences for better personalization.