-
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 agent storage class #1978
base: main
Are you sure you want to change the base?
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? |
Sure! Should I use this mongo storage as an example? |
Sure! Please go ahead |
OK, I've added cookbook/examples for both PRs @manthanguptaa
…On Mon, Feb 3, 2025, 10:08 PM Manthan Gupta ***@***.***> wrote:
Sure! Please go ahead
—
Reply to this email directly, view it on GitHub
<#1978 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEKM2JKZKKRHYITHENNHAD2OBKMNAVCNFSM6AAAAABWJZFFF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZSHE3DGNZRGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
""" | ||
This recipe shows how to store agent sessions in a Firestore 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/storage/firestore_storage.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 add steps to set up gcloud?
from datetime import datetime, timezone | ||
from typing import List, Optional | ||
from uuid import UUID | ||
|
||
try: | ||
from google.cloud import firestore | ||
from google.cloud.firestore import Client | ||
from google.cloud.firestore import CollectionReference | ||
from google.cloud.firestore_v1.base_query import FieldFilter, BaseQuery | ||
|
||
except ImportError: | ||
raise ImportError( | ||
"`firestore` not installed. Please install it with `pip install google-cloud-firestore`" | ||
) | ||
|
||
from agno.storage.agent.base import AgentStorage | ||
from agno.storage.agent.session import AgentSession | ||
from agno.utils.log import logger |
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.
from datetime import datetime, timezone | |
from typing import List, Optional | |
from uuid import UUID | |
try: | |
from google.cloud import firestore | |
from google.cloud.firestore import Client | |
from google.cloud.firestore import CollectionReference | |
from google.cloud.firestore_v1.base_query import FieldFilter, BaseQuery | |
except ImportError: | |
raise ImportError( | |
"`firestore` not installed. Please install it with `pip install google-cloud-firestore`" | |
) | |
from agno.storage.agent.base import AgentStorage | |
from agno.storage.agent.session import AgentSession | |
from agno.utils.log import logger | |
from datetime import datetime, timezone | |
from typing import List, Optional | |
from uuid import UUID | |
from agno.storage.agent.base import AgentStorage | |
from agno.storage.agent.session import AgentSession | |
from agno.utils.log import logger | |
try: | |
from google.cloud import firestore | |
from google.cloud.firestore import Client | |
from google.cloud.firestore import CollectionReference | |
from google.cloud.firestore_v1.base_query import FieldFilter, BaseQuery | |
except ImportError: | |
raise ImportError( | |
"`firestore` not installed. Please install it with `pip install google-cloud-firestore`" | |
) | |
def __init__( | ||
self, | ||
collection_name: str, | ||
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", |
def create(self) -> None: | ||
"""Create necessary indexes for the collection""" | ||
try: | ||
logger.info( | ||
f"Unnecessary call to create index for '{self.collection_name}'" | ||
) | ||
except Exception as e: | ||
logger.error(f"Error creating indexes for 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.
This seems to be doing nothing at the moment. Is this intentional?
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.
Please add function signature in all the docstrings
Description
Fixes # (issue)
#1977
Type of change
Please check the options that are relevant:
Checklist
./scripts/format.sh
and./scripts/validate.sh
to ensure code is formatted and linted.