-
Notifications
You must be signed in to change notification settings - Fork 30
feat: added s3 artifact #36
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from . import agent | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Example agent demonstrating S3 artifact storage. | ||
|
|
||
| This example shows how to configure an ADK agent to use Amazon S3 for | ||
| artifact storage using the community S3ArtifactService. | ||
|
|
||
| Before running: | ||
| 1. Install: pip install google-adk-community boto3 | ||
| 2. Set AWS credentials (see README.md) | ||
| 3. Create S3 bucket | ||
| 4. Update bucket name below or set ADK_S3_BUCKET environment variable | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| from google.adk import Agent | ||
| from google.adk.apps import App | ||
| from google.adk_community.artifacts import S3ArtifactService | ||
|
|
||
| # Get bucket name from environment or use default | ||
| BUCKET_NAME = os.getenv("ADK_S3_BUCKET", "my-adk-artifacts") | ||
| AWS_REGION = os.getenv("AWS_REGION", "us-east-1") | ||
|
|
||
| # Initialize S3 artifact service | ||
| artifact_service = S3ArtifactService( | ||
| bucket_name=BUCKET_NAME, | ||
| region_name=AWS_REGION, | ||
| ) | ||
|
|
||
| # Define the agent | ||
| root_agent = Agent( | ||
| name="s3_artifact_agent", | ||
| model="gemini-2.0-flash", | ||
| instruction="""You are a helpful assistant that can save and retrieve files. | ||
|
|
||
| When users ask you to save information, use the save_artifact tool to store | ||
| it in S3. When they ask for previously saved information, use the load_artifact | ||
| tool to retrieve it. | ||
|
|
||
| Examples: | ||
| - "Save this report to a file called quarterly_report.pdf" | ||
| - "Load the file called quarterly_report.pdf" | ||
| - "List all my saved files" | ||
| """, | ||
| description="An assistant that demonstrates S3 artifact storage", | ||
| ) | ||
|
|
||
| # Create app with S3 artifact service | ||
| app = App( | ||
| name="s3_artifact_example", | ||
| root_agent=root_agent, | ||
| artifact_service=artifact_service, | ||
| ) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,12 +25,12 @@ classifiers = [ # List of https://pypi.org/classifiers/ | |
| ] | ||
| dependencies = [ | ||
| # go/keep-sorted start | ||
| "google-genai>=1.21.1, <2.0.0", # Google GenAI SDK | ||
| "google-adk", # Google ADK | ||
| "google-genai>=1.21.1, <2.0.0", # Google GenAI SDK | ||
| "httpx>=0.27.0, <1.0.0", # For OpenMemory service | ||
| "orjson>=3.11.3", | ||
| "redis>=5.0.0, <6.0.0", # Redis for session storage | ||
| # go/keep-sorted end | ||
| "orjson>=3.11.3", | ||
| ] | ||
|
Comment on lines
26
to
34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You could create a new optional dependency group, for example: [project.optional-dependencies]
s3 = ["boto3>=1.28.0"]
test = [
"pytest>=8.4.2",
"pytest-asyncio>=1.2.0",
]Users could then install S3 support via
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| dynamic = ["version"] | ||
|
|
||
|
|
@@ -41,6 +41,9 @@ changelog = "https://github.com/google/adk-python-community/blob/main/CHANGELOG. | |
| documentation = "https://google.github.io/adk-docs/" | ||
|
|
||
| [project.optional-dependencies] | ||
| s3 = [ | ||
| "boto3>=1.28.0", # For S3ArtifactService | ||
| ] | ||
| test = [ | ||
| "pytest>=8.4.2", | ||
| "pytest-asyncio>=1.2.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Community Artifact Services | ||
|
|
||
| This module contains community-contributed artifact service implementations for ADK. | ||
|
|
||
| ## Available Services | ||
|
|
||
| ### S3ArtifactService | ||
|
|
||
| Production-ready artifact storage using Amazon S3. | ||
|
|
||
| **Installation:** | ||
| ```bash | ||
| pip install google-adk-community boto3 | ||
| ``` | ||
|
|
||
| **Usage:** | ||
| ```python | ||
| from google.adk_community.artifacts import S3ArtifactService | ||
|
|
||
| artifact_service = S3ArtifactService( | ||
| bucket_name="my-adk-artifacts", | ||
| region_name="us-east-1" | ||
| ) | ||
| ``` | ||
|
|
||
| **Features:** | ||
| - Session-scoped and user-scoped artifacts | ||
| - Automatic version management | ||
| - Custom metadata support | ||
| - URL encoding for special characters | ||
| - Works with S3-compatible services (MinIO, DigitalOcean Spaces, etc.) | ||
|
|
||
| **See Also:** | ||
| - [S3ArtifactService Implementation](./s3_artifact_service.py) | ||
| - [Example Agent](../../../contributing/samples/s3_artifact_example/) | ||
| - [Tests](../../../tests/unittests/artifacts/test_s3_artifact_service.py) | ||
|
|
||
| ## Contributing | ||
|
|
||
| Want to add a new artifact service? See our [contribution guide](../../../CONTRIBUTING.md). | ||
|
|
||
| Examples of artifact services to contribute: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe remove this? |
||
| - Azure Blob Storage | ||
| - Google Drive | ||
| - Dropbox | ||
| - MinIO (dedicated implementation) | ||
| - Any S3-compatible service | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from .s3_artifact_service import S3ArtifactService | ||
|
|
||
| __all__ = [ | ||
| 'S3ArtifactService', | ||
| ] | ||
|
|
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.
In theory we can use any agent with any service implementation, so we don't need a sample for that.
A README would be sufficient
Uh oh!
There was an error while loading. Please reload this page.
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.
It does no harm but only gives users convenience to try out, right? It saves the time from copying code from README.
There is precedence. https://github.com/google/adk-python-community/tree/main/contributing/samples/open_memory/open_memory_agent