File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ for ADK agents using the community package.
1414### 1. Install Dependencies
1515
1616``` bash
17- pip install google-adk google-adk- community
17+ pip install google-adk- community[redis]
1818```
1919
2020### 2. Set Up OpenMemory Server
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ This sample demonstrates how to use Redis as a session storage backend for ADK a
1313### 1. Install Dependencies
1414
1515``` bash
16- pip install google-adk google-adk- community
16+ pip install google-adk- community[redis]
1717```
1818
1919### 2. Set Up Redis Server
@@ -109,15 +109,15 @@ async def get_health():
109109 return {" status" : " ok" }
110110
111111# Run the server
112- uvicorn.run(app, host = " 0.0.0.0" , port = 8080 )
112+ uvicorn.run(app, host = " 0.0.0.0" , port = int (os.environ.get( " PORT " , 8080 )) )
113113```
114114
115115### Direct RedisSessionService Usage
116116
117117You can also use ` RedisSessionService ` directly without FastAPI:
118118
119119``` python
120- from google.adk_community.sessions import RedisSessionService
120+ from google.adk_community.sessions.redis_session_service import RedisSessionService
121121from google.adk.runners import Runner
122122from google.adk.errors.already_exists_error import AlreadyExistsError
123123from google.adk.agents import Agent
Original file line number Diff line number Diff line change @@ -28,9 +28,7 @@ dependencies = [
2828 " google-genai>=1.21.1, <2.0.0" , # Google GenAI SDK
2929 " google-adk" , # Google ADK
3030 " httpx>=0.27.0, <1.0.0" , # For OpenMemory service
31- " redis >= 7.0.0" , # Redis for session storage
3231 # go/keep-sorted end
33- " orjson>=3.11.4" ,
3432]
3533dynamic = [" version" ]
3634
@@ -41,9 +39,13 @@ changelog = "https://github.com/google/adk-python-community/blob/main/CHANGELOG.
4139documentation = " https://google.github.io/adk-docs/"
4240
4341[project .optional-dependencies ]
42+ redis = [
43+ " redis>=7.0.0" , # Redis for session storage
44+ " orjson>=3.11.4" , # Fast JSON serialization for Redis
45+ ]
4446test = [
45- " pytest>=8.4.2" ,
46- " pytest-asyncio>=1.2.0" ,
47+ " pytest>=8.4.2" ,
48+ " pytest-asyncio>=1.2.0" ,
4749]
4850
4951
@@ -72,8 +74,8 @@ build-backend = "flit_core.buildapi"
7274
7375[dependency-groups ]
7476dev = [
75- " pytest>=8.4.2" ,
76- " pytest-asyncio>=1.2.0" ,
77+ " pytest>=8.4.2" ,
78+ " pytest-asyncio>=1.2.0" ,
7779]
7880
7981
Original file line number Diff line number Diff line change 2020import uuid
2121from typing import Any , Optional
2222
23- import orjson
24- import redis .asyncio as redis
25- from redis .crc import key_slot
2623from typing_extensions import override
2724
25+ try :
26+ import orjson
27+ import redis .asyncio as redis
28+ from redis .crc import key_slot
29+ except ImportError as exc :
30+ raise ImportError (
31+ "redis and orjson are required to use RedisSessionService. "
32+ "Install it with: pip install google-adk-community[redis]"
33+ ) from exc
34+
2835from google .adk .events .event import Event
2936from google .adk .sessions .base_session_service import (
3037 BaseSessionService ,
You can’t perform that action at this time.
0 commit comments