Skip to content

gnovelli/WikiDai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WikidAI

AI-Powered Knowledge Assistant with Transparent Multi-Agent Orchestration

Educational demonstration of how modern LLMs orchestrate specialized agents to answer complex queries

License: MIT Docker Gemini 2.5 Pro TypeScript

Quick Start โ€ข Features โ€ข Architecture โ€ข Demo Queries


๐Ÿ’ก What is WikidAI?

WikidAI is an educational proof-of-concept that demonstrates how Large Language Models can orchestrate multiple specialized agents to answer complex questions. Unlike black-box AI assistants, WikidAI shows you exactly how it thinks - you can watch in real-time as it:

  • ๐Ÿง  Reasons about which data sources to query
  • ๐Ÿ”ง Generates SPARQL queries for Wikidata's knowledge graph
  • ๐ŸŒ Fetches summaries from Wikipedia and OpenStreetMap
  • โ›… Retrieves real-time weather data
  • ๐Ÿ”„ Chains multiple queries together to answer complex questions

I have built it in a few hours for a short lightning talk for itWikiCon 2025 on November 8, 2025 in Catania. This Proof of Concept showcases the power of transparent AI orchestration with Gemini 2.5 Pro.

๐Ÿš€ Quick Start

Get WikidAI running in under 2 minutes:

Prerequisites

Setup

# 1. Clone the repository
git clone https://github.com/gnovelli/wikidai.git
cd wikidai

# 2. Configure your API key
cd backend
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

# 3. Launch with Docker
cd ..
docker compose up

๐ŸŽ‰ You're Ready!

Open your browser and navigate to:


โœจ What Makes WikidAI Special?

๐Ÿ” Transparent AI Reasoning

Unlike typical AI assistants that hide their decision-making process, WikidAI provides a real-time window into the AI's thoughts:

User: "Who is the mayor of Rome and what's the weather there?"

AI Reasoning (visible to you):
โ”œโ”€ ๐Ÿค” Need to find current mayor โ†’ Query Wikidata with SPARQL
โ”œโ”€ ๐Ÿ“ Got Roberto Gualtieri โ†’ Need location coordinates
โ”œโ”€ ๐Ÿ—บ๏ธ Query Nominatim for Rome coordinates
โ””โ”€ โ›… Query OpenMeteo for current weather

Final Answer: "Roberto Gualtieri is the mayor of Rome.
Current weather: 22ยฐC, partly cloudy..."

๐ŸŽฏ Production-Grade Features

Feature Description
๐Ÿ›ก๏ธ SPARQL Gauntlet Multi-layer security validation for generated queries
๐Ÿงช Syntax Validation Uses sparqljs to validate queries before execution
๐Ÿ’ฌ Multi-Turn Conversations Maintains context across multiple questions
โšก Function Calling Native Gemini 2.5 Pro function orchestration
๐ŸŽจ Educational UI 3-panel dashboard showing Input โ†’ Reasoning โ†’ Output
๐Ÿณ Docker-First Zero-config deployment with hot-reload for development

๐Ÿค– Four Specialized Agents

  1. WikidataAgent - Queries the world's largest open knowledge graph

    • Generates SPARQL queries from natural language
    • Handles entity disambiguation (e.g., "Paris the city" vs "Paris Hilton")
    • Validates and sanitizes all queries
  2. WikipediaAgent - Fetches concise summaries

    • Multi-language support
    • Fallback handling for missing articles
  3. NominatimAgent - Geocoding and reverse geocoding

    • Powered by OpenStreetMap data
    • Returns detailed location information
  4. OpenMeteoAgent - Real-time weather data

    • No API key required
    • Current conditions and forecasts

๐ŸŽฎ Try It Yourself!

Simple Queries

๐Ÿ’ฌ "Who was Albert Einstein?"
โ†’ Fetches Wikipedia summary

๐Ÿ’ฌ "What's the population of Tokyo?"
โ†’ Generates and executes SPARQL query on Wikidata

Complex Multi-Agent Orchestration

๐Ÿ’ฌ "Who is the mayor of Rome and what's the weather there today?"
โ†’ Chains: Wikidata โ†’ Nominatim โ†’ OpenMeteo

๐Ÿ’ฌ "Tell me about Marie Curie and the weather in her birthplace"
โ†’ Chains: Wikipedia โ†’ Wikidata โ†’ Nominatim โ†’ OpenMeteo

Advanced SPARQL Generation

๐Ÿ’ฌ "List all Italian cities with more than 500,000 inhabitants"
โ†’ Generates complex SPARQL with filters and aggregations

๐Ÿ’ฌ "Who are the Nobel Prize winners born in Germany?"
โ†’ Demonstrates entity disambiguation and property navigation

๐Ÿ—๏ธ Architecture

WikidAI uses a clean, layered architecture designed for educational clarity:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  ๐ŸŒ User Browser                    โ”‚
โ”‚              http://localhost:8080                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         ๐Ÿ“ฑ Frontend (Nginx + Vanilla JS)            โ”‚
โ”‚   โ€ข 3-Panel Dashboard (Input/Reasoning/Output)      โ”‚
โ”‚   โ€ข Real-time thought stream visualization          โ”‚
โ”‚   โ€ข Agent call tracking & metrics                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚ REST API
                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        ๐ŸŽฏ Backend (Express + TypeScript)            โ”‚
โ”‚                                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚  โ”‚     ๐Ÿง  Gemini Orchestrator               โ”‚      โ”‚
โ”‚  โ”‚  (Function Calling + Thinking Mode)      โ”‚      โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚             โ”‚                                       โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚    โ–ผ                 โ–ผ          โ–ผ         โ–ผ        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚  โ”‚ ๐Ÿ“š โ”‚          โ”‚ ๐Ÿ—บ๏ธ โ”‚      โ”‚ ๐ŸŒ โ”‚    โ”‚ โ›… โ”‚     โ”‚
โ”‚  โ”‚Wikiโ”‚          โ”‚Nom โ”‚      โ”‚Wikiโ”‚    โ”‚Openโ”‚     โ”‚
โ”‚  โ”‚dataโ”‚          โ”‚inatโ”‚      โ”‚pediโ”‚    โ”‚Meteโ”‚     โ”‚
โ”‚  โ”‚    โ”‚          โ”‚im  โ”‚      โ”‚a   โ”‚    โ”‚o   โ”‚     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚                                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚   ๐Ÿ’พ Redis Cache  โ”‚
     โ”‚  (Future: Rate    โ”‚
     โ”‚   Limiting)       โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

External APIs:
โ”œโ”€ Wikidata SPARQL Endpoint (query.wikidata.org)
โ”œโ”€ Wikipedia API (en.wikipedia.org/api)
โ”œโ”€ Nominatim (nominatim.openstreetmap.org)
โ”œโ”€ OpenMeteo (api.open-meteo.com)
โ””โ”€ Gemini 2.5 Pro (generativelanguage.googleapis.com)

Key Design Decisions

๐ŸŽจ Why Vanilla JS for Frontend?

  • Educational clarity - no framework magic to understand
  • Fast iteration during PoC phase
  • Easy for contributors to jump in

๐Ÿค– Why Gemini 2.5 Pro?

  • Native function calling (no custom parsing needed)
  • "Thinking mode" for transparent reasoning
  • Extended context window (1M tokens)
  • Cost-effective for educational projects

๐Ÿณ Why Docker-First?

  • Zero dependency conflicts
  • Identical dev/prod environments
  • Hot-reload for rapid development

๐Ÿ“‚ Project Structure

wikidai/
โ”œโ”€โ”€ ๐ŸŽจ frontend/
โ”‚   โ”œโ”€โ”€ index.html              # 3-panel dashboard UI
โ”‚   โ”œโ”€โ”€ nginx.conf              # Reverse proxy config
โ”‚   โ””โ”€โ”€ Dockerfile              # Nginx container
โ”‚
โ”œโ”€โ”€ โš™๏ธ backend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿค– agents/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ wikidata-agent.ts      # SPARQL generation & validation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ wikipedia-agent.ts     # Wikipedia API wrapper
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ nominatim-agent.ts     # Geocoding service
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ openmeteo-agent.ts     # Weather data
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ prompts/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ system-instructions.ts        # Balanced mode
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ wikidata-focused-instructions.ts  # SPARQL-first mode
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ”œโ”€โ”€ orchestrator.ts            # Gemini function calling logic
โ”‚   โ”‚   โ”œโ”€โ”€ conversation-manager.ts    # Multi-turn state management
โ”‚   โ”‚   โ”œโ”€โ”€ reflexive-mode.ts          # Advanced reasoning loops
โ”‚   โ”‚   โ”œโ”€โ”€ config.ts                  # Environment configuration
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts                   # TypeScript interfaces
โ”‚   โ”‚   โ””โ”€โ”€ index.ts                   # Express server
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Dockerfile              # Multi-stage Node.js build
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ tsconfig.json
โ”‚
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml       # Full stack orchestration
โ”œโ”€โ”€ ๐Ÿ“– README.md                #    

๐Ÿงช Development & Testing

Running Tests

# Inside Docker container
docker compose exec backend npm test

# Or locally (requires Node.js 20+)
cd backend
npm install
npm test

Development Commands

# Start all services with hot-reload
docker compose up

# Rebuild after Dockerfile changes
docker compose up --build

# View logs in real-time
docker compose logs -f backend

# Stop all services
docker compose down

# Stop and remove volumes (clean slate)
docker compose down -v

# Run a specific agent test
docker compose exec backend npm run test:wikidata

Environment Variables

Create backend/.env with:

# Required
GEMINI_API_KEY=your_api_key_here

# Optional
NODE_ENV=development
PORT=3000
REDIS_URL=redis://redis:6379
LOG_LEVEL=debug

๐Ÿ“Š Implementation Status

โœ… Phase 1: PoC (Completed)

Feature Status Details
Docker Setup โœ… Complete Multi-stage builds, hot-reload, health checks
Gemini Integration โœ… Complete Function calling, thinking mode, history
Wikidata Agent โœ… Complete SPARQL generation, validation, gauntlet
Wikipedia Agent โœ… Complete Summary fetching, error handling
Nominatim Agent โœ… Complete Geocoding and reverse geocoding
OpenMeteo Agent โœ… Complete Real-time weather data
Educational UI โœ… Complete 3-panel dashboard with reasoning display
Multi-Turn Conversations โœ… Complete Context preservation across queries

PoC Success Metrics:

  • โœ… All demo queries working (100% success rate)
  • โœ… SPARQL validation operational (prevents injection)
  • โœ… Thought visualization functional
  • โœ… Multi-agent orchestration working

๐Ÿšง Phase 2: MVP (In Progress)

  • Rate limiting with BullMQ
  • DuckDuckGo web search agent
  • Production frontend (SolidJS rewrite)
  • Advanced error handling
  • Performance metrics dashboard
  • API documentation (OpenAPI/Swagger)

๐Ÿ”ฎ Phase 3: Production (Planned)

  • Cloud deployment (Google Cloud Run)
  • Authentication & user management
  • Query caching & optimization
  • Monitoring & observability (Prometheus/Grafana)
  • Multi-language support
  • Advanced SPARQL optimization

๐Ÿค Contributing

WikidAI is an educational project - contributions are welcome!

How to Contribute

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Commit with clear messages: git commit -m 'Add amazing feature'
  5. Push to your fork: git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

  • Follow the existing TypeScript style (we use ESLint)
  • Add tests for new agents or features
  • Update documentation for significant changes
  • Keep the educational focus - clarity over cleverness

Ideas for Contributions

  • ๐ŸŒ New agents (e.g., DBpedia, Europeana, arXiv)
  • ๐ŸŽจ UI improvements (dark mode, mobile responsiveness)
  • ๐Ÿ“Š Better visualization of SPARQL queries
  • ๐Ÿงช More comprehensive test coverage
  • ๐Ÿ“ Documentation improvements or translations
  • ๐Ÿ”ง Performance optimizations

๐Ÿ“– Learn More

Related Resources


๐Ÿ™ Acknowledgments

WikidAI was created by Giovanni Novelli Ph.D. for itWikiCon 2025 in Catania, Italy.

Special thanks to:

  • The Wikimedia community for Wikidata and Wikipedia
  • Google for the Gemini API
  • OpenStreetMap contributors
  • The open-source community

Author: Giovanni Novelli Ph.D.


๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright ยฉ 2025 Giovanni Novelli Ph.D.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.


๐Ÿ“ฌ Contact & Support


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •