-
Notifications
You must be signed in to change notification settings - Fork 1
docs(ci): publish MkDocs site to GitHub Pages #12
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
Merged
Merged
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,63 @@ | ||
| name: Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "docs/**" | ||
| - "mkdocs.yml" | ||
| - "src/adk_redis/**" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/docs.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: pages | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| version: "latest" | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install 3.12 | ||
|
|
||
| - name: Install docs dependencies | ||
| # docs extra pulls in mkdocs-material, mkdocstrings, llmstxt, etc. | ||
| # The `all` extra is included so mkdocstrings can import the package | ||
| # surface (e.g., redisvl) when rendering API reference pages. | ||
| run: uv sync --extra docs --extra all | ||
|
|
||
| - name: Build site | ||
| # No --strict: pre-existing griffe warnings in tools/memory/* | ||
| # docstrings would block deploys. Tracked separately. | ||
| run: uv run mkdocs build | ||
|
|
||
| - name: Upload site | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: site | ||
|
|
||
| deploy: | ||
| if: github.ref == 'refs/heads/main' | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
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 |
|---|---|---|
| @@ -1,30 +1,53 @@ | ||
| # ADK Overview | ||
|
|
||
| The [Google Agent Development Kit (ADK)](https://github.com/google/adk-python) is a framework for building AI agents with Google's Gemini models. `adk-redis` provides Redis-backed implementations of ADK's service interfaces. | ||
| The [Google Agent Development Kit (ADK)](https://github.com/google/adk-python) is a framework for building AI agents with Google's Gemini models. `adk-redis` provides Redis-backed implementations of ADK's service interfaces so you can move from prototype to production without rewriting your agent. | ||
|
|
||
| ## ADK abstractions | ||
| ## Architecture | ||
|
|
||
| | Abstraction | What it does | Redis implementation | | ||
| |-------------|-------------|---------------------| | ||
| | **Agent** | The reasoning core: plans, calls tools, responds | No change (ADK provides this) | | ||
| | **Session** | Conversation state across turns | `RedisSessionService` | | ||
| | **Memory** | Persistent knowledge across sessions | `RedisMemoryService` | | ||
| | **Tool** | Functions the agent can call | RedisVL search tools | | ||
| ```mermaid | ||
| flowchart TD | ||
| subgraph Agent [Your ADK Agent] | ||
| SS[Session Service<br/>working memory] | ||
| MS[Memory Service<br/>long-term] | ||
| ST[Search Tools<br/>vector · hybrid · SQL] | ||
| SC[Semantic Cache<br/>before/after callbacks] | ||
| end | ||
|
|
||
| ## Where Redis fits | ||
| SS & MS -->|REST / MCP| AMS | ||
| ST -->|RedisVL / MCP| R | ||
| SC -->|RedisVL / LangCache| R | ||
|
|
||
| Redis replaces the default in-memory implementations with durable, scalable alternatives: | ||
| subgraph AMS [Agent Memory Server] | ||
| WM[Working Memory API] | ||
| LTM[Long-Term Memory API] | ||
| end | ||
|
|
||
| - **Sessions** are stored as Redis JSON documents with optional TTL | ||
| - **Memory** is proxied to the Redis Agent Memory Server for two-tier storage | ||
| - **Search tools** use RedisVL for vector similarity search | ||
| - **Caching** uses Redis for semantic LLM response caching | ||
| AMS --> R | ||
|
|
||
| ## When to use adk-redis | ||
| subgraph R [Redis 8.4+] | ||
| JSON[(JSON storage)] | ||
| VEC[(Vector index)] | ||
| FTS[(Full-text index)] | ||
| end | ||
| ``` | ||
|
|
||
| Use `adk-redis` when you are building a Google ADK agent and need: | ||
| ## ADK Interfaces | ||
|
|
||
| - Session persistence across process restarts | ||
| - Long-term memory that survives beyond a single conversation | ||
| - Vector search over your own documents | ||
| - Production deployment with Redis as the data layer | ||
| `adk-redis` implements four ADK extension points. Each one maps to a concept page with full details. | ||
|
|
||
| | ADK Interface | `adk-redis` implementation | Concept page | | ||
| |---------------|---------------------------|-------------| | ||
| | `BaseSessionService` | `RedisWorkingMemorySessionService` | [Sessions + Memory Services](sessions.md) | | ||
| | `BaseMemoryService` | `RedisLongTermMemoryService` | [Sessions + Memory Services](sessions.md) | | ||
| | `BaseTool` | Search tools (`RedisVectorSearchTool`, `RedisHybridSearchTool`, etc.) and memory tools (`SearchMemoryTool`, `CreateMemoryTool`, etc.) | [Search Tools](search.md), [Memory MCP + Tools](memory.md) | | ||
| | Model callbacks | `LLMResponseCache` with `RedisVLCacheProvider` or `LangCacheProvider` | [Semantic Caching](caching.md) | | ||
|
|
||
| ## Running Your Agent | ||
|
|
||
| ADK provides several ways to run and test agents: | ||
|
|
||
| - **`adk web`**: browser-based UI for interactive development and debugging. | ||
| - **`adk run`**: terminal-based interaction. | ||
| - **`adk api_server`**: RESTful API for production deployment. | ||
|
|
||
| See the [ADK runtime documentation](https://google.github.io/adk-docs/runtime/) for details. |
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,144 @@ | ||
| # Semantic Caching | ||
|
|
||
| `adk-redis` provides semantic caching that skips LLM calls when a user sends a prompt that is similar (or identical) to one already answered. This reduces latency and cost without changing agent behavior. | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| | Feature | Details | | ||
| |---------|---------| | ||
| | **What it caches** | LLM responses keyed by prompt similarity | | ||
| | **Similarity** | Vector distance between prompt embeddings | | ||
| | **Providers** | `RedisVLCacheProvider` (self-hosted) or `LangCacheProvider` (managed) | | ||
| | **TTL** | Configurable per-entry expiration | | ||
| | **Integration** | ADK `before_model_callback` / `after_model_callback` hooks | | ||
|
|
||
| ## How It Works | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| U([User prompt]) --> BC[before_model_callback<br/>embed prompt, search cache] | ||
| BC --> D{Cache hit?} | ||
| D -->|Yes| CR([Return cached response<br/>no LLM call]) | ||
| D -->|No| LLM[Call LLM] | ||
| LLM --> AC[after_model_callback<br/>store response in cache] | ||
| AC --> R([Return LLM response]) | ||
|
|
||
| subgraph Cache [Redis Cache] | ||
| SE[(Semantic index<br/>prompt embeddings)] | ||
| end | ||
|
|
||
| BC <--> Cache | ||
| AC --> Cache | ||
| ``` | ||
|
|
||
| 1. Before the LLM is called, `LLMResponseCache` embeds the prompt and searches for a semantically similar entry in the cache. | ||
| 2. If the distance is below the configured threshold, the cached response is returned immediately (no LLM call). | ||
| 3. If no match is found, the LLM runs normally and the response is stored in the cache for future hits. | ||
|
|
||
| ## Two Provider Options | ||
|
|
||
| ### Self-Hosted (RedisVL) | ||
|
|
||
| Use `RedisVLCacheProvider` when you run your own Redis instance and want full control over the vectorizer and cache index. | ||
|
|
||
| ```python | ||
| from redisvl.utils.vectorize import HFTextVectorizer | ||
|
|
||
| from adk_redis.cache import ( | ||
| LLMResponseCache, | ||
| LLMResponseCacheConfig, | ||
| RedisVLCacheProvider, | ||
| RedisVLCacheProviderConfig, | ||
| ) | ||
|
|
||
| vectorizer = HFTextVectorizer(model="redis/langcache-embed-v1") | ||
|
|
||
| provider = RedisVLCacheProvider( | ||
| config=RedisVLCacheProviderConfig( | ||
| redis_url="redis://localhost:6379", | ||
| name="my_cache", | ||
| ttl=3600, | ||
| distance_threshold=0.1, | ||
| ), | ||
| vectorizer=vectorizer, | ||
| ) | ||
| ``` | ||
|
|
||
| **Requirements**: `pip install 'adk-redis[search]'` and a running Redis instance. | ||
|
|
||
| ### Managed (LangCache) | ||
|
|
||
| Use `LangCacheProvider` with [Redis LangCache](https://redis.io/langcache) for a fully managed service. No local vectorizer needed; embeddings are handled server-side. | ||
|
|
||
| ```python | ||
| from adk_redis.cache import ( | ||
| LLMResponseCache, | ||
| LLMResponseCacheConfig, | ||
| LangCacheProvider, | ||
| LangCacheProviderConfig, | ||
| ) | ||
|
|
||
| provider = LangCacheProvider( | ||
| config=LangCacheProviderConfig( | ||
| cache_id="your-cache-id", | ||
| api_key="your-api-key", | ||
| server_url="https://aws-us-east-1.langcache.redis.io", | ||
| ttl=3600, | ||
| ), | ||
| ) | ||
| ``` | ||
|
|
||
| **Requirements**: `pip install 'adk-redis[langcache]'` and a LangCache account. | ||
|
|
||
| ## Wiring Into an Agent | ||
|
|
||
| Both providers use the same `LLMResponseCache` wrapper, which produces ADK-compatible callbacks: | ||
|
|
||
| ```python | ||
| from adk_redis.cache import create_llm_cache_callbacks | ||
|
|
||
| llm_cache = LLMResponseCache( | ||
| provider=provider, | ||
| config=LLMResponseCacheConfig( | ||
| first_message_only=True, # only cache the first user message | ||
| include_app_name=True, # scope cache keys by app | ||
| include_user_id=True, # scope cache keys by user | ||
| ), | ||
| ) | ||
|
|
||
| before_cb, after_cb = create_llm_cache_callbacks(llm_cache) | ||
|
|
||
| agent = Agent( | ||
| model="gemini-2.0-flash", | ||
| name="my_agent", | ||
| before_model_callback=before_cb, | ||
| after_model_callback=after_cb, | ||
| ) | ||
| ``` | ||
|
|
||
| ## When to Use Which | ||
|
|
||
| | Provider | Use when | | ||
| |----------|----------| | ||
| | **RedisVL** | You already run Redis, want local embeddings, need full control over cache index schema. | | ||
| | **LangCache** | You want a managed service with no infrastructure, server-side embeddings, and built-in analytics. | | ||
|
|
||
| ## Configuration Options | ||
|
|
||
| | Option | Provider | Default | Description | | ||
| |--------|----------|---------|-------------| | ||
| | `distance_threshold` | Both | `0.1` | Max vector distance for a cache hit (lower = stricter) | | ||
| | `ttl` | Both | `None` | Time-to-live in seconds for cache entries | | ||
| | `name` | RedisVL | `llmcache` | Redis index name for the cache | | ||
| | `redis_url` | RedisVL | `redis://localhost:6379` | Redis connection string | | ||
| | `cache_id` | LangCache | Required | LangCache instance identifier | | ||
| | `api_key` | LangCache | Required | LangCache API key | | ||
| | `use_exact_search` | LangCache | `True` | Enable exact (hash) matching in addition to semantic | | ||
| | `use_semantic_search` | LangCache | `True` | Enable semantic (vector) matching | | ||
|
|
||
| ## Next Steps | ||
|
|
||
| - [Semantic cache example](https://github.com/redis-developer/adk-redis/tree/main/examples/semantic_cache) for a runnable self-hosted demo. | ||
| - [LangCache example](https://github.com/redis-developer/adk-redis/tree/main/examples/langcache_cache) for a runnable managed demo. | ||
| - [Sessions + Memory services](sessions.md) and [Sessions + Memory MCP](memory.md) for the other Redis-backed features. | ||
| - [ADK runtime options](https://google.github.io/adk-docs/runtime/) for `adk web`, `adk run`, and `adk api_server`. |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing
workflow_dispatchwithout a branch guard means anyone with permission to run Actions can publish docs from any branch, so unmerged or experimental content can overwrite the public GitHub Pages site when thedeployjob runs. This is a production-facing risk for the docs site unless thegithub-pagesenvironment is separately configured with branch protection, so the workflow should enforcemainin YAML (for example via a deploy jobif) instead of relying on repository settings.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 6c6dd0c: added
if: github.ref == 'refs/heads/main'to the deploy job so workflow_dispatch from non-main branches cannot overwrite the live site.