Skip to content

Instantly share code, notes, and snippets.

@elifiner
Created November 13, 2024 03:05
Show Gist options
  • Save elifiner/c6f3f9ea27469476061752ee94672a1f to your computer and use it in GitHub Desktop.
Save elifiner/c6f3f9ea27469476061752ee94672a1f to your computer and use it in GitHub Desktop.
import os
import time
from dotenv import load_dotenv
from mem0 import MemoryClient
MEMORY_CONTENT = """The second thing I want to capture is Learning - looks like going top to bottom is useful here.
I'm trying to build a curriculum to fill in my gaps in general knowledge. I want to become an educated person with enough grasp of the fundamentals of many (all?) subjects to have an intelligent discussion on any topic. The word "erudite" comes to mind. Maybe something like Elon Musk when he's not talking about things he has specific skill in (engineering and rocket science). Possibly similar to the classical education ideas we're exploring for homeschooling with The Core by Leigh Bortins. It's a bit overwhelming to consider, but here's an initial list of topics: history, literature, philosophy, geography, politics (theory and practice), math (esp. linear algebra, calculus and statistics), economy, biology, chemistry, physics ability to read scientific papers, a few additional languages - likely German, Arabic, French, Spanish, Mandarin, Japanese. I'd like to learn to play the piano, get better at playing the guitar, learn how to carry a tune and be able to play a few dozen common songs for pleasure.
Using Bortins approach I think I'll prefer to learn these topics by tackling source material (at least for the humanities), but each topic has a series of fundamentals I'll need to cover and memorize so I can tackle the source material.
This is sort of like a Bachelor of Everything.
This is a very big lift and I'll need to break this down into phases. I can tackle this either by layers (a bit of everything all at once) or by topics.
"""
def main():
load_dotenv()
api_key = os.environ["MEM0_API_KEY"]
user_id = "eli-test"
client = MemoryClient(api_key=api_key)
print("Clearing existing memories...")
client.delete_all(user_id=user_id)
message = {"role": "user", "content": MEMORY_CONTENT}
print("Adding memory...")
start_time = time.time()
client.add(
messages=[message],
user_id=user_id,
output_format="v1.1"
)
elapsed_time = time.time() - start_time
print(f"Memory added in {elapsed_time:.2f} seconds")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment