Client library of MemoBase: manage user memory for your LLM applications
Project description
🌬️ Does your AI forget your users?
MemoBase maintains long-term memory of your users, for your product.
🖼️ Do you understand the customers that using your AI?
MemoBase offers accurate user profile, involving many aspects of your users: Age, Education, Interests, Opinions...
Customize the aspects you want MemoBase to collect.
⌛️ Do you want users spend more time on your Apps?
MemoBase is working with some AI companion startups. They have observated increased chatting turns after adopting MemoBase, leading to higher user retention and subscription rate.
Get Started
-
Start your MemoBase Backend, you should have the below two things to continue:
-
A project url. default to
http://localhost:8019
-
A project token. default to
secret
-
-
Install the Python SDK:
pip install memobase
-
Get ready to remember your customers now:
Make sure you're connected
from memobase import MemoBaseClient, ChatBlob
mb = MemoBaseClient("http://localhost:8019", "secret")
assert mb.ping()
User CURD
uid = mb.add_user({"any_key": "any_value"})
mb.update_user({"any_key": "any_value2"})
u = mb.get_user(uid)
print(u)
Delete: mb.delete(uid)
Single User Data
In MemoBase, all types of data are blobs to a user that can insert, get and delete:
messages = [
{
"role": "user",
"content": "Hello, I'm Gus",
},
{
"role": "assistant",
"content": "Hi, nice to meet you, Gus!",
}
]
bid = u.insert(ChatBlob(messages=messages))
print(u.get(bid))
Delete: u.delete(bid)
. Delete a blob will cause forgetting memories that only related to this blob.
"Flush it moment"
u.flush()
And what will you get?
print(u.profile())
# [UserProfile(topic="basic_info", sub_topic="name", content="Gus"),...]
u.profile()
will return a list of profiles that are learned from this user, including topic
, sub_topic
and content
. As you insert more blobs, the profiles will become better.
Why need a flush?
In MemoBase, we don't memoize users in hot path. We use buffer zones for the recent inserted blobs.
When the buffer zone is too large (e.g. 1024 tokens) or idle for a long time (e.g. 1 hour), MemoBase will flush the whole buffer into the memory. Or you can just manually decide when to flush (e.g. A chat session is closed in your App)
Why/Where should I use MemoBase?
Remember the users
By placing profiles into your AI (e.g. system prompt).
Demo
PROFILES = "\n".join([p.describe for p in u.profile()])
print(PROFILES)
# basic_info: name - Gus
# basic_info: age - 25
# ...
# interest: foods - Mexican cuisine
# psychological: goals - Build something that maybe useful
# ...
User analysis and tracking
Too much information is hidden in the conversations between users and AI, that's why you need a new data tracking method to record user preference and behavior.
Demo
PROFILES = u.profile()
def under_age_30(p):
return p.sub_topic == "age" and int(p.content) < 30
def love_cat(p):
return p.topic == "interest" and p.sub_topic == "pets" and "cat" in p.content
is_user_under_30 = (
len([p for p in profiles if under_age_30(p)]) > 0
)
is_user_love_cat = (
len([p for p in profiles if love_cat(p)]) > 0
)
...
Sell something to your customers.
Not everyone is looking for Grammarly, it's always nice to sell something your users might want.
Demo
def pick_an_ad(profiles):
work_titles = [p for p in profiles if p.topic=="work" and p.sub_topic=="title"]
if not len(work_titles):
return None
wt = work_titles[0].content
if wt == "Software Engineer":
return "Deep Learning Stuff"
elif wt == "some job":
return "some ads"
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file memobase-0.0.1.tar.gz
.
File metadata
- Download URL: memobase-0.0.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 786424bc047b428a4c53709db6a90260672ac5a5442cad489fdc944bf7912ef1 |
|
MD5 | 1c4b4247bca7ba0d539c265c32a00260 |
|
BLAKE2b-256 | 5007db2f4a0fe66d570d45ebad99ae72ecd2da4ab7232b3778db01713ef9fa98 |
File details
Details for the file memobase-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: memobase-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de2273084f887c7ceb900c540e85d368642ee85a2345d5ca82b1ff00fd93f04c |
|
MD5 | 8e6a2caeefba1fbd3553e250650acafd |
|
BLAKE2b-256 | cd7a6ca0a7838ede3651deff0e3f7a05bbad9939d015b22f35bfc75c477d1035 |