This example shows how to build Sage, a Perplexity-like Answer Engine that intelligently determines whether to perform a web search or conduct a deep analysis using ExaTools based on the user’s query.

Sage:

  1. Uses real-time web search (DuckDuckGo) and deep contextual analysis (ExaTools) to provide comprehensive answers
  2. Intelligently selects tools based on query complexity
  3. Provides an interactive Streamlit UI with session management and chat history export
  4. Supports multiple LLM providers (OpenAI, Anthropic, Google, Groq)

Key capabilities

  • Natural language query understanding and processing
  • Real-time web search integration with DuckDuckGo
  • Deep contextual analysis using ExaTools
  • Multiple LLM provider support
  • Session management using SQLite
  • Chat history export
  • Interactive Streamlit UI

Simple queries to try

  • “Tell me about the tariffs the US is imposing in 2025”
  • “Which is a better reasoning model: o3-mini or DeepSeek R1?”
  • “Tell me about Agno”
  • “What are the latest trends in renewable energy?”

Advanced analysis queries

  • “Evaluate how emerging AI regulations could influence innovation”
  • “Compare the environmental impact of electric vs hydrogen vehicles”
  • “Analyze the global semiconductor supply chain challenges”
  • “Explain the implications of quantum computing on cryptography”

Code

The complete code is available in the Agno repository.

Usage

1

Clone the repository

git clone https://github.com/agno-agi/agno.git
cd agno
2

Create virtual environment

python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
3

Install dependencies

pip install -r cookbook/examples/apps/answer_engine/requirements.txt
4

Set up API keys

# Required
export OPENAI_API_KEY=***
export EXA_API_KEY=***

# Optional (for additional models)
export ANTHROPIC_API_KEY=***
export GOOGLE_API_KEY=***
export GROQ_API_KEY=***

We recommend using gpt-4o for optimal performance.

5

Launch the app

streamlit run cookbook/examples/apps/answer_engine/app.py

Open localhost:8501 to start using Sage.

Model Selection

The application supports multiple model providers:

  • OpenAI (o3-mini, gpt-4o)
  • Anthropic (claude-3-5-sonnet)
  • Google (gemini-2.0-flash-exp)
  • Groq (llama-3.3-70b-versatile)

Agent Configuration

The agent configuration is in agents.py and the prompts are in prompts.py:

  • To modify prompts, update the prompts.py file
  • To add new tools or models, update the agents.py file

Support

Need help? Join our Discourse community for support!