Skip to content

Commit

Permalink
Add custom retriever
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Feb 5, 2025
1 parent a049d78 commit 3fc7576
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cookbook/agent_concepts/knowledge/custom/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from agno.vectordb.qdrant import Qdrant
from qdrant_client import QdrantClient

# -------------------------------------------------------------------------------------------------
# ---------------------------------------------------------
# This section loads the knowledge base. Skip if your knowledge base was populated elsewhere.
# Define the embedder
embedder = OpenAIEmbedder(id="text-embedding-3-small")
Expand All @@ -21,20 +21,20 @@
# Load the knowledge base
# knowledge_base.load(recreate=True) # Comment out after first run
# Knowledge base is now loaded
# -------------------------------------------------------------------------------------------------
# ---------------------------------------------------------


# -------------------------------------------------------------------------------------------------
# Define the custom retriever
# This is the function that the agent will use to retrieve documents
def retriever(
query: str, agent: Optional[Agent] = None, num_documents: int = 5, **kwargs
) -> Optional[list[dict]]:
"""
Custom retriever function to search the vector database for relevant documents.
Args:
agent (Agent): The agent instance making the query
query (str): The search query string
agent (Agent): The agent instance making the query
num_documents (int): Number of documents to retrieve (default: 5)
**kwargs: Additional keyword arguments
Expand Down

0 comments on commit 3fc7576

Please sign in to comment.