Skip to main content
Widgets are smart UI cards that appear automatically when Perplexica detects specific types of queries. They provide instant, structured information while your main answer is being generated.

How widgets work

When you ask a question, Perplexica’s classifier determines if any widgets are relevant:
  1. Classification: The AI analyzes your query to detect widget triggers
  2. Parallel execution: Relevant widgets run alongside the main research
  3. Instant display: Widget results appear immediately in the UI
  4. Context for AI: Widget data is provided to the AI as additional context
Widgets run in parallel with research, so they don’t slow down your search results.

Available widgets

Weather

Current conditions and forecasts

Calculations

Mathematical expressions and equations

Stocks

Real-time stock prices and charts

Weather widget

The weather widget provides current conditions and forecasts when you ask about weather. Example queries:
  • “What’s the weather in New York?”
  • “Will it rain tomorrow in London?”
  • “Show me the forecast for Tokyo”
What it shows:
  • Current temperature and conditions
  • Humidity, precipitation, and wind data
  • Hourly forecast for the next 24 hours
  • 7-day daily forecast
  • Weather codes for conditions (sunny, rainy, etc.)
Data sources: The weather widget uses two APIs:
  • OpenStreetMap Nominatim: Converts location names to coordinates
  • Open-Meteo: Fetches weather data and forecasts
You can specify locations by name (“San Francisco, CA”) or coordinates if you prefer. The AI will extract the appropriate format from your query.
Location flexibility:
  • City names: “weather in Paris”
  • City with state/country: “weather in Austin, Texas”
  • Abbreviated forms: “weather in NYC” (automatically expands to New York City)
  • Coordinates: The widget can also work with latitude/longitude

Calculation widget

The calculation widget solves mathematical expressions instantly using the Math.js library. Example queries:
  • “Calculate 15% of 2,450”
  • “What is the square root of 144?”
  • “Solve 3x + 5 = 20”
  • “Convert 100 USD to EUR at 1.18 exchange rate”
What it calculates:
  • Basic arithmetic: addition, subtraction, multiplication, division
  • Advanced math: exponents, roots, logarithms
  • Trigonometry: sin, cos, tan, and their inverses
  • Units and conversions
  • Complex expressions with multiple operations
Powered by Math.js: The widget uses the Math.js library, which supports a wide range of mathematical operations and expressions. If the expression is valid Math.js syntax, the widget will calculate it.
The AI extracts the mathematical expression from your natural language query and evaluates it. If no valid expression can be extracted, the widget won’t appear.
Expression examples:
// These expressions work in the calculation widget:
"sqrt(144)"           // Square root
"15 * 2450 / 100"     // Percentage calculation
"sin(45 deg)"         // Trigonometry with units
"2^8"                 // Exponentiation
"log(100, 10)"        // Logarithm

Stock widget

The stock widget displays real-time stock prices, charts, and financial metrics. Example queries:
  • “Apple stock price”
  • “How is NVDA performing?”
  • “Compare Microsoft and Google stock”
  • “Show me Tesla stock chart”
What it shows:
  • Current market price
  • Daily change (absolute and percentage)
  • Pre-market and post-market prices
  • Previous close, open, high, low
  • Market state (open, closed, pre-market, post-market)
Data source: Stock data is fetched from Yahoo Finance using the yahoo-finance2 library, providing real-time quotes and historical data.
You can use either stock names (“Apple”, “Microsoft”) or ticker symbols (“AAPL”, “MSFT”). The widget will find the correct stock automatically.
Stock comparison: When you ask to compare stocks, the widget can display up to 3 comparison stocks alongside the primary stock:
  • “Compare Nvidia, AMD, and Intel stock”
  • “How do tech giants compare: Apple vs Microsoft vs Google”
Comparison charts show percentage change over time, making it easy to see relative performance.

Widget classification

The classifier determines which widgets to show based on your query:
classification: {
  showWeatherWidget: boolean;
  showStockWidget: boolean;
  showCalculationWidget: boolean;
}
Each widget has a shouldExecute method that checks if it’s been enabled:
shouldExecute: (classification) => classification.classification.showWeatherWidget

Widget data in AI context

Widgets provide context to the AI to improve answer quality:
  • Weather: Current conditions included in the AI’s context
  • Calculations: Result provided so the AI can explain it
  • Stocks: Price and key metrics available for the AI to reference
This allows the AI to give you a natural language answer that incorporates the widget data:
“The current price of Apple (AAPL) is $182.45, up 2.3% today. The stock has shown strong momentum…”
Widgets enhance your search but aren’t cited as sources. They provide structured data that supplements the AI’s researched answer.

Upcoming widgets

Perplexica is actively developing additional widgets:
  • More specialized widgets for common queries
  • Integration with additional data sources
  • Custom widget support
Join the Discord community to suggest new widget ideas or vote on upcoming features.

Build docs developers (and LLMs) love