Build personal browser agent remembers user preferences and automates web tasks. It integrates Mem0 for memory management with MultiOn for executing browser actions, enabling personalized and efficient web interactions.

Overview

In this guide, we’ll explore two examples of creating Browser-based AI Agents:

  1. An agent that searches arxiv.org for research papers relevant to user’s research interests.
  2. A travel agent that provides personalized travel information based on user preferences. Refer the notebook for detailed code.

Setup and Configuration

Install necessary libraries:

pip install mem0ai multion openai

First, we’ll import the necessary libraries and set up our configurations.

import os
from mem0 import Memory, MemoryClient
from multion.client import MultiOn
from openai import OpenAI

# Configuration
OPENAI_API_KEY = 'sk-xxx'  # Replace with your actual OpenAI API key
MULTION_API_KEY = 'your-multion-key'  # Replace with your actual MultiOn API key
MEM0_API_KEY = 'your-mem0-key'  # Replace with your actual Mem0 API key
USER_ID = "your-user-id"

# Set up OpenAI API key
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY

# Initialize Mem0 and MultiOn
memory = Memory()  # For local usage
memory_client = MemoryClient(api_key=MEM0_API_KEY)  # For API usage
multion = MultiOn(api_key=MULTION_API_KEY)

Example 1: Research Paper Search Agent

Add memories to Mem0

Define user data and add it to Mem0.

USER_DATA = """
About me
- I'm Deshraj Yadav, Co-founder and CTO at Mem0, interested in AI and ML Infrastructure.
- Previously, I was a Senior Autopilot Engineer at Tesla, leading the AI Platform for Autopilot.
- I built EvalAI at Georgia Tech, an open-source platform for evaluating ML algorithms.
- Outside of work, I enjoy playing cricket in two leagues in the San Francisco.
"""

memory.add(USER_DATA, user_id=USER_ID)
print("User data added to memory.")

Retrieving Relevant Memories

Define search command and retrieve relevant memories from Mem0.

command = "Find papers on arxiv that I should read based on my interests."

relevant_memories = memory.search(command, user_id=USER_ID, limit=3)
relevant_memories_text = '\n'.join(mem['text'] for mem in relevant_memories)
print(f"Relevant memories:")
print(relevant_memories_text)

Browsing arXiv

Use MultiOn to browse arXiv based on the command and relevant memories.

prompt = f"{command}\n My past memories: {relevant_memories_text}"
browse_result = multion.browse(cmd=prompt, url="https://arxiv.org/")
print(browse_result)

Example 2: Travel Agent

Get Travel Information

Add conversation to Mem0 and create a function to get travel information based on user’s question and optionally their preferences from memory.

Conclusion

By integrating Mem0 with MultiOn, you’ve created personalized browser agents that remember user preferences and automate web tasks. The first example demonstrates a research-focused agent, while the second example shows a travel agent capable of providing personalized recommendations.

These examples illustrate how combining memory management with web browsing capabilities can create powerful, context-aware AI agents for various applications.

Help