Unable to chat with rag-agent using playground #41

Closed
opened 2025-11-06 14:31:49 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Arslan-Mehmood1 on GitHub (Mar 24, 2025).

from agno.agent import Agent
# from agno.models.openai import OpenAIChat
from agno.models.ollama import Ollama
from agno.embedder.ollama import OllamaEmbedder

from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.vectordb.lancedb import LanceDb, SearchType
from agno.playground import Playground, serve_playground_app
from agno.tools.duckduckgo import DuckDuckGoTools

ollama_llm = Ollama(id="llama3.2:1b-instruct-fp16")
ollama_embedder = OllamaEmbedder(id="nomic-embed-text:latest", dimensions=768)

db_uri = "tmp/lancedb"
# Create a knowledge base from a PDF
knowledge_base = PDFUrlKnowledgeBase(
    urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
    # Use LanceDB as the vector database
    vector_db=LanceDb(table_name="recipes", uri=db_uri, search_type=SearchType.vector, embedder=ollama_embedder),
)
# Load the knowledge base: Comment out after first run
# knowledge_base.load(upsert=True)

rag_agent = Agent(
    model=ollama_llm,
    # model=OpenAIChat(id="gpt-4o"),
    agent_id="rag-agent",
    knowledge=knowledge_base, # Add the knowledge base to the agent
    tools=[DuckDuckGoTools()],
    show_tool_calls=True,
    markdown=True,
)

app = Playground(agents=[rag_agent]).get_app()

if __name__ == "__main__":
    serve_playground_app("rag_agent:app", reload=True)

LOGS:

INFO Starting playground on http://localhost:7777                                                                                                                     
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Agent Playground ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                             ┃
┃                                                                             ┃
┃  Playground URL: https://app.agno.com/playground?endpoint=localhost%3A7777  ┃
┃                                                                             ┃
┃                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
INFO:     Will watch for changes in these directories: ['/home/arslan/Data/Learning/REPO/wip/agentic_rag']
INFO:     Uvicorn running on http://localhost:7777 (Press CTRL+C to quit)
INFO:     Started reloader process [31195] using StatReload
INFO:     Started server process [31217]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:38480 - "GET /v1/playground/agents HTTP/1.1" 200 OK
INFO:     127.0.0.1:38496 - "GET /v1/playground/status HTTP/1.1" 200 OK
INFO:     127.0.0.1:38480 - "GET /v1/playground/agents/rag-agent/sessions?user_id=allokzzzzzzz HTTP/1.1" 404 Not Found
Originally created by @Arslan-Mehmood1 on GitHub (Mar 24, 2025). ``` from agno.agent import Agent # from agno.models.openai import OpenAIChat from agno.models.ollama import Ollama from agno.embedder.ollama import OllamaEmbedder from agno.knowledge.pdf_url import PDFUrlKnowledgeBase from agno.vectordb.lancedb import LanceDb, SearchType from agno.playground import Playground, serve_playground_app from agno.tools.duckduckgo import DuckDuckGoTools ollama_llm = Ollama(id="llama3.2:1b-instruct-fp16") ollama_embedder = OllamaEmbedder(id="nomic-embed-text:latest", dimensions=768) db_uri = "tmp/lancedb" # Create a knowledge base from a PDF knowledge_base = PDFUrlKnowledgeBase( urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"], # Use LanceDB as the vector database vector_db=LanceDb(table_name="recipes", uri=db_uri, search_type=SearchType.vector, embedder=ollama_embedder), ) # Load the knowledge base: Comment out after first run # knowledge_base.load(upsert=True) rag_agent = Agent( model=ollama_llm, # model=OpenAIChat(id="gpt-4o"), agent_id="rag-agent", knowledge=knowledge_base, # Add the knowledge base to the agent tools=[DuckDuckGoTools()], show_tool_calls=True, markdown=True, ) app = Playground(agents=[rag_agent]).get_app() if __name__ == "__main__": serve_playground_app("rag_agent:app", reload=True) ``` LOGS: ``` INFO Starting playground on http://localhost:7777 ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Agent Playground ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ ┃ ┃ ┃ ┃ Playground URL: https://app.agno.com/playground?endpoint=localhost%3A7777 ┃ ┃ ┃ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ INFO: Will watch for changes in these directories: ['/home/arslan/Data/Learning/REPO/wip/agentic_rag'] INFO: Uvicorn running on http://localhost:7777 (Press CTRL+C to quit) INFO: Started reloader process [31195] using StatReload INFO: Started server process [31217] INFO: Waiting for application startup. INFO: Application startup complete. INFO: 127.0.0.1:38480 - "GET /v1/playground/agents HTTP/1.1" 200 OK INFO: 127.0.0.1:38496 - "GET /v1/playground/status HTTP/1.1" 200 OK INFO: 127.0.0.1:38480 - "GET /v1/playground/agents/rag-agent/sessions?user_id=allokzzzzzzz HTTP/1.1" 404 Not Found ```
GiteaMirror added the bug label 2025-11-06 14:31:49 -06:00
Author
Owner

@Shubhamsaboo commented on GitHub (Apr 14, 2025):

@Madhuvod can you please check this?

@Shubhamsaboo commented on GitHub (Apr 14, 2025): @Madhuvod can you please check this?
Author
Owner

@Shubhamsaboo commented on GitHub (Jun 15, 2025):

This works based on the logs. You just have to click the link to access the playground as shown in the logs.

http://localhost:7777

@Shubhamsaboo commented on GitHub (Jun 15, 2025): This works based on the logs. You just have to click the link to access the playground as shown in the logs. http://localhost:7777
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-llm-apps#41