RAG Agent Setup with Agent UI – Error: `net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)`

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 :


@pritiagno @Monali @yash
please look into this

Hi @atharvx
thanks for reaching out and supporting Agno!We’ve shared this with the team and are working through requests one by one—we’ll get back to you as soon as we can.We’ve just kicked off the Global Agent Hackathon , so things are a bit busier than usual. If you’re up for it, we’d love for you to join—it’s a great chance to build, win some exciting prizes and connect with the agent community!If it’s urgent, just let us know. Thanks for your patience!

Hi @Monali I am currently working on this Agent UI and it’s urgent, Could you please provide a solution as soon as possible .
I would love to join hackathon.

Hey @atharvx,

I tried to replicate the issue but wasn’t able to. Could you please share more details on this? Also, try clearing your knowledge_base and try it again

Let me know how it goes!
thanks :raising_hands:

Hi @ayush
I tried this code still getting same error.

I am getting response in my console keeping debug is on but not getting response in UI

from agno.models.openai import OpenAIChat
from agno.playground import Playground, serve_playground_app
from agno.storage.sqlite import SqliteStorage
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools
import os
import dotenv
dotenv.load_dotenv() 
 
from agno.models.azure import AzureOpenAI   
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,
    )
web_agent = Agent(
    name="Web Agent",
    model=azure_model,
    tools=[DuckDuckGoTools()],
    instructions=["Always include sources"],
    # Store the agent sessions in a sqlite database
    storage=SqliteStorage(table_name="web_agent", db_file=agent_storage),
    # Adds the current date and time to the instructions
    add_datetime_to_instructions=True,
    # Adds the history of the conversation to the messages
    add_history_to_messages=True,
    # Number of history responses to add to the messages
    num_history_responses=5,
    # Adds markdown formatting to the messages
    markdown=True,
)

finance_agent = Agent(
    name="Finance Agent",
    model=azure_model,
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
    instructions=["Always use tables to display data"],
    storage=SqliteStorage(table_name="finance_agent", db_file=agent_storage),
    add_datetime_to_instructions=True,
    add_history_to_messages=True,
    num_history_responses=5,
    markdown=True,
)

app = Playground(agents=[web_agent, finance_agent]).get_app()

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

Here is my knowledgebase code:

knowledge_base  = PDFKnowledgeBase(
    path="data/pdfs",
    vector_db=PgVector(
            table_name="AA",
            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"  # Explicitly set the model ID to match your deployment
            )
        )
    )

Please make sure the endpoint is correctly set on agent-ui, and double-check that you’re following the docs here:

:page_facing_up: Agentic RAG with Agent UI - Agno
because we are still not able to replicate the issue ,
can you please try it again after removing max_tokens=16384,

thank :raising_hands: