Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
with Redis as the backend data store.
"""

# Default Redis URL for local Redis Stack.
# Override via the REDIS_URL environment variable for remote or authenticated instances.
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")


async def example_manual_memory_store() -> None:
"""Basic example of using Redis history provider."""
Expand All @@ -24,7 +28,7 @@ async def example_manual_memory_store() -> None:
# Create Redis history provider
redis_provider = RedisHistoryProvider(
source_id="redis_basic_chat",
redis_url="redis://localhost:6379",
redis_url=REDIS_URL,
)

# Create agent with Redis history provider
Expand Down Expand Up @@ -62,7 +66,7 @@ async def example_user_session_management() -> None:
# Create Redis history provider for specific user session
redis_provider = RedisHistoryProvider(
source_id=f"redis_{user_id}",
redis_url="redis://localhost:6379",
redis_url=REDIS_URL,
max_messages=10, # Keep only last 10 messages
)

Expand Down Expand Up @@ -103,7 +107,7 @@ async def example_conversation_persistence() -> None:
print("--- Phase 1: Starting conversation ---")
redis_provider = RedisHistoryProvider(
source_id="redis_persistent_chat",
redis_url="redis://localhost:6379",
redis_url=REDIS_URL,
)

agent = OpenAIChatClient().as_agent(
Expand Down Expand Up @@ -152,7 +156,7 @@ async def example_session_serialization() -> None:

redis_provider = RedisHistoryProvider(
source_id="redis_serialization_chat",
redis_url="redis://localhost:6379",
redis_url=REDIS_URL,
)

agent = OpenAIChatClient().as_agent(
Expand Down Expand Up @@ -194,7 +198,7 @@ async def example_message_limits() -> None:
# Create provider with small message limit
redis_provider = RedisHistoryProvider(
source_id="redis_limited_chat",
redis_url="redis://localhost:6379",
redis_url=REDIS_URL,
max_messages=3, # Keep only 3 most recent messages
)

Expand Down Expand Up @@ -229,7 +233,7 @@ async def main() -> None:
print("Redis History Provider Examples")
print("=" * 50)
print("Prerequisites:")
print("- Redis server running on localhost:6379")
print("- Redis server running (set REDIS_URL env var or default localhost:6379)")
print("- OPENAI_API_KEY environment variable set")
print("=" * 50)

Expand Down