Skip to content
Merged
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
22 changes: 22 additions & 0 deletions _snippets/db-valkey-params.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
| Parameter | Type | Default | Description |
| ----------------- | -------------------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------- |
| `id` | `Optional[str]` | - | The ID of the database instance. UUID by default. |
| `valkey_client` | `Optional[Union[GlideClient, GlideClusterClient]]` | - | Pre-configured Valkey GLIDE client. If not provided a new client will be created. |
| `host` | `str` | `"localhost"` | Valkey server host. |
| `port` | `int` | `6379` | Valkey server port. |
| `database_id` | `Optional[int]` | - | Logical database index (e.g. 0-15). |
| `username` | `Optional[str]` | - | Username for authentication. |
| `password` | `Optional[str]` | - | Password for authentication. |
| `use_tls` | `bool` | `False` | Enable TLS encryption. |
| `request_timeout` | `Optional[int]` | - | Milliseconds to wait for a request to complete. If unset, the GLIDE client default (250 ms) applies. |
| `db_prefix` | `str` | `"agno"` | Prefix for all Valkey keys. |
| `client_name` | `str` | `"agno_db_client"` | Connection name, visible in `CLIENT LIST`. |
| `expire` | `Optional[int]` | - | TTL for Valkey keys in seconds. |
| `session_table` | `Optional[str]` | - | Name of the table to store sessions. |
| `memory_table` | `Optional[str]` | - | Name of the table to store memories. |
| `metrics_table` | `Optional[str]` | - | Name of the table to store metrics. |
| `eval_table` | `Optional[str]` | - | Name of the table to store evaluation runs. |
| `knowledge_table` | `Optional[str]` | - | Name of the table to store knowledge documents. |
| `traces_table` | `Optional[str]` | - | Name of the table to store traces. |
| `spans_table` | `Optional[str]` | - | Name of the table to store spans. |
| `learnings_table` | `Optional[str]` | - | Name of the table to store learnings. |
20 changes: 20 additions & 0 deletions _snippets/vectordb_valkey_params.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| `index_name` | `str` | Required | Name of the Valkey search index to store vector data |
| `host` | `str` | `"localhost"` | Valkey server host |
| `port` | `int` | `6379` | Valkey server port |
| `username` | `Optional[str]` | `None` | Username for authentication |
| `password` | `Optional[str]` | `None` | Password for authentication |
| `use_tls` | `bool` | `False` | Enable TLS encryption |
| `database_id` | `Optional[int]` | `None` | Logical database index (e.g. 0-15) |
| `request_timeout` | `Optional[int]` | `None` | Milliseconds to wait for a request to complete. If unset, the GLIDE client default (250 ms) applies |
| `client_name` | `str` | `"agno_vectordb_client"` | Connection name, visible in `CLIENT LIST` |
| `glide_client` | `Optional[GlideClient]` | `None` | Pre-configured Valkey GLIDE client instance |
| `embedder` | `Optional[Embedder]` | `None` | Embedder instance to generate embeddings (defaults to `OpenAIEmbedder()` when unset) |
| `search_type` | `SearchType` | `SearchType.vector` | Type of search to perform (vector, keyword) |
| `distance` | `Distance` | `Distance.cosine` | Distance metric (cosine, l2, max_inner_product) |
| `vector_algorithm` | `str` | `"HNSW"` | Vector index algorithm (HNSW or FLAT) |
| `reranker` | `Optional[Reranker]` | `None` | Reranker for search results |
| `id` | `Optional[str]` | `None` | Optional custom ID. If not provided, an ID will be generated |
| `name` | `Optional[str]` | `None` | Optional name for the vector database |
| `description` | `Optional[str]` | `None` | Optional description for the vector database |
8 changes: 8 additions & 0 deletions database/providers/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ Agno supports the following database providers organized by category:
>
Redis in-memory data store integration.
</Card>
<Card
title="Valkey"
icon="database"
iconType="duotone"
href="/database/providers/valkey/overview"
>
Valkey in-memory data store integration.
</Card>
<Card
title="DynamoDB"
icon="aws"
Expand Down
38 changes: 38 additions & 0 deletions database/providers/valkey/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Valkey
description: Use Valkey for agent session storage and persistence.
sidebarTitle: Overview
---

Agno supports using [Valkey](https://valkey.io/) as a database with the `ValkeyDb` class.

## Usage

### Run Valkey

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **Valkey** on port **6379** using:

```bash
docker run -d \
--name my-valkey \
-p 6379:6379 \
valkey/valkey
```

```python valkey_for_agent.py
from agno.agent import Agent
from agno.db.valkey import ValkeyDb

# Initialize Valkey db
db = ValkeyDb(
host="localhost",
port=6379,
)

# Create agent with Valkey db
agent = Agent(db=db)
```

## Params

<Snippet file="db-valkey-params.mdx" />
57 changes: 57 additions & 0 deletions database/providers/valkey/usage/valkey-for-agent.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Valkey for Agent
sidebarTitle: Agent
---

Agno supports using Valkey as a storage backend for Agents using the `ValkeyDb` class.

## Usage

### Run Valkey

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **Valkey** on port **6379** using:

```bash
docker run -d \
--name my-valkey \
-p 6379:6379 \
valkey/valkey
```

```python valkey_for_agent.py
from agno.agent import Agent
from agno.db.base import SessionType
from agno.db.valkey import ValkeyDb
from agno.tools.hackernews import HackerNewsTools

# Initialize Valkey db
db = ValkeyDb(
host="localhost",
port=6379,
)

# Create agent with Valkey db
agent = Agent(
db=db,
tools=[HackerNewsTools()],
add_history_to_context=True,
)

agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")

# Verify db contents
print("\nVerifying db contents...")
all_sessions = db.get_sessions(session_type=SessionType.AGENT)
print(f"Total sessions in Valkey: {len(all_sessions)}")

if all_sessions:
print("\nSession details:")
session = all_sessions[0]
print(f"The stored session: {session}")

```

## Params

<Snippet file="db-valkey-params.mdx" />
81 changes: 81 additions & 0 deletions database/providers/valkey/usage/valkey-for-team.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Valkey for Team
sidebarTitle: Team
---

Agno supports using Valkey as a storage backend for Teams using the `ValkeyDb` class.

## Usage

### Run Valkey

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **Valkey** on port **6379** using:

```bash
docker run -d \
--name my-valkey \
-p 6379:6379 \
valkey/valkey
```

```python valkey_for_team.py
"""
Run: `uv pip install openai agno valkey-glide-sync` to install the dependencies
"""

from typing import List

from agno.agent import Agent
from agno.db.valkey import ValkeyDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from pydantic import BaseModel

db = ValkeyDb(
host="localhost",
port=6379,
)

class Article(BaseModel):
title: str
summary: str
reference_links: List[str]

hn_researcher = Agent(
name="HackerNews Researcher",
model=OpenAIResponses(id="gpt-5.2"),
role="Gets top stories from hackernews.",
tools=[HackerNewsTools()],
)

web_searcher = Agent(
name="Web Searcher",
model=OpenAIResponses(id="gpt-5.2"),
role="Searches the web for information on a topic",
tools=[HackerNewsTools()],
add_datetime_to_context=True,
)

hn_team = Team(
name="HackerNews Team",
model=OpenAIResponses(id="gpt-5.2"),
members=[hn_researcher, web_searcher],
db=db,
instructions=[
"First, search hackernews for what the user is asking about.",
"Then, ask the web searcher to search for each story to get more information.",
"Finally, provide a thoughtful and engaging summary.",
],
output_schema=Article,
markdown=True,
show_members_responses=True,
)

hn_team.print_response("Write an article about the top 2 stories on hackernews")

```

## Params

<Snippet file="db-valkey-params.mdx" />
94 changes: 94 additions & 0 deletions database/providers/valkey/usage/valkey-for-workflow.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: Valkey for Workflow
sidebarTitle: Workflow
---

Agno supports using Valkey as a storage backend for Workflows using the `ValkeyDb` class.

## Usage

### Run Valkey

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **Valkey** on port **6379** using:

```bash
docker run -d \
--name my-valkey \
-p 6379:6379 \
valkey/valkey
```

```python valkey_for_workflow.py
"""
Run: `uv pip install openai agno valkey-glide-sync fastapi` to install the dependencies
"""
from agno.agent import Agent
from agno.db.valkey import ValkeyDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow

# Define agents
hackernews_agent = Agent(
name="Hackernews Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
role="Extract key insights and content from Hackernews posts",
)
web_agent = Agent(
name="Web Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
role="Search the web for the latest news and trends",
)

# Define research team for complex analysis
research_team = Team(
name="Research Team",
members=[hackernews_agent, web_agent],
instructions="Research tech topics from Hackernews and the web",
)

content_planner = Agent(
name="Content Planner",
model=OpenAIResponses(id="gpt-5.2"),
instructions=[
"Plan a content schedule over 4 weeks for the provided topic and research content",
"Ensure that I have posts for 3 posts per week",
],
)

# Define steps
research_step = Step(
name="Research Step",
team=research_team,
)

content_planning_step = Step(
name="Content Planning Step",
agent=content_planner,
)

# Create and use workflow
if __name__ == "__main__":
content_creation_workflow = Workflow(
name="Content Creation Workflow",
description="Automated content creation from blog posts to social media",
db=ValkeyDb(
host="localhost",
port=6379,
),
steps=[research_step, content_planning_step],
)
content_creation_workflow.print_response(
input="AI trends in 2024",
markdown=True,
)

```

## Params

<Snippet file="db-valkey-params.mdx" />
Loading
Loading