Metadata-Version: 2.3
Name: chatvat
Version: 0.1.7
Summary: The Universal RAG Chatbot Factory. Zero-dependency AI deployments.
License: Apache-2.0
Author: Madhav Kapila
Author-email: smartatk04@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Build Tools
Provides-Extra: engine
Requires-Dist: beautifulsoup4 (>=4.12.0,<5.0.0) ; extra == "engine"
Requires-Dist: chromadb (>=0.5.0,<0.6.0) ; extra == "engine"
Requires-Dist: crawl4ai (>=0.4.0,<0.5.0) ; extra == "engine"
Requires-Dist: fastapi (>=0.109.0,<0.110.0) ; extra == "engine"
Requires-Dist: langchain (>=0.3.0,<0.4.0) ; extra == "engine"
Requires-Dist: langchain-chroma (>=0.2.0,<0.3.0) ; extra == "engine"
Requires-Dist: langchain-community (>=0.3.0,<0.4.0) ; extra == "engine"
Requires-Dist: langchain-groq (>=0.2.0,<0.3.0) ; extra == "engine"
Requires-Dist: langchain-huggingface (>=0.1.0,<0.2.0) ; extra == "engine"
Requires-Dist: langchain-openai (>=0.2.0,<0.3.0) ; extra == "engine"
Requires-Dist: openai (>=1.10.0,<2.0.0) ; extra == "engine"
Requires-Dist: playwright (>=1.40.0,<2.0.0) ; extra == "engine"
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
Requires-Dist: pyfiglet (>=1.0.2,<2.0.0)
Requires-Dist: pypdf (>=4.0.0,<5.0.0) ; extra == "engine"
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: rich (>=13.7.0,<14.0.0)
Requires-Dist: tiktoken (>=0.7.0,<0.8.0) ; extra == "engine"
Requires-Dist: torch (>=2.2.0,<3.0.0) ; extra == "engine"
Requires-Dist: typer[all] (>=0.12.3,<0.13.0)
Requires-Dist: uvicorn[standard] (>=0.27.0,<0.28.0) ; extra == "engine"
Project-URL: Homepage, https://github.com/madhavkapila
Project-URL: Repository, https://github.com/madhavkapila/ChatVat.git
Description-Content-Type: text/markdown

# ChatVat (The ChatBot🤖 Factory🏭)
> **The Universal RAG Chatbot Factory**

[![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)](https://www.python.org/)
[![Docker](https://img.shields.io/badge/Docker-Ready-2496ED?logo=docker&logoColor=white)](https://www.docker.com/)
[![Style](https://img.shields.io/badge/Code%20Style-Black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)


---

## 🌟 The Vision

**ChatVat** is not just another chatbot script. It is a **Manufacturing Plant** for self-contained AI systems. 

It solves the "It works on my machine" problem by adhering to a strict **"Zero-Dependency"** philosophy. ChatVat takes your raw data sources—websites, APIs, and documents—and fuses them with a production-grade RAG engine into a sealed Docker container. This "capsule" contains everything needed to run: the code, the database, the browser, and the API server.

You can deploy a ChatVat bot anywhere: from a MacBook Air to an air-gapped server in Antarctica, without installing Python or git.

### Core Philosophy
* **Production Parity:** The bot you test locally is bit-for-bit identical to the bot you deploy.
* **Source Injection:** The engine code is "injected" directly into the container during the build. No external git clones or PyPI downloads are required inside the image.
* **Self-Healing:** Built-in deduplication (MD5 Hashing), crash recovery, and "Ghost Entry" prevention.

---

## ⚡ Quick Start

### 1. Installation
Install the ChatVat CLI from the source (or your private registry).

```bash
pip install chatvat
```

### 2. Initialize the Assembly Line
Create a clean directory for your new bot and run the configuration wizard.

```bash
mkdir my-crypto-bot
cd my-crypto-bot
chatvat init
```

*The wizard will guide you through:*
* **Naming your bot**
* **Setting up AI Brain** (Groq Llama-3 + HuggingFace Embeddings)
* **Connecting Data Sources** (URLs, APIs, or Local Files)
* **Defining Deployment Ports**

### 3. Build the Capsule
Compile your configuration and the ChatVat engine into a Docker Image.

```bash
chatvat build
```

> **What happens here?** > The CLI locates the `chatvat` library on your system, copies the core engine code into a build context, injects your `chatvat.config.json`, and triggers a Docker build. The result is a sealed image containing your specific bot.

### 4. Deploy Anywhere
Run your bot using standard Docker commands. It injects your API keys at runtime for security.

```bash
# Example: Running on Port 8000
docker run -d \
  -p 8000:8000 \
  --env-file .env \
  --name crypto-bot \
  chatvat-bot
```

---

## 🧠 Architecture Deep Dive

ChatVat implements a modular **RAG (Retrieval-Augmented Generation)** pipeline designed for resilience.


### The Components

| Component | Role | Description |
| :--- | :--- | :--- |
| **The Cortex** | Intelligence | Powered by **Groq** for ultra-fast inference using the model of your choice and **HuggingFace** for embeddings. |
| **The Memory** | Vector Store | A persistent, thread-safe **ChromaDB** instance. It uses MD5 hashing to prevent duplicate data entry. |
| **The Eyes** | Crawler | A headless **Chromium** browser (via Crawl4AI/Playwright) capable of reading dynamic JS-heavy websites. |
| **The Nervous System** | Ingestor | A background worker that auto-updates knowledge every `X` minutes (configurable). |
| **The API** | Interface | A high-performance **FastAPI** server exposing REST endpoints. |

### The "Source Injection" Workflow

Unlike traditional builds that `pip install` libraries from the internet, ChatVat performs **Source Injection**:

1.  **Locate:** The CLI finds where `chatvat` is installed on your host machine.
2.  **Extract:** It copies the raw Python source code of the engine.
3.  **Inject:** It places this code into the `/app` directory of the Docker container.
4.  **Seal:** The Dockerfile sets `PYTHONPATH=/app`, making the injected code instantly executable without installation.

---

## 🛠️ Configuration Guide

Your bot is defined by `chatvat.config.json`. You can edit this file manually after running `init`.

```json
{
    "bot_name": "ChatVatBot",
    "port": 8000,
    "refresh_interval_minutes": 60,
    "system_prompt": "You are a helpful assistant for the .....",
    "llm_model": "llama-3.1-70b-versatile",
    "embedding_model": "all-MiniLM-L6-v2",
    "sources": [
        {
            "type": "static_url",
            "target": "[https://www.amazon.com/gp/bestsellers/books/ref=zg_bs_nav](https://www.amazon.com/gp/bestsellers/books/ref=zg_bs_nav)"
        },
        {
            "type": "dynamic_json",
            "target": "[https://YOUR_API_ENDPOINT](https://YOUR_API_ENDPOINT)",
            "headers": {
                "Authorization": "Bearer ${API_KEY}"
            }
        },
        {
            "type": "local_file",
            "target": "./policy_docs.pdf"
        }
    ]
}
```

* **`refresh_interval_minutes`**: Set to `0` to disable auto-updates.
* **`sources`**: Supports `static_url` (Websites), `dynamic_json` (REST APIs), and `local_file` (PDF/TXT).
* **`headers`**: Can use `${VAR_NAME}` syntax to reference environment variables from your `.env` file.

---

## 📚 API Reference

Once the container is running, interact with it via HTTP REST API.

### 1. Health Check
Used by cloud balancers (AWS/Render) to verify the bot is alive.

```bash
GET /health
```
**Response:**
```json
{
  "status": "healthy",
  "version": "0.1.0"
}
```

### 2. Chat Interface
The main endpoint for sending queries.

```bash
POST /chat
```
**Payload:**
```json
{
  "message": "What events are happening on Day 1?"
}
```
**Response:**
```json
{
  "message": "On Day 1, the opening ceremony starts at 10 AM..."
}
```

---

## ⚠️ Disclaimer & Legal Notice

**Author:** Madhav Kapila
**Project:** ChatVat - Conversational AI & Web Crawling Engine

This software is provided for **educational and research purposes only**.

1.  **No Liability:** The author (Madhav Kapila) is not responsible for any damage caused by the use of this tool. This includes, but is not limited to:
    * IP bans or blacklisting of your device/server.
    * Legal consequences of crawling restricted or sensitive websites.
    * Data loss or corruption on the user's local machine or target infrastructure.
2.  **User Responsibility:** You, the user, acknowledge that you are solely responsible for compliance with all applicable laws and regulations (such as GDPR, CFAA, or Terms of Service of target websites) when using this software.
3.  **"As Is" Warranty:** This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement.

**By downloading, installing, or using this software, you agree to these terms.**

---

<p align="center">
  Built with ❤️ by the <b>Madhav Kapila</b>.
</p>

