📢 Announcing our research paper: Zentry achieves 26% higher accuracy than OpenAI Memory, 91% lower latency, and 90% token savings! Read the paper to learn how we're revolutionizing AI agent memory.
Welcome to the zentry quickstart guide. This guide will help you get up and running with zentry in no time.
messages = [ {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}]# Store inferred memories (default behavior)result = m.add(messages, user_id="alice", metadata={"category": "movie_recommendations"})# Store raw messages without inference# result = m.add(messages, user_id="alice", metadata={"category": "movie_recommendations"}, infer=False)
zentry offers extensive configuration options to customize its behavior according to your needs. These configurations span across different components like vector stores, language models, embedders, and graph stores.
zentry can be easily integrated into chat applications to enhance conversational agents with structured memory. zentry’s APIs are designed to be compatible with OpenAI’s, with the goal of making it easy to leverage zentry in applications you may have already built.
If you have a zentry API key, you can use it to initialize the client. Alternatively, you can initialize zentry without an API key if you’re using it locally.
zentry supports several language models (LLMs) through integration with various providers.
from zentry.proxy.main import zentryclient = zentry(api_key="m0-xxx")# First interaction: Storing user preferencesmessages = [ { "role": "user", "content": "I love indian food but I cannot eat pizza since allergic to cheese." },]user_id = "alice"chat_completion = client.chat.completions.create(messages=messages, model="gpt-4o-mini", user_id=user_id)# Memory saved after this will look like: "Loves Indian food. Allergic to cheese and cannot eat pizza."# Second interaction: Leveraging stored memorymessages = [ { "role": "user", "content": "Suggest restaurants in San Francisco to eat.", }]chat_completion = client.chat.completions.create(messages=messages, model="gpt-4o-mini", user_id=user_id)print(chat_completion.choices[0].message.content)# Answer: You might enjoy Indian restaurants in San Francisco, such as Amber India, Dosa, or Curry Up Now, which offer delicious options without cheese.
In this example, you can see how the second response is tailored based on the information provided in the first interaction. zentry remembers the user’s preference for Indian food and their cheese allergy, using this information to provide more relevant and personalized restaurant suggestions in San Francisco.
Get started with using zentry APIs in your applications. For more details, refer to the Platform.
Here is an example of how to use zentry APIs:
Copy
import osfrom zentry import MemoryClientos.environ["zentry_API_KEY"] = "your-api-key"client = MemoryClient() # get api_key from https://app.zentry.gg/# Store messagesmessages = [ {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."}, {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."}]result = client.add(messages, user_id="alex")print(result)# Retrieve memoriesall_memories = client.get_all(user_id="alex")print(all_memories)# Search memoriesquery = "What do you know about me?"related_memories = client.search(query, user_id="alex")# Get memory historyhistory = client.history(memory_id="m1")print(history)