Skip to main content

Norns Knowledge Domain

General knowledge and information retrieval capabilities for the Norns agent system.


Overview

The Knowledge domain provides Norns with the ability to answer general knowledge queries, including weather conditions, news articles, current events, sports scores, and factual information. It integrates with external APIs to retrieve up-to-date information beyond the agent's training data.

PropertyValue
DomainDomain.KNOWLEDGE
SupervisorKnowledgeDomainSupervisor
WorkersWebSearchWorker, WeatherWorker, NewsWorker
Level2 (Domain Supervisor)

Architecture

The Knowledge domain follows the hierarchical agent architecture with a domain supervisor coordinating three specialized workers:

┌─────────────────────────────────────────────────────────┐
│ KNOWLEDGE DOMAIN SUPERVISOR │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ WebSearch │ │ Weather │ │ News │ │
│ │ Worker │ │ Worker │ │ Worker │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Tavily API │ │ OpenWeather │ │ Brave Search │ │
│ │ (Search) │ │ API │ │ API │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────┘

Query Routing

The supervisor analyzes incoming requests and routes them to the appropriate worker based on intent:

Query TypeExampleWorker
Weather conditions"What's the weather like?"WeatherWorker
Weather forecasts"Will it rain tomorrow?"WeatherWorker
General facts"What is the capital of France?"WebSearchWorker
How-to questions"How do I make pasta?"WebSearchWorker
Trivia"Who won the Super Bowl?"WebSearchWorker
News articles"Latest news about AI"NewsWorker
Sports scores"NFL scores today"NewsWorker

Workers

WebSearchWorker

Handles general web search and factual queries using the Tavily API.

Capabilities:

  • General facts and trivia (who, what, when, where, why questions)
  • How-to guides and tutorials
  • Current information about topics
  • Answers to specific questions

Parameters:

  • query: Search query (required)
  • search_depth: "basic" for quick answers, "advanced" for thorough research
  • max_results: Number of results to return (1-10, default: 5)

Example Queries:

  • "What is quantum computing?"
  • "How do I change a tire?"
  • "Who invented the telephone?"
  • "When was the Eiffel Tower built?"

WeatherWorker

Retrieves weather conditions and forecasts using OpenWeatherMap API.

Capabilities:

  • Current weather conditions
  • 5-day weather forecasts
  • Temperature, humidity, wind speed
  • Weather descriptions (cloudy, rainy, etc.)

Parameters:

  • location: City name or "current" for default location
  • units: "imperial" (Fahrenheit) or "metric" (Celsius)
  • forecast_type: "current" or "forecast"

Example Queries:

  • "What's the weather like?"
  • "Weather in Austin, Texas"
  • "Will it rain tomorrow?"
  • "Is it going to snow this week?"
  • "Temperature in San Francisco"

Note: If location is "current", "here", "home", or blank, the system uses the DEFAULT_LOCATION environment variable.

NewsWorker

Searches for recent news articles using the Brave Search News API.

Capabilities:

  • Current events and breaking news
  • Sports scores and results
  • Recent headlines on any topic
  • Time-filtered news (day, week, month)

Parameters:

  • query: News topic to search for (required)
  • count: Number of results (1-10, default: 5)
  • freshness: "day", "week", or "month"

Example Queries:

  • "Latest news about artificial intelligence"
  • "NFL scores today"
  • "What happened in tech news?"
  • "Breaking news about climate"

Setup

Required API Keys

All API keys must be configured in /Users/ravenhelm/ravenhelm/secrets/.env:

# Tavily API (Web Search)
TAVILY_API_KEY=tvly-...

# OpenWeatherMap API (Weather)
OPENWEATHER_API_KEY=...

# Brave Search API (News)
BRAVE_API_KEY=...

# Default location for weather queries (optional)
DEFAULT_LOCATION=San Marcos, TX

API Service Setup

Sign up: https://tavily.com

Free Tier:

  • 1,000 searches/month
  • Basic and advanced search depth
  • Real-time web results

Steps:

  1. Create account at https://tavily.com
  2. Navigate to API Keys section
  3. Copy API key (starts with tvly-)
  4. Add to .env as TAVILY_API_KEY

2. OpenWeatherMap API (Weather)

Sign up: https://openweathermap.org/api

Free Tier:

  • 1,000 calls/day
  • Current weather data
  • 5-day forecast
  • 3-hour forecast intervals

Steps:

  1. Create account at https://openweathermap.org/api
  2. Subscribe to "Current Weather Data" and "5 Day Forecast" (both free)
  3. Go to API Keys section
  4. Copy or generate API key
  5. Add to .env as OPENWEATHER_API_KEY

Warning: API keys can take up to 2 hours to activate after signup.

3. Brave Search API (News)

Sign up: https://brave.com/search/api/

Free Tier:

  • 2,000 queries/month
  • News search with freshness filters
  • No credit card required

Steps:

  1. Create account at https://brave.com/search/api/
  2. Navigate to API Keys section
  3. Generate new API key
  4. Add to .env as BRAVE_API_KEY

Docker Configuration

Ensure environment variables are passed to the norns-agent container in docker-compose.yml:

norns-agent:
environment:
# Knowledge Domain APIs
- TAVILY_API_KEY=${TAVILY_API_KEY}
- OPENWEATHER_API_KEY=${OPENWEATHER_API_KEY}
- BRAVE_API_KEY=${BRAVE_API_KEY}
- DEFAULT_LOCATION=${DEFAULT_LOCATION:-San Marcos, TX}

Restart After Configuration

# Restart Norns agent to load new environment variables
ssh ravenhelm@100.115.101.81 "docker restart norns-agent"

# Verify logs
ssh ravenhelm@100.115.101.81 "docker logs -f norns-agent"

Usage Examples

Weather Queries

User: What's the weather like?
Norns: [Routes to WeatherWorker with location="current"]
→ Provides current weather for DEFAULT_LOCATION

User: Weather in Austin
Norns: [Routes to WeatherWorker with location="Austin, TX"]
→ Provides current weather for Austin

User: Will it rain tomorrow in Seattle?
Norns: [Routes to WeatherWorker with forecast_type="forecast"]
→ Provides 5-day forecast and analyzes rain probability

Web Search Queries

User: What is machine learning?
Norns: [Routes to WebSearchWorker with search_depth="basic"]
→ Returns concise definition and overview

User: How do I bake sourdough bread?
Norns: [Routes to WebSearchWorker with search_depth="advanced"]
→ Returns detailed step-by-step instructions

User: Who won the 2024 World Series?
Norns: [Routes to WebSearchWorker]
→ Returns current sports information

News Queries

User: Latest AI news
Norns: [Routes to NewsWorker with query="artificial intelligence", freshness="week"]
→ Returns recent AI-related news articles

User: NFL scores today
Norns: [Routes to NewsWorker with query="NFL scores", freshness="day"]
→ Returns today's NFL game results

User: What's happening in tech?
Norns: [Routes to NewsWorker with query="technology news", freshness="week"]
→ Returns recent tech headlines

Implementation Details

File Locations

/Users/ravenhelm/ravenhelm/docs/AI-ML-Platform/norns-agent/agent/
├── agents/
│ ├── domain_supervisors/
│ │ └── knowledge_supervisor.py # Domain supervisor
│ └── workers/
│ └── knowledge_workers.py # Worker implementations
└── tools.py # Tool function definitions

Code Structure

Domain Supervisor (knowledge_supervisor.py):

  • Analyzes user intent using LLM
  • Routes to appropriate worker
  • Extracts and passes parameters
  • Aggregates results

Workers (knowledge_workers.py):

  • WebSearchWorker: Tavily API integration
  • WeatherWorker: OpenWeatherMap API integration
  • NewsWorker: Brave Search News API integration

Tools (tools.py):

  • web_search(): Async Tavily search function
  • get_weather(): Async weather data retrieval
  • search_news(): Async news search function

Event Publishing

All workers publish events to Redpanda for observability:

  1. TOOL_CALL event when worker starts
  2. TOOL_RESULT event when worker completes
  3. Includes execution time and metadata

Events can be traced in Langfuse for debugging.


Troubleshooting

Issue: "Web search is not configured"

Symptoms: Worker returns configuration error message

Cause: TAVILY_API_KEY not set or not loaded

Solution:

# Check environment variable
ssh ravenhelm@100.115.101.81 "docker exec norns-agent env | grep TAVILY"

# Verify .env file
ssh ravenhelm@100.115.101.81 "grep TAVILY /Users/ravenhelm/ravenhelm/secrets/.env"

# Restart container
ssh ravenhelm@100.115.101.81 "docker restart norns-agent"

Issue: "Weather service is not configured"

Symptoms: Weather queries return configuration error

Cause: OPENWEATHER_API_KEY not set or API key not activated

Solution:

# Check if key is set
ssh ravenhelm@100.115.101.81 "docker exec norns-agent env | grep OPENWEATHER"

# Test manually
curl "https://api.openweathermap.org/data/2.5/weather?q=Austin&appid=YOUR_KEY"

# Restart container
ssh ravenhelm@100.115.101.81 "docker restart norns-agent"

Issue: "News search is not configured"

Symptoms: News queries fail with configuration error

Cause: BRAVE_API_KEY not set

Solution:

# Check environment variable
ssh ravenhelm@100.115.101.81 "docker exec norns-agent env | grep BRAVE"

# Verify .env file
ssh ravenhelm@100.115.101.81 "grep BRAVE /Users/ravenhelm/ravenhelm/secrets/.env"

# Restart container
ssh ravenhelm@100.115.101.81 "docker restart norns-agent"

Issue: Weather returns wrong location

Symptoms: Weather queries always return data for unexpected location

Cause: DEFAULT_LOCATION environment variable set incorrectly

Solution:

# Check current default location
ssh ravenhelm@100.115.101.81 "docker exec norns-agent env | grep DEFAULT_LOCATION"

# Update in .env file
ssh ravenhelm@100.115.101.81 "nano /Users/ravenhelm/ravenhelm/secrets/.env"
# Set: DEFAULT_LOCATION=YourCity, YourState

# Restart
ssh ravenhelm@100.115.101.81 "docker restart norns-agent"

Issue: API rate limit exceeded

Symptoms: Errors about quota or rate limits

Solutions:

Tavily (1,000/month):

OpenWeatherMap (1,000/day):

Brave Search (2,000/month):

Debugging with Langfuse

View detailed trace data for Knowledge domain queries:

  1. Open https://langfuse.ravenhelm.dev
  2. Navigate to Traces
  3. Filter by session ID or user ID
  4. Look for TOOL_CALL and TOOL_RESULT events
  5. Check execution time and error messages
# View recent logs for errors
ssh ravenhelm@100.115.101.81 "docker logs norns-agent 2>&1 | grep -A 10 'knowledge'"

Future Enhancements

Potential additions to the Knowledge domain:

  • Calculator/Math: Wolfram Alpha integration for calculations
  • Wikipedia: Direct Wikipedia API for encyclopedic knowledge
  • Stock/Finance: Real-time stock prices and financial data
  • Translation: Language translation capabilities
  • Image Search: Visual search capabilities
  • Maps/Directions: Location and navigation data