Metadata-Version: 2.4
Name: bibliophile-assistant
Version: 0.1.0
Summary: Document-based AI assistant using Ollama and ChromaDB
Home-page: https://github.com/JyslaFancy/Bibliophile-Assistant
Author: Harald Daltveit
Author-email: harald@daltveit.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Utilities
Classifier: Topic :: Text Processing
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# Bibliophile Assistant

A CLI tool that uses Ollama and ChromaDB to create a document-based AI assistant. Users can point to folders with documents (Word, PDF, Markdown, Excel, PowerPoint) and the tool will index them for AI-powered question answering.

## Features

- **Document Processing**: Supports PDF, Word (DOCX, DOC), Markdown, Text, Excel (XLSX, XLS), and PowerPoint (PPTX, PPT) files
- **Ollama Integration**: Uses local Ollama models for embeddings and chat
- **ChromaDB**: Vector database for efficient document retrieval
- **Auto-Setup**: Detects hardware (RAM, GPU) and suggests appropriate models
- **User-Friendly CLI**: Easy-to-use command-line interface with progress indicators

## Installation

### Prerequisites

- Python 3.8 or higher
- Git (for cloning)

### Setup

1. Clone the repository:
   ```bash
   git clone https://github.com/JyslaFancy/Bibliophile-Assistant.git
   cd Bibliophile-Assistant
   ```

2. Install Python dependencies:
   ```bash
   pip install -e .
   ```
   Or install manually:
   ```bash
   pip install -r requirements.txt
   ```

3. Install Ollama (if not already installed):
   - The tool can automatically install Ollama on Linux/macOS
   - Or install manually from [https://ollama.ai](https://ollama.ai)

4. Pull the models (the tool will suggest appropriate ones based on your hardware):
   ```bash
   bibliophile setup
   ```

## Usage

### Setup and Configuration

```bash
# Auto-detect hardware and suggest models
bibliophile setup

# Auto-install Ollama if not found
bibliophile setup --install-ollama

# Auto-pull suggested models
bibliophile setup --pull-models

# Start Ollama server
bibliophile setup --start-server

# Full auto-setup (install + models + server)
bibliophile setup --install-ollama --pull-models --start-server

# Or manually configure
bibliophile setup --manual
```

### Index Documents

```bash
# Index all documents in a folder
bibliophile index /path/to/documents

# With a custom collection name
bibliophile index /path/to/documents --name my_project

# With custom chunk size
bibliophile index /path/to/documents --chunk-size 500

# Overwrite existing collection
bibliophile index /path/to/documents --overwrite
```

### Ask Questions

```bash
# Ask a question about your documents
bibliophile ask "What is the main topic of these documents?"

# Ask from a specific collection
bibliophile ask "What are the key findings?" --collection my_project

# Get more results
bibliophile ask "Summarize the documents" --limit 10
```

### Interactive Chat

```bash
# Start an interactive chat session
bibliophile chat

# With a specific collection
bibliophile chat --collection my_project

# With more results per query
bibliophile chat --limit 10
```

**Chat Commands:**
- `/quit`, `/exit`, `/q` - End the chat session
- `/help`, `/h` - Show available commands
- `/clear`, `/reset` - Clear conversation history
- `/collection`, `/col` - Show current collection

### Manage Collections

```bash
# List all collections
bibliophile list-collections

# Delete a collection
bibliophile delete-collection my_project
```

### Configuration

```bash
# Show current configuration
bibliophile config-show

# Reset configuration
bibliophile config-reset

# Use custom config file
bibliophile --config /path/to/config.yaml index /path/to/documents
```

## Supported File Types

- `.pdf` - PDF documents
- `.docx` - Word documents (Office Open XML)
- `.doc` - Word documents (legacy)
- `.md` - Markdown files
- `.txt` - Plain text files
- `.xlsx` - Excel spreadsheets
- `.xls` - Excel spreadsheets (legacy)
- `.pptx` - PowerPoint presentations
- `.ppt` - PowerPoint presentations (legacy)

## Configuration

Configuration is stored in `~/.bibliophile/config.yaml` by default.

### Configuration Options

```yaml
ollama:
  chat_model: "llama3"        # Model for chat/answering
  embedding_model: "llama3"   # Model for embeddings
  base_url: "http://localhost:11434"  # Ollama API URL

chroma:
  path: ".bibliophile/chroma"  # ChromaDB data directory
  persist_directory: null

document_processing:
  chunk_size: 1000           # Characters per chunk
  chunk_overlap: 200         # Overlap between chunks
  supported_extensions:     # File extensions to process
    - ".pdf"
    - ".docx"
    - ".md"
    - ".txt"
    - ".xlsx"
    - ".pptx"

collections: []             # List of indexed collections
```

## Hardware Requirements

The tool will automatically detect your system hardware and suggest appropriate models:

- **Minimum**: 8GB RAM - Uses small models like `llama3`
- **Recommended**: 16GB+ RAM - Can use larger models like `llama3.2`
- **With GPU**: 12GB+ VRAM - Can use GPU-accelerated models

## Troubleshooting

### Ollama not found

Make sure Ollama is installed and running:
```bash
ollama --version
ollama serve
```

### Missing dependencies

Install required packages:
```bash
pip install -r requirements.txt
```

For PDF support:
```bash
pip install pypdf
```

For Word/Excel/PowerPoint support:
```bash
pip install python-docx openpyxl python-pptx
```

### ChromaDB issues

Make sure ChromaDB is installed:
```bash
pip install chromadb
```

## Development

Run the CLI directly:
```bash
python -m bibliophile.main
```

Or install in development mode:
```bash
pip install -e .
```

## License

MIT License - See [LICENSE](LICENSE) for details.
