File size: 3,389 Bytes
78e8dd4
 
 
 
 
 
8d12e54
78e8dd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---

title: CSRC Car Manual RAG System
emoji: πŸš—
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 6.0.0
app_file: app.py
pinned: false
license: mit
---


# CSRC Car Manual RAG System

An intelligent RAG (Retrieval-Augmented Generation) system for querying car manual documents using OpenAI and vector stores.

## πŸš€ Features

- **RAG-based Q&A**: Ask questions about car manual content
- **Vector Store**: Fast and accurate document retrieval
- **Knowledge Graph**: Visualize document relationships
- **Personalized Learning**: Adaptive learning paths (optional)
- **Scenario Contextualization**: Context-aware responses (optional)

## πŸ“‹ Setup Instructions

### 1. Clone or Upload to Hugging Face Spaces

- **Option A**: Create a new Space on Hugging Face and upload files
- **Option B**: Connect your GitHub repository to Spaces

### 2. Set Environment Variables (Secrets)

Go to **Settings > Secrets** in your Space and add:

```

OPENAI_API_KEY=your-openai-api-key-here

```

⚠️ **Important**: Never commit API keys to the repository. Always use Spaces Secrets.

### 3. Upload PDF Files

Ensure your PDF files are in the `car_manual/` directory:

```

car_manual/

β”œβ”€β”€ Function of Active Distance Assist DISTRONIC.pdf

β”œβ”€β”€ Function of Active Lane Change Assist.pdf

β”œβ”€β”€ Function of Active Steering Assist.pdf

└── Function of Active Stop-and-Go Assist.pdf

```

### 4. Wait for Build

Spaces will automatically:
- Install dependencies from `requirements.txt`
- Run `app.py`
- Start the Gradio interface

## πŸ“ Project Structure

```

.

β”œβ”€β”€ app.py                 # Hugging Face Spaces entry point

β”œβ”€β”€ main.py               # Local development entry point

β”œβ”€β”€ requirements.txt      # Python dependencies

β”œβ”€β”€ src/                  # Core modules

β”œβ”€β”€ modules/              # Feature modules

β”œβ”€β”€ car_manual/           # PDF files directory

β”œβ”€β”€ config/               # Configuration files

└── output/               # Output directory (auto-created)

```

## πŸ”§ Configuration

### Required

- **OPENAI_API_KEY**: Your OpenAI API key (set in Spaces Secrets)

### Optional

- **PDF Files**: Place in `car_manual/` directory
- **Vector Store**: Automatically created on first run

## πŸ“– Usage

1. Wait for the Space to build (check the logs)
2. Open the Gradio interface
3. Enter your question in the input field
4. Get answers with source citations

## πŸ› Troubleshooting

### Error: OPENAI_API_KEY not found

- Go to Settings > Secrets
- Add `OPENAI_API_KEY` with your actual API key
- Restart the Space

### Error: No PDF files found

- Ensure PDF files are in the `car_manual/` directory
- Check file permissions
- Verify file names (case-sensitive)

### Build Fails

- Check the logs for error messages
- Verify `requirements.txt` is correct
- Ensure all Python dependencies are compatible

## πŸ“ Notes

- Vector store is created automatically on first run
- Vector store ID is saved in `config/vector_store_config.json`
- First initialization may take time (uploading PDFs to OpenAI)

## πŸ”— Links

- [OpenAI API Keys](https://platform.openai.com/api-keys)
- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)

## πŸ“„ License

MIT License