Skip to content

Repository files navigation

Dynamic RAG Bot

A conversational AI that provides country information using OpenAI's GPT-5 mini model. The bot can answer basic questions from memory or fetch detailed information from documents when needed.

What It Does

The bot knows basic facts about 10 countries and can have intelligent conversations:

  • Quick answers: "What's the capital of France?" → "Paris"
  • Deep dives: When you want more details, it fetches information from country documents
  • Smart decisions: Automatically knows whether to answer from memory or look up documents

Countries Supported

France, Spain, Japan, Germany, Italy, Brazil, India, China, USA, Australia

Each country has basic facts (capital, population, language, currency) in memory, plus detailed documents covering geography, history, culture, and economy.

How It Works

  1. main.py - Chat interface where you talk to the bot
  2. bot.py - Makes decisions about how to answer your questions
  3. document_reader.py - Fetches detailed info from country files when needed
  4. models.py - Data structures for consistent responses
  5. data/countries/ - Detailed information files for each country

Quick Start

  1. Setup:

    python -m venv .venv
    .venv\Scripts\activate  # Windows
    pip install openai instructor python-dotenv pydantic rich
  2. Add your OpenAI API key to .env:

    OPENAI_API_KEY=your-key-here
    
  3. Run:

    python main.py

Example Conversations

You: What's the capital of Spain?
Bot: The capital of Spain is Madrid. Would you like to know more about Spain?

You: Yes
Bot: What specifically would you like to know about Spain?

You: Tell me about Spanish food
Bot: [Fetches detailed information about Spanish cuisine from documents]

Architecture

Simple function-based design using OpenAI's stateful Responses API:

  • No classes, just clean functions
  • Automatic conversation memory
  • Structured responses with source citations
  • Error handling for missing information

Testing

Run the integration tests to verify everything works:

python test_integration.py
python simple_integration_test.py

Technology

  • OpenAI GPT-5 mini with Responses API for stateful conversations
  • Instructor for structured AI outputs
  • Pydantic for data validation
  • Python 3.11

Current Status

✅ Stage 1: Single document system working

  • Basic Q&A from memory
  • Document fetching with citations
  • Smart routing between memory and documents

🔄 Next: Multi-document comparisons ("Compare French and Spanish wine")

About

Conversational AI that provides country information using OpenAI GPT-5 mini with smart document retrieval

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages