Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions packages/adk-sdk-python/src/supermemory_adk/__init__.py
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",
]
Comment on lines +82 to +84

This comment was marked as outdated.

72 changes: 72 additions & 0 deletions packages/adk-sdk-python/src/supermemory_adk/exceptions.py
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
Loading