from agno.agent import Agent
# import phi.api
from agno.models.groq import Groq
# from phi.model.ollama import Ollama
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.playground import Playground, serve_playground_app
from dotenv import load_dotenv
from agno.embedder.ollama import OllamaEmbedder
from agno.knowledge.pdf import PDFKnowledgeBase, PDFReader
from agno.vectordb.pgvector import PgVector
from agno.vectordb.search import SearchType
# import os
# import phi
# phi.api=os.getenv("PHI_API_KEY")
websearch_agent=Agent(
name="web agent",
role="you are web search agent,generate an answer based on data from websearch",
model=Groq(id="llama-3.1-8b-instant"),
tools=[DuckDuckGoTools(fixed_max_results=5)],
instructions=["always include sources"],
show_tool_calls=True,
markdown=True,
debug_mode=True
)
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge_base = PDFKnowledgeBase(
# Read PDF from this URL
path="C:/Users/jithi/Desktop",
# Store embeddings in the `ai.recipes` table
vector_db=PgVector(table_name="recipes", db_url=db_url,embedder=OllamaEmbedder(id="nomic-embed-text",dimensions=768),search_type=SearchType.hybrid),
)
# Load the knowledge base: Comment after first run
# knowledge_base.load(recreate=True)
rag_agent = Agent(
name="RAG agent",
model=Groq(id="llama-3.1-8b-instant"),
# model=Ollama(id="llama3.1:8b"),
knowledge=knowledge_base,
# Enable RAG by adding references from AgentKnowledge to the user prompt.
add_references=True,
# Set as False because Agents default to `search_knowledge=True`
search_knowledge=False,
markdown=True,
debug_mode=True,
instructions=["retrieve essential and accurate points only"],
role=["You are RAG agent"],
)
multi_agent=Agent(
name="multi agents",
model=Groq(id="llama-3.1-8b-instant"),
team=[rag_agent,websearch_agent],
instructions=["call the RAG agent first and then only call the web agent if necessary content isnt recieved from the RAG agent,give priority to info in returned by the RAG agent"],
show_tool_calls=True,
markdown=True,
debug_mode=True
)
app=Playground(agents=[websearch_agent,rag_agent,multi_agent]).get_app()
if __name__=="__main__":
# knowledge_base.load(recreate=True)
serve_playground_app("playgroundwebagent:app",reload=True )
while the agents are run independently,both the web agent and rag agent seems to work fine. But when i call them both us the team orchestration. in debugging the the function call seems to happen,but no content is being returned from the knowledge base nor the web search.