Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JoeCardoso13/diary_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

10 Commits

Repository files navigation


Diary Bot RAG Assistant

This application creates a Retrieval-Augmented Generation (RAG) system that allows users to ask questions about their custom-made diary. For demonstration, the system uses an arbitrarily created diary, with AI generated entries stored in a .csv file. The script for injecting this data appropriately into a PostgreSQL database with vector embeddings is provided, it enables context-aware responses to user queries.

πŸ–₯️ Gradio Web Interface

Gradio UI Demonstration Gradio UI Demonstration



⌨️ Command Line Interface

CLI Demonstration

Prerequisites

  • Python 3.8+
  • PostgreSQL 12+ with pgvector extension
  • OpenAI API key

Installation

  1. Clone this repository and change directory to its root folder:
git clone https://github.com/JoeCardoso13/diary_bot.git && cd diary_bot
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up PostgreSQL:

    • Install PostgreSQL if you haven't already
    • Install the pgvector extension:
      CREATE EXTENSION vector;
    • Create a database named diary_bot
  2. Add your OpenAI API key into your environment, e.g. an .env file with the following:

OPENAI_API_KEY=your_api_key_here
DB_NAME=diary_bot
DB_USER=your_psql_user_name
DB_HOST=/var/run/postgresql_or_localhost
DB_PORT=5432

Data Processing

Before using the system, you need to process the diary entries by running the pre_processing.py script:

python src/pre_processing.py

This will:

  • Read the CSV file
  • Generate embeddings for each entry
  • Store the data in the PostgreSQL database

Running the Application

Option 1: Web Interface

Run the Gradio interface for a user-friendly web experience:

python src/main_gradio_interface.py

This will:

  • Start a local web server
  • Open the interface in your default browser
  • Allow you to:
    • Ask questions about my hike
    • Get random question suggestions
    • See responses with source attribution

Option 2: Command Line Interface

Run the CLI version for a simpler interface:

python src/main_command_line.py

This provides:

  • A text-based interface
  • Same functionality as the web version
  • Responses in the terminal

Project Structure

diary_bot/
β”œβ”€β”€ data/
β”‚ └── diary.csv # Blog entries data
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ pre_processing.py # Data processing and embedding generation
β”‚ β”œβ”€β”€ rag_tools.py # Shared RAG functionality
β”‚ β”œβ”€β”€ main_command_line.py # CLI interface
β”‚ └── main_gradio_interface.py # Web interface
β”œβ”€β”€ requirements.txt # Python dependencies
└── README.md

Database Schema

The diary table contains:

  • id: Unique identifier
  • date: Date of diary entry
  • entry: Content of diary entry
  • embedding: Vector embedding of the entry text

What's Next

The next evolution of Diary Bot leans into the Model Context Protocol.

The idea: expose the existing RAG system as an MCP server, then surface it as an MCP App β€” an iframe that lives inside a claude.ai session. The agent there can see everything the app renders, query the diary freely, and reason over it in real time. The RAG system stops being a standalone tool and becomes something a live Claude agent can reach into on demand.

The gut feeling driving this: a diary is personal context. An agent with access to your personal context β€” able to surface patterns, make connections, answer questions you didn't know to ask β€” is a fundamentally different kind of assistant.

About

A RAG based Diary Bot assistant with 2 interface options: web UI and CLI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /