-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Supermemory ADK SDK #755
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
Open
sreedharsreeram
wants to merge
3
commits into
main
Choose a base branch
from
ADK-SDK
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+653
−0
Open
Supermemory ADK SDK #755
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| """Supermemory ADK - Memory-enhanced AI agents with Google Agent Development Kit. | ||
|
|
||
| This package provides seamless integration between Supermemory and Google's Agent | ||
| Development Kit (ADK), enabling persistent memory and context enhancement for AI agents. | ||
|
|
||
| Example: | ||
| ```python | ||
| from google.adk.agents import Agent | ||
| from supermemory_adk import supermemory_tools | ||
|
|
||
| # Create agent with Supermemory tools | ||
| root_agent = Agent( | ||
| model='gemini-2.5-flash', | ||
| tools=supermemory_tools( | ||
| api_key="your-api-key", | ||
| container_tags=["user-123"] | ||
| ), | ||
| instruction="Use memory tools when needed" | ||
| ) | ||
| ``` | ||
|
|
||
| Example (Wrapper Mode): | ||
| ```python | ||
| from google.adk.agents import Agent | ||
| from supermemory_adk import with_supermemory, MemoryMode | ||
|
|
||
| # Create base agent | ||
| base_agent = Agent( | ||
| model='gemini-2.5-flash', | ||
| instruction="You are a helpful assistant" | ||
| ) | ||
|
|
||
| # Wrap with automatic memory injection | ||
| root_agent = with_supermemory( | ||
| base_agent, | ||
| container_tag="user-123", | ||
| mode=MemoryMode.FULL, | ||
| auto_save=True | ||
| ) | ||
| ``` | ||
| """ | ||
|
|
||
| from .exceptions import ( | ||
| SupermemoryADKError, | ||
| SupermemoryAPIError, | ||
| SupermemoryConfigurationError, | ||
| SupermemoryMemoryOperationError, | ||
| SupermemoryNetworkError, | ||
| SupermemoryTimeoutError, | ||
| SupermemoryToolError, | ||
| ) | ||
| from .tools import supermemory_tools | ||
| from .utils import ( | ||
| DeduplicatedMemories, | ||
| Logger, | ||
| create_logger, | ||
| deduplicate_memories, | ||
| format_memories_to_markdown, | ||
| format_memories_to_text, | ||
| ) | ||
|
|
||
| __version__ = "0.1.0" | ||
|
|
||
| __all__ = [ | ||
| # Version | ||
| "__version__", | ||
| # Exceptions | ||
| "SupermemoryADKError", | ||
| "SupermemoryConfigurationError", | ||
| "SupermemoryAPIError", | ||
| "SupermemoryMemoryOperationError", | ||
| "SupermemoryNetworkError", | ||
| "SupermemoryTimeoutError", | ||
| "SupermemoryToolError", | ||
| # Utils | ||
| "Logger", | ||
| "create_logger", | ||
| "DeduplicatedMemories", | ||
| "deduplicate_memories", | ||
| "format_memories_to_markdown", | ||
| "format_memories_to_text", | ||
| # Tools | ||
| "supermemory_tools", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Custom exceptions for Supermemory ADK integration.""" | ||
|
|
||
| from typing import Optional | ||
|
|
||
|
|
||
| class SupermemoryADKError(Exception): | ||
| """Base exception for all Supermemory ADK errors.""" | ||
|
|
||
| def __init__(self, message: str, original_error: Optional[Exception] = None): | ||
| super().__init__(message) | ||
| self.message = message | ||
| self.original_error = original_error | ||
|
|
||
| def __str__(self) -> str: | ||
| if self.original_error: | ||
| return f"{self.message}: {self.original_error}" | ||
| return self.message | ||
|
|
||
|
|
||
| class SupermemoryConfigurationError(SupermemoryADKError): | ||
| """Raised when there are configuration issues (e.g., missing API key, invalid params).""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class SupermemoryAPIError(SupermemoryADKError): | ||
| """Raised when Supermemory API requests fail.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| message: str, | ||
| status_code: Optional[int] = None, | ||
| response_text: Optional[str] = None, | ||
| original_error: Optional[Exception] = None, | ||
| ): | ||
| super().__init__(message, original_error) | ||
| self.status_code = status_code | ||
| self.response_text = response_text | ||
|
|
||
| def __str__(self) -> str: | ||
| parts = [self.message] | ||
| if self.status_code: | ||
| parts.append(f"Status: {self.status_code}") | ||
| if self.response_text: | ||
| parts.append(f"Response: {self.response_text}") | ||
| if self.original_error: | ||
| parts.append(f"Cause: {self.original_error}") | ||
| return " | ".join(parts) | ||
|
|
||
|
|
||
| class SupermemoryMemoryOperationError(SupermemoryADKError): | ||
| """Raised when memory operations (search, add) fail.""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class SupermemoryTimeoutError(SupermemoryADKError): | ||
| """Raised when operations timeout.""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class SupermemoryNetworkError(SupermemoryADKError): | ||
| """Raised when network operations fail.""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class SupermemoryToolError(SupermemoryADKError): | ||
| """Raised when ADK tool execution fails.""" | ||
|
|
||
| pass |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.