Skip to content

ohmdob/ruby-chan

Repository files navigation

🧠 NoteGraph - Knowledge Graph Note Taking System

A semantic note-taking application with knowledge graph capabilities, powered by SQLite-Vec for vector search and LLM integration for intelligent summarization.

✨ Features

  • 🔍 Semantic Search: Find notes using meaning and context, not just keywords
  • 🕸️ Knowledge Graph: Automatic relationship detection between notes
  • 🧠 LLM Integration: AI-powered summarization and analysis
  • 📝 Rich Notes: Support for tags, titles, and content
  • 🎯 Interactive UI: Gradio-based web interface for visualization
  • 💾 Local-first: SQLite database with vector extensions
  • 🚀 Fast: Efficient vector search with sqlite-vec

🛠️ Installation

Prerequisites

  • Python 3.12+
  • OpenAI API key (for LLM features)

Setup

  1. Create virtual environment:

    uv venv --python=3.12 .venv
    source .venv/bin/activate
  2. Install dependencies:

    uv pip install -r requirements.txt
  3. Set up API key:

    export OPENAI_API_KEY="your-openai-api-key"

🚀 Quick Start

1. Test the system

# Test vector database functionality
uv run python test_vec0.py

# Run comprehensive tests
uv run python test_note_graph.py

2. Run the demo

uv run python demo.py

3. Launch the web interface

uv run python gradio_app.py

The web interface will be available at http://localhost:7860

📁 Project Structure

ruby-chan/
├── note_graph.py      # Core NoteGraph class
├── gradio_app.py      # Web interface
├── test_note_graph.py # Comprehensive tests
├── test_vec0.py      # Vector database tests
├── debug_vec.py      # Debug utilities
├── requirements.txt  # Dependencies
├── README.md         # This file
└── AGENTS.md         # Project documentation

🔧 Usage

Python API

from note_graph import NoteGraph

# Initialize the system
ng = NoteGraph("my_notes.db")
ng.init_embedding_model()
ng.init_openai("your-api-key")

# Add a note
note_id = ng.add_note(
    "Machine Learning Basics",
    "Machine learning enables computers to learn from data...",
    ["AI", "ML", "Basics"]
)

# Semantic search
results = ng.semantic_search("neural networks", limit=5)

# Get knowledge graph
G = ng.get_knowledge_graph()

# Generate summary
summary = ng.summarize_notes([note_id, other_id])

Web Interface

The Gradio interface provides:

  • 📝 Add Notes: Create new notes with tags
  • 🔍 Search: Semantic and text search
  • 🕸️ Knowledge Graph: Interactive visualization
  • 📊 Analysis: Note details and AI summaries

🧪 Testing

Run all tests to verify functionality:

# Vector database tests
uv run python test_vec0.py

# Comprehensive system tests
uv run python test_note_graph.py


## 🔬 Technology Stack

- **Database**: SQLite with sqlite-vec extension
- **Embeddings**: Sentence Transformers (all-MiniLM-L6-v2)
- **Web UI**: Gradio
- **Graph**: NetworkX
- **LLM**: OpenAI GPT-3.5-turbo
- **Visualization**: Plotly

## 📝 API Keys

The system uses OpenAI for:
- Automatic relationship generation
- Note summarization
- Intelligent analysis

Set your API key:
```bash
export OPENAI_API_KEY="sk-..."

🔍 Vector Search

Uses sqlite-vec for high-performance semantic search:

  • 384-dimensional embeddings
  • Euclidean distance for similarity
  • Sub-second search times
  • Supports thousands of notes

🕸️ Knowledge Graph

Automatically detects relationships between notes:

  • Similar: Semantically related content
  • Reference: Direct references or citations
  • Follow-up: Sequential learning paths
  • Contrast: Opposing or alternative views

🎯 Example Use Cases

  1. Research Notes: Connect academic papers and concepts
  2. Learning Journal: Track understanding and relationships
  3. Meeting Notes: Find related discussions and decisions
  4. Personal Knowledge: Build your second brain
  5. Documentation: Connect technical concepts and examples

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Submit a pull request

📄 License

This project is open source and available under the MIT License.

🆘 Troubleshooting

Common Issues

  1. Tokenizers Warning: Set TOKENIZERS_PARALLELISM=false
  2. Embedding Size: Ensure all embeddings are 384 dimensions
  3. API Key: Verify OpenAI key is set correctly
  4. Memory: Large datasets may need more RAM

Debug Mode

Run the debug script to test vector operations:

uv run python debug_vec.py

🎉 Getting Started

  1. Install dependencies
  2. Set up API key
  3. Launch the web interface
  4. Start adding notes!

Happy note-taking! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages