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
18 changes: 11 additions & 7 deletions libs/langgraph-checkpoint-aws/langgraph_checkpoint_aws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
LangGraph Checkpoint AWS - A LangChain checkpointer implementation using
Bedrock Session Management Service.
Bedrock Session Management Service and Valkey.
"""

from importlib.metadata import version
Expand All @@ -12,38 +12,42 @@
AgentCoreMemoryStore,
)

# Conditional imports for checkpoint functionality
# Conditional imports for Valkey functionality
try:
from langgraph_checkpoint_aws.cache import ValkeyCache
from langgraph_checkpoint_aws.checkpoint import AsyncValkeySaver, ValkeySaver

valkey_available = True
except ImportError:
# If checkpoint dependencies are not available, create placeholder classes
from typing import Any

def _missing_checkpoint_dependencies_error(*args: Any, **kwargs: Any) -> Any:
def _missing_dependencies_error(*args: Any, **kwargs: Any) -> Any:
raise ImportError(
"Valkey checkpoint functionality requires optional dependencies. "
"Valkey functionality requires optional dependencies. "
"Install them with: pip install 'langgraph-checkpoint-aws[valkey]'"
)

# Create placeholder classes that raise helpful errors
AsyncValkeySaver: type[Any] = _missing_checkpoint_dependencies_error # type: ignore[assignment,no-redef]
ValkeySaver: type[Any] = _missing_checkpoint_dependencies_error # type: ignore[assignment,no-redef]
AsyncValkeySaver: type[Any] = _missing_dependencies_error # type: ignore[assignment,no-redef]
ValkeyCache: type[Any] = _missing_dependencies_error # type: ignore[assignment,no-redef]
ValkeySaver: type[Any] = _missing_dependencies_error # type: ignore[assignment,no-redef]
valkey_available = False

try:
__version__ = version("langgraph-checkpoint-aws")
except Exception:
# Fallback version if package is not installed
__version__ = "1.0.0a1"
__version__ = "1.0.0"
SDK_USER_AGENT = f"LangGraphCheckpointAWS#{__version__}"

# Expose the saver class at the package level
__all__ = [
"AgentCoreMemorySaver",
"AgentCoreMemoryStore",
"AsyncValkeySaver",
"ValkeyCache",
"ValkeySaver",
"SDK_USER_AGENT",
"valkey_available",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Cache implementations for LangGraph checkpoint AWS."""

from typing import Any

# Store the import error for later use
_import_error: ImportError | None = None

# Conditional imports for optional dependencies
try:
from langgraph_checkpoint_aws.cache.valkey import ValkeyCache

__all__ = ["ValkeyCache"]
except ImportError as e:
# Store the error for later use
_import_error = e

# If dependencies are not available, provide helpful error message
def _missing_dependencies_error(*args: Any, **kwargs: Any) -> Any:
raise ImportError(
"Valkey cache functionality requires optional dependencies. "
"Install them with: pip install 'langgraph-checkpoint-aws[valkey]'"
) from _import_error

# Create placeholder classes that raise helpful errors
# Use type: ignore to suppress mypy errors for this intentional pattern
ValkeyCache: type[Any] = _missing_dependencies_error # type: ignore[assignment,no-redef]

__all__ = ["ValkeyCache"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Valkey cache implementation for LangGraph checkpoint AWS."""

from typing import Any

# Store the import error for later use
_import_error: ImportError | None = None

# Conditional imports for optional dependencies
try:
from .cache import ValkeyCache

__all__ = ["ValkeyCache"]
except ImportError as e:
# Store the error for later use
_import_error = e

# If dependencies are not available, provide helpful error message
def _missing_dependencies_error(*args: Any, **kwargs: Any) -> Any:
raise ImportError(
"Valkey functionality requires optional dependencies. "
"Install them with: pip install 'langgraph-checkpoint-aws[valkey]'"
) from _import_error

# Create placeholder classes that raise helpful errors
# Use type: ignore to suppress mypy errors for this intentional pattern
ValkeyCache: type[Any] = _missing_dependencies_error # type: ignore[assignment,no-redef]

__all__ = ["ValkeyCache"]
Loading