Skip to content

Commit b09f09c

Browse files
[cookbook] Multi Agent Teams using Local Agentic RAG (#4238)
## Science Agent - Physics and Chemistry Agent tl;dr - This is a multi-document Agentic RAG which routes to a specific Agent based on the knowledge base for the roleplay. - The Agentic RAG system is set up locally using Ollama, FastEmbed and Qdrant-Client. - The same pipeline can be replaced to SambaNova or Groq instead of Ollama for faster LLM inference Co-authored-by: Mustafa Esoofally <[email protected]>
1 parent 7614703 commit b09f09c

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""
2+
pip install agno
3+
pip install fastembed, qdrant-client
4+
pip install ollama [ollama pull qwen2.5:7b]
5+
pip install pypdf
6+
"""
7+
8+
from agno.agent import Agent
9+
from agno.team import Team
10+
from agno.models.ollama import Ollama
11+
from agno.vectordb.qdrant import Qdrant
12+
from agno.embedder.fastembed import FastEmbedEmbedder
13+
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
14+
15+
collection_name = "science"
16+
physics_tb = "https://ncert.nic.in/textbook/pdf/keph101.pdf"
17+
chemistry_tb = "https://ncert.nic.in/textbook/pdf/lech101.pdf"
18+
19+
vector_db = Qdrant(
20+
path = "/tmp/qdrant",
21+
collection=collection_name,
22+
embedder=FastEmbedEmbedder(),
23+
)
24+
25+
knowledge_base = PDFUrlKnowledgeBase(
26+
urls = [physics_tb,chemistry_tb],
27+
vector_db=vector_db,
28+
num_documents = 4,
29+
)
30+
knowledge_base.load() # once the data is stored, comment this line
31+
32+
physics_agent = Agent(
33+
name = "Physics Agent",
34+
role = "Expert in Physics",
35+
instructions = "Answer questions based on the knowledge base",
36+
model=Ollama(id="qwen2.5:7b"),
37+
read_chat_history=True,
38+
show_tool_calls=True,
39+
markdown=True,
40+
)
41+
42+
chemistry_agent = Agent(
43+
name = "Chemistry Agent",
44+
role = "Expert in Chemistry",
45+
instructions = "Answer questions based on the knowledge base",
46+
model=Ollama(id="qwen2.5:7b"),
47+
read_chat_history=True,
48+
show_tool_calls=True,
49+
markdown=True,
50+
)
51+
52+
science_master = Team(
53+
name="Team with Knowledge",
54+
members=[physics_agent,chemistry_agent],
55+
model=Ollama(id="qwen2.5:7b"),
56+
knowledge=knowledge_base,
57+
search_knowledge=True,
58+
show_members_responses=True,
59+
markdown=True,
60+
)
61+
62+
#science_master.print_response("give dimensional equation for volume, speed and force",stream=True)
63+
science_master.print_response("state Henry's law",stream=True)

0 commit comments

Comments
 (0)