File size: 2,026 Bytes
4ab9426
 
 
 
 
 
4ed62bb
4ab9426
 
 
 
 
aea8144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---

title: My Ai Twin
emoji: 🤖
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.16.0
app_file: app.py
pinned: false
license: mit
---


# AI Twin RAG Application

This application is an AI Twin of yourself, built using Retrieval-Augmented Generation (RAG). It answers questions based on your personal data stored in the `knowledge_base/` directory.

## Features
- **Personal Knowledge Base:** Uses your real and synthetic data to answer questions.
- **RAG Pipeline:** Utilizes LangChain, ChromaDB, and Hugging Face embeddings for accurate retrieval.
- **Interactive UI:** Built with Gradio for easy interaction.

## Setup & Installation

1.  **Install Dependencies:**
    ```bash

    pip install -r requirements.txt

    ```


2.  **Set Up Hugging Face Token:**
    - You need a Hugging Face API token to use the inference endpoint.
    - Set it as an environment variable:
      ```bash

      export HUGGINGFACEHUB_API_TOKEN="your_token_here"

      # Windows PowerShell:

      $env:HUGGINGFACEHUB_API_TOKEN="your_token_here"

      ```

    - Or uncomment the line in `app.py` to set it directly.


3.  **Run Verification (Optional):**
    ```bash

    python verify_rag.py

    ```


4.  **Launch the App:**
    ```bash

    python app.py

    ```

    The app will run locally at `http://127.0.0.1:7860`.


## Deployment to Hugging Face Spaces

1.  Create a new Space on [Hugging Face](https://huggingface.co/spaces).
2.  Select **Gradio** as the SDK.
3.  Upload the following files:
    - `app.py`
    - `requirements.txt`
    - `knowledge_base/` (entire folder)
    - `chroma_db/` (optional, can be generated on the fly, but better to let it generate)
4.  Add your `HUGGINGFACEHUB_API_TOKEN` in the Space settings (Settings -> Variables and secrets).

## Files
- `app.py`: Main application logic.
- `knowledge_base/`: Directory containing your profile data.
- `requirements.txt`: Python dependencies.
- `verify_rag.py`: Script to test RAG logic without UI.