-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore memory #1975
base: main
Are you sure you want to change the base?
Firestore memory #1975
Conversation
Can you please add a corresponding cookbook and add the steps to setup firestore and get the required env variables at the top of the cookbook? |
Hi @manthanguptaa I've added the cookbook |
def __init__( | ||
self, | ||
collection_name: str = "memory", | ||
db_name: Optional[str] = "(default)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db_name: Optional[str] = "(default)", | |
db_name: Optional[str] = "agno", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [default] 'database' gets you free-tier use which in google cloud is pretty generous.
https://cloud.google.com/firestore/pricing Note: Only the (default) database qualifies for the free quota.
def create(self) -> None: | ||
"""Create the collection index | ||
Avoiding index creation by using a user/memory model | ||
|
||
Returns: | ||
None | ||
""" | ||
try: | ||
logger.info(f"Mocked call to create index for '{self.collection_name}'") | ||
except Exception as e: | ||
logger.error(f"Error creating collection: {e}") | ||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this doesn’t seem to be doing anything. Was that intentional? Just wanted to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, indexes are odd in firestore. Fields are indexed automagically so best to use a model that leverages that. To create an index is an async job where they mention the need for an index in a log file that points you back to the google cloud console to create it. You can do it in code, but it doesn't complete in time to use for a session. This approach seemed to solve for being able to use firestore immediately with as little setup as possible.
""" | ||
This recipe shows how to store agent sessions in a MongoDB database. | ||
Steps: | ||
1. Run: `pip install openai google-cloud-firestore agno` to install dependencies | ||
2. Make sure your gcloud project is set up and you have the necessary permissions to access Firestore | ||
3. Run: `python cookbook/memory/09_persistent_memory_firestore.py` to run the agent | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please also mention steps on how to set up gcloud locally and set up the project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be ok to reference official google docs like https://cloud.google.com/firestore/docs/create-database-server-client-library ?
arrange imports Co-authored-by: Manthan Gupta <[email protected]>
Description
Adds firestore memory to solve #1974
Fixes # (issue)
[Feature Request] firestore agent memory #1974
Type of change
Checklist
./scripts/format.sh
and./scripts/validate.sh
to ensure code is formatted and linted.Additional Notes
firestore works best without having to create indexes. The data model collection_name/user_id/memories allows for selecting all memories and using an orderby without having to create a composite index which is a bit tricky in firestore (requires async calls, no callback when completed, not ready immediately).