Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
975513f
refactor: decompose Knowledge class into internal components
willemcdejongh Feb 20, 2026
2a07109
refactor: remove RemoteKnowledge inheritance, use composition
willemcdejongh Feb 20, 2026
70025c7
fix: address PR review bugs in knowledge decomposition
willemcdejongh Feb 20, 2026
09b1af9
fix: always set linked_to metadata in prepare_documents_for_insert
willemcdejongh Feb 23, 2026
0649071
refactor: pass pipeline directly to loaders, delete forwarding methods
willemcdejongh Feb 23, 2026
12f97f8
refactor: replace LightRag class-name checks with ManagedKnowledgeBac…
willemcdejongh Feb 26, 2026
711bfa3
merge: update knowledge-phase3-managed-backend with latest staging
willemcdejongh Mar 4, 2026
93f597f
refactor: rename backend to managed_backend for clarity
willemcdejongh Mar 4, 2026
1c3e353
refactor: rename managed_backend to external_provider, remove LightRa…
willemcdejongh Mar 4, 2026
802726c
refactor: replace all remaining backend references with provider
willemcdejongh Mar 4, 2026
fbc1c83
refactor: rename LightRagBackend class to LightRagProvider
willemcdejongh Mar 4, 2026
09c7e3e
cookbook: add LightRAG external provider cookbook
willemcdejongh Mar 5, 2026
cf427a2
fix: add ProcessingResult schema and status polling to external provi…
willemcdejongh Mar 5, 2026
ea5136b
fix: add processing_id to DB upsert field mappings
willemcdejongh Mar 5, 2026
3ca0303
fix: use _agno metadata for processing_id instead of DB column
willemcdejongh Mar 5, 2026
cece28e
fix: check status_summary before declaring processing complete
willemcdejongh Mar 5, 2026
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
6 changes: 3 additions & 3 deletions cookbook/07_knowledge/04_advanced/03_graph_rag.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Graph RAG: LightRAG Integration
=================================
LightRAG is a managed knowledge backend that builds a knowledge graph
LightRAG is an external knowledge provider that builds a knowledge graph
from your documents. It handles its own ingestion and retrieval,
providing graph-based RAG capabilities.
Expand All @@ -24,10 +24,10 @@
# ---------------------------------------------------------------------------

try:
from agno.vectordb.lightrag import LightRag
from agno.knowledge.external_provider import LightRagProvider

knowledge = Knowledge(
vector_db=LightRag(
external_provider=LightRagProvider(
server_url="http://localhost:9621",
),
)
Expand Down
12 changes: 11 additions & 1 deletion cookbook/07_knowledge/05_integrations/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Integrations

Specific reader, cloud storage, and vector database integrations.
Specific reader, cloud storage, vector database, and external provider integrations.

## Prerequisites

1. Run Qdrant: `./cookbook/scripts/run_qdrant.sh`
2. Set `OPENAI_API_KEY` environment variable
3. For cloud: set provider-specific credentials (see each file)
4. For managed DBs: install provider packages (see each file)
5. For external providers: run the provider server (see each file)

## Readers

Expand All @@ -34,6 +35,15 @@ Specific reader, cloud storage, and vector database integrations.
| [vector_dbs/02_local.py](./vector_dbs/02_local.py) | ChromaDB + LanceDB (local development) |
| [vector_dbs/03_managed.py](./vector_dbs/03_managed.py) | Pinecone + PgVector (managed/production) |

## External Providers

External providers manage their own indexing pipeline (chunking, embedding, storage).
You send documents to them and they handle everything internally.

| File | Provider |
|------|----------|
| [external_providers/01_lightrag.py](./external_providers/01_lightrag.py) | LightRAG (graph-based RAG) |

## Running

```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
LightRAG: Graph-Based External Provider
=========================================
LightRAG is an external knowledge provider that manages its own
graph-based indexing pipeline. Unlike vector databases where Agno
handles chunking, embedding, and storage, LightRAG runs its own
server and handles everything internally.
How it works:
- Documents are sent to LightRAG's HTTP API
- LightRAG extracts entities and relationships
- Queries traverse the knowledge graph for multi-hop reasoning
This is useful when you want graph-based RAG without managing
the graph construction yourself.
Requirements:
- LightRAG server running (default: http://localhost:9621)
- pip install lightrag-agno
"""

import asyncio
from os import getenv

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------

try:
from agno.knowledge.external_provider import LightRagProvider

# LightRagProvider implements the ExternalKnowledgeProvider protocol.
# It handles ingestion, querying, and deletion via LightRAG's HTTP API.
provider = LightRagProvider(
server_url=getenv("LIGHTRAG_SERVER_URL", "http://localhost:9621"),
api_key=getenv("LIGHTRAG_API_KEY"),
)

# Pass the provider directly — no vector_db needed.
knowledge = Knowledge(
name="lightrag-demo",
external_provider=provider,
)

agent = Agent(
model=OpenAIResponses(id="gpt-4o"),
knowledge=knowledge,
search_knowledge=True,
markdown=True,
)

except ImportError:
provider = None
knowledge = None
agent = None
print("LightRAG not installed. Run: pip install lightrag-agno")


# ---------------------------------------------------------------------------
# Run Demo
# ---------------------------------------------------------------------------

if __name__ == "__main__":

async def main():
if not knowledge or not agent:
print("Skipping demo: LightRAG not installed.")
return

# 1. Ingest a document — LightRAG builds a knowledge graph from it
print("\n--- Ingesting document into LightRAG ---\n")
await knowledge.ainsert(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
)

# 2. Query via the agent — retrieval goes through LightRAG's graph
print("\n" + "=" * 60)
print("LightRAG: graph-based knowledge retrieval")
print("=" * 60 + "\n")

agent.print_response(
"What ingredients are commonly shared across Thai recipes?",
stream=True,
)

# 3. You can also query the provider directly for raw results
print("\n--- Direct provider query ---\n")
results = await provider.aquery("What Thai dishes use coconut milk?")
if results:
print(f"Got {len(results)} result(s)")
print(f"References: {results[0].meta_data.get('references', [])}")

asyncio.run(main())
8 changes: 4 additions & 4 deletions cookbook/07_knowledge/09_archive/vector_dbs/lightrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from os import getenv

from agno.agent import Agent
from agno.knowledge.external_provider import LightRagProvider
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.wikipedia_reader import WikipediaReader
from agno.vectordb.lightrag import LightRag

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
vector_db = LightRag(
provider = LightRagProvider(
server_url=getenv("LIGHTRAG_SERVER_URL", "http://localhost:9621"),
api_key=getenv("LIGHTRAG_API_KEY"),
)
Expand All @@ -29,7 +29,7 @@
knowledge = Knowledge(
name="LightRAG Knowledge Base",
description="Knowledge base using LightRAG for graph-based retrieval",
vector_db=vector_db,
external_provider=provider,
)


Expand Down Expand Up @@ -70,7 +70,7 @@ async def main() -> None:
markdown=True,
)

results = await vector_db.async_search("What skills does Jordan Mitchell have?")
results = await provider.aquery("What skills does Jordan Mitchell have?")
if results:
doc = results[0]
print(f"References: {doc.meta_data.get('references', [])}")
Expand Down
8 changes: 4 additions & 4 deletions cookbook/92_integrations/rag/agentic_rag_with_lightrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
from os import getenv

from agno.agent import Agent
from agno.knowledge.external_provider import LightRagProvider
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.wikipedia_reader import WikipediaReader
from agno.vectordb.lightrag import LightRag

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
vector_db = LightRag(api_key=getenv("LIGHTRAG_API_KEY"))
provider = LightRagProvider(api_key=getenv("LIGHTRAG_API_KEY"))

knowledge = Knowledge(
name="My LightRag Knowledge Base",
description="Knowledge base using a LightRag vector database",
vector_db=vector_db,
description="Knowledge base using LightRAG as an external provider",
external_provider=provider,
)

# ---------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions libs/agno/agno/knowledge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from agno.knowledge.external_provider import ExternalKnowledgeProvider
from agno.knowledge.filesystem import FileSystemKnowledge
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.protocol import KnowledgeProtocol
Expand All @@ -6,4 +7,5 @@
"FileSystemKnowledge",
"Knowledge",
"KnowledgeProtocol",
"ExternalKnowledgeProvider",
]
5 changes: 5 additions & 0 deletions libs/agno/agno/knowledge/external_provider/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from agno.knowledge.external_provider.lightrag import LightRagProvider
from agno.knowledge.external_provider.protocol import ExternalKnowledgeProvider
from agno.knowledge.external_provider.schemas import ProcessingResult

__all__ = ["LightRagProvider", "ExternalKnowledgeProvider", "ProcessingResult"]
Loading