MuhammadSaad16 commited on
Commit
2e51804
Β·
verified Β·
1 Parent(s): 807b59f
Files changed (1) hide show
  1. README.md +10 -152
README.md CHANGED
@@ -1,152 +1,10 @@
1
- # FastAPI RAG Chatbot Backend
2
-
3
- This project implements a FastAPI backend for a Retrieval-Augmented Generation (RAG) chatbot. It integrates with OpenAI for chat completions and embeddings, Neon Serverless Postgres for persistent data, and Qdrant Cloud for vector storage.
4
-
5
- ## Project Structure
6
-
7
- ```
8
- backend/
9
- β”œβ”€β”€ app/
10
- β”‚ β”œβ”€β”€ __init__.py
11
- β”‚ β”œβ”€β”€ main.py
12
- β”‚ β”œβ”€β”€ config.py
13
- β”‚ β”œβ”€β”€ database.py
14
- β”‚ β”œβ”€β”€ qdrant_client.py
15
- β”‚ β”œβ”€β”€ models/
16
- β”‚ β”‚ β”œβ”€β”€ __init__.py
17
- β”‚ β”‚ β”œβ”€β”€ user.py
18
- β”‚ β”‚ └── chat.py
19
- β”‚ β”œβ”€β”€ schemas/
20
- β”‚ β”‚ β”œβ”€β”€ __init__.py
21
- β”‚ β”‚ └── chat.py
22
- β”‚ β”œβ”€β”€ routes/
23
- β”‚ β”‚ β”œβ”€β”€ __init__.py
24
- β”‚ β”‚ β”œβ”€β”€ chat.py
25
- β”‚ β”‚ └── health.py
26
- β”‚ └── services/
27
- β”‚ β”œβ”€β”€ __init__.py
28
- β”‚ β”œβ”€β”€ rag_service.py
29
- β”‚ β”œβ”€β”€ embeddings_service.py
30
- β”‚ └── openai_service.py
31
- β”œβ”€β”€ scripts/
32
- β”‚ └── ingest_content.py
33
- β”œβ”€β”€ .env.example
34
- β”œβ”€β”€ requirements.txt
35
- β”œβ”€β”€ README.md
36
- └── .gitignore
37
- ```
38
-
39
- ## Setup Instructions
40
-
41
- 1. **Clone the repository**:
42
-
43
- ```bash
44
- git clone <repository-url>
45
- cd robotic
46
- ```
47
-
48
- 2. **Navigate to the backend directory**:
49
-
50
- ```bash
51
- cd backend
52
- ```
53
-
54
- 3. **Set up the Python virtual environment and install dependencies**:
55
-
56
- On Windows, run:
57
- ```bash
58
- .\setup.bat
59
- ```
60
-
61
- On Linux/macOS, run:
62
- ```bash
63
- python3 -m venv venv
64
- source venv/bin/activate
65
- pip install -r requirements.txt
66
- ```
67
-
68
- 4. **Configure Environment Variables**:
69
-
70
- Create a `.env` file in the `backend/` directory by copying `.env.example` and filling in your credentials:
71
-
72
- ```bash
73
- copy .env.example .env
74
- # or for Linux/macOS
75
- cp .env.example .env
76
- ```
77
-
78
- Edit the `.env` file with your actual API keys and database URLs:
79
-
80
- ```
81
- OPENAI_API_KEY=your_openai_api_key_here
82
- NEON_DATABASE_URL=your_neon_postgres_connection_string_here
83
- QDRANT_URL=your_qdrant_cluster_url_here
84
- QDRANT_API_KEY=your_qdrant_api_key_here
85
- ```
86
-
87
- ## Running the Application
88
-
89
- 1. **Activate your virtual environment**:
90
-
91
- On Windows:
92
- ```bash
93
- .\venv\Scripts\activate
94
- ```
95
-
96
- On Linux/macOS:
97
- ```bash
98
- source venv/bin/activate
99
- ```
100
-
101
- 2. **Start the FastAPI server**:
102
-
103
- On Windows, run:
104
- ```bash
105
- .\run.bat
106
- ```
107
-
108
- On Linux/macOS, run:
109
- ```bash
110
- uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
111
- ```
112
-
113
- The API will be accessible at `http://localhost:8000`.
114
-
115
- ## API Endpoints
116
-
117
- *(Note: Detailed API documentation will be available at `/docs` once the server is running)*
118
-
119
- ### Health Check
120
-
121
- - **GET `/health`**
122
- - Returns the health status of the backend and its integrated services.
123
-
124
- ### Chatbot Interaction
125
-
126
- - **POST `/chat/`**
127
- - **Description**: Sends a user query to the RAG chatbot and receives a generated response.
128
- - **Request Body Example**:
129
-
130
- ```json
131
- {
132
- "query": "What is the main topic of the book?"
133
- }
134
- ```
135
- - **Response Body Example**:
136
-
137
- ```json
138
- {
139
- "response": "The main topic of the book is ..."
140
- }
141
- ```
142
-
143
- ## Content Ingestion Script
144
-
145
- - **`scripts/ingest_content.py`**
146
- - This script is responsible for reading MDX files from `../physical-ai-humanoid-robotics/docs/`, chunking the text, generating OpenAI embeddings, and storing them in Qdrant.
147
- - **Usage**:
148
-
149
- ```bash
150
- python scripts/ingest_content.py
151
- ```
152
-
 
1
+ ---
2
+ title: Chat Robot
3
+ emoji: 😻
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference