RAG Agent Setup with Agent UI – Error: net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
Overview
This document outlines the setup for a Retrieval-Augmented Generation (RAG) agent using the agno
framework, and describes an issue encountered when running the Agent UI via a local Playground.
Error Encountered
While accessing the Agent UI at:
http://localhost:7777/v1/playground/agents/rag-agent/runs
the following error appears in the browser console:
net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
Code Example
from pathlib import Path
from shutil import rmtree
from textwrap import dedent
import os
from typing import Iterator
from agno.knowledge.pdf import PDFKnowledgeBase
from agno.vectordb.pgvector import PgVector, SearchType
from agno.agent import Agent, RunResponse, RunEvent
from agno.storage.sqlite import SqliteStorage
from agno.utils.log import logger
from agno.utils.pprint import pprint_run_response
from agno.workflow import Workflow
from agno.embedder.azure_openai import AzureOpenAIEmbedder
from agno.models.azure import AzureOpenAI
from agno.playground import Playground, serve_playground_app
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
db_url = "postgresql+psycopg://abc:abc@localhost:4444/agentic_rag"
agent_storage: str = "tmp/agents.db"
azure_model = AzureOpenAI(
id=os.getenv("AZURE_OPENAI_MODEL_NAME"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT"),
max_tokens=16384,
)
knowledge_base = PDFKnowledgeBase(
path="data/pdfs",
vector_db=PgVector(
table_name="rag",
db_url=db_url,
search_type=SearchType.hybrid,
embedder=AzureOpenAIEmbedder(
api_key=os.getenv("AZURE_EMBEDDER_OPENAI_API_KEY"),
api_version=os.getenv("AZURE_EMBEDDER_OPENAI_API_VERSION", "2024-02-15-preview"),
azure_endpoint=os.getenv("AZURE_EMBEDDER_OPENAI_ENDPOINT"),
azure_deployment=os.getenv("AZURE_EMBEDDER_DEPLOYMENT"),
id="text-embedding-ada-002"
)
)
)
rag_agent = Agent(
name="RAG Agent",
agent_id="rag-agent",
model=azure_model,
knowledge=knowledge_base,
search_knowledge=True,
read_chat_history=True,
storage=SqliteStorage(table_name="web_agent", db_file=agent_storage),
add_datetime_to_instructions=True,
add_history_to_messages=True,
num_history_responses=5,
instructions=[
"You are a helpful assistant that answers questions based on the provided knowledge base.",
"Always search and reference the knowledge base for accurate information.",
"When responding, follow these rules:",
"- Always cite the source PDF filename and page number for each piece of information",
"- For table data: Extract and present exact values from tables in a structured format",
"- For tabular information, maintain the original column headers and row relationships ad dyou logic to handle table format cause there is not boundry is given",
"- When numerical values are found in tables, ensure accuracy in reporting numbers and units",
"- For paragraph information, summarize key points concisely",
"- Include specific values, measurements, and numbers when available",
"- Keep responses focused and under 10 sentences",
"- If information is not found in knowledge base, clearly state that",
"- Format the reference as: [Source: {PDF_name}, Page {number}]"
],
markdown=True
)
# Load the knowledge base before serving
knowledge_base.load(recreate=False)
# Get the FastAPI app
app = Playground(agents=[rag_agent]).get_app()
if __name__ == "__main__":
serve_playground_app("rag_app:app", reload=True)
Even Same error for Simple Agent.
Below are screenshots :