Where the note is kept
Note: Chroma, mem0, and MongoDB are on this page so you can see the setting. They have no Try it button.
The script and SQLite
The note can stay in the script, or it can be kept in a database. The search is the same idea either way.
Script prints the boat sentence from the script. SQLite prints the same sentence from a database, in lower case. user_id is whose notes they are.
Example
from praisonaiagents.knowledge import KeywordIndex, Knowledge
lines = [
"Apples grow on trees in the orchard.",
"The secret colour of the boat is blue.",
"Tickets for the ferry cost four pounds.",
]
index = KeywordIndex()
index.add_documents(lines)
kb = Knowledge(config={"vector_store": {"provider": "sqlite"}})
kb.add("The secret colour of the boat is blue.", user_id="learner")
print("Script")
print(index.query("What colour is the boat?", top_k=1)[0]["text"].strip())
print("SQLite")
print(kb.search("colour", user_id="learner").results[0].text)Example explained
- KeywordIndex — The note lives in this run. Nothing is written to a database.
- sqlite — A database that needs no extra install. provider names it.
Chroma
Chroma is a local database for the note. Install chromadb on your computer, then set provider to chroma. This site does not have that package, so there is no Try it button.
Example
from praisonai import Knowledge
kb = Knowledge(config={
"vector_store": {
"provider": "chroma",
"config": {"path": "./.praison/knowledge"},
}
})mem0
mem0 is the store used when you do not name one. It needs the mem0 package, and a user id when you add a note. There is no Try it button.
Example
from praisonai import Knowledge
kb = Knowledge(config={"vector_store": {"provider": "mem0"}})MongoDB
MongoDB keeps the note in a database you already run. Replace the connection string with your own. This site does not start a database, so there is no Try it button.
Example
from praisonai import Knowledge
kb = Knowledge(config={
"vector_store": {
"provider": "mongodb",
"config": {
"connection_string": "mongodb://localhost:27017",
"database": "praison",
"collection": "notes",
},
}
})Reference: documentation