Skip to content

Commit b00ec0b

Browse files
Merge pull request #23 from akvo/feature/22-deploy-chat-widget-for-tdt-knowledge-hub-documents-to-knowledge-hub-page
Feature/22 deploy chat widget for tdt knowledge hub documents to knowledge hub page
2 parents ab9050b + 45c8567 commit b00ec0b

File tree

5 files changed

+383
-32
lines changed

5 files changed

+383
-32
lines changed

demo-page/config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ window.config_default = {
33
title: "Akvo RAG",
44
kb_options: [
55
{
6-
kb_id: 25,
7-
label: "UNEP Knowledge Base with 500 docs",
8-
},
9-
{
10-
kb_id: 26,
11-
label: "UNEP Knowledge Base with 250 docs",
6+
kb_id: 34,
7+
label: "UNEP Knowledge Base",
128
},
139
{
1410
kb_id: 28,
@@ -38,3 +34,10 @@ window.config_living_income = {
3834
kb_id: 28,
3935
wsURL: "wss://akvo-rag.akvotest.org/ws/chat",
4036
};
37+
38+
// LOCAL ENV
39+
window.config_local = {
40+
title: "Chat from Local",
41+
kb_id: 38,
42+
wsURL: "ws://localhost:81/ws/chat",
43+
};

demo-page/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/>
1818
<link
1919
rel="stylesheet"
20-
href="https://cdn.jsdelivr.net/npm/[email protected].5/dist/akvo-rag.css"
20+
href="https://cdn.jsdelivr.net/npm/[email protected].6/dist/akvo-rag.css"
2121
/>
2222
</head>
2323
<body>
@@ -41,7 +41,7 @@ <h1>RAG Chat Assistant</h1>
4141

4242
<!-- Chat widget CDN script (to be added) -->
4343
<script src="config.js"></script>
44-
<script src="https://cdn.jsdelivr.net/npm/[email protected].5/dist/akvo-rag.js"></script>
44+
<script src="https://cdn.jsdelivr.net/npm/[email protected].6/dist/akvo-rag.js"></script>
4545
<script>
4646
const params = new URLSearchParams(window.location.search);
4747
const docs = params.get("docs");

script/README.md

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,51 @@
11
# 📚 Table of Contents
22

33
- [📚 Table of Contents](#-table-of-contents)
4-
- [🤖 UNEP Knowledge Base import script](#-unep-knowledge-base-import-script)
5-
- [🔐 Environment Variables](#-environment-variables)
6-
- [🚀 Running the Script](#-running-the-script)
7-
- [📁 Directory Structure](#-directory-structure)
84
- [🤖 Create or Update User script](#-create-or-update-user-script)
95
- [🚀 Usage](#-usage)
106
- [⚙️ Script flow:](#️-script-flow)
117
- [Example](#example)
8+
- [🤖 UNEP Knowledge Base import script](#-unep-knowledge-base-import-script)
9+
- [🔐 Environment Variables](#-environment-variables)
10+
- [🚀 Running the Script](#-running-the-script)
11+
- [📁 Directory Structure](#-directory-structure)
12+
- [🤖 TDT Knowledge Base import script](#-tdt-knowledge-base-import-script)
13+
- [🔐 Environment Variables](#-environment-variables-1)
14+
- [🚀 Running the Script](#-running-the-script-1)
15+
- [📁 Directory Structure](#-directory-structure-1)
16+
17+
---
18+
19+
# 🤖 Create or Update User script
20+
21+
This script helps create or update user quickly in the system, ensuring user records are set up correctly for authentication and access control. It can also assign superuser status for administrative privileges.
22+
23+
## 🚀 Usage
24+
25+
The `add_user.py` script allows you to create or update a user account in the system’s user database (or service).
26+
27+
```bash
28+
./dev.sh exec script python -m add_user
29+
```
30+
31+
## ⚙️ Script flow:
32+
1. Prompt for Email
33+
The script will ask for the user's email address.
34+
2. Prompt for Superuser Status
35+
You’ll be asked whether the user should be a superuser (y for yes, n for no).
36+
3. User Creation/Update
37+
- The script will either create a new user or update an existing user with the given email.
38+
- The username and password will both be set to the email address as a default (consider changing the password later for security).
39+
40+
### Example
41+
42+
```bash
43+
=== Create or Update User ===
44+
45+
Is Super User? (y/n): y
46+
```
47+
48+
This creates or updates the user `[email protected]` and marks them as a superuser.
1249

1350
---
1451

@@ -56,33 +93,46 @@ You will be prompted to:
5693

5794
---
5895

59-
# 🤖 Create or Update User script
96+
# 🤖 TDT Knowledge Base import script
6097

61-
This script helps create or update user quickly in the system, ensuring user records are set up correctly for authentication and access control. It can also assign superuser status for administrative privileges.
98+
This script automates the process of collecting, saving, and uploading PDF documents from [TDT Knowledge Hub](https://tdt.akvotest.org/knowledge-hub) into a RAG (Retrieval-Augmented Generation) system.
6299

63-
## 🚀 Usage
100+
This Python script supports three main operation modes:
64101

65-
The `add_user.py` script allows you to create or update a user account in the system’s user database (or service).
102+
1. **CSV Only** – Save PDF URLs to a CSV file.
103+
2. **CSV + Download** – Save URLs and download the corresponding PDFs.
104+
3. **Full Process** – Save URLs, download PDFs, and upload/process them in RAG.
105+
106+
## 🔐 Environment Variables
107+
108+
Before running the script, set RAG credentials in your shell or environment:
109+
110+
``` bash
111+
export RAG_USERNAME="rag_admin"
112+
export RAG_PASSWORD="RAGadmin1"
113+
```
114+
115+
## 🚀 Running the Script
116+
117+
To execute the script:
66118

67119
```bash
68-
./dev.sh exec script python -m add_user
120+
./dev.sh exec script python -m kb_init_tdt
69121
```
70122

71-
## ⚙️ Script flow:
72-
1. Prompt for Email
73-
The script will ask for the user's email address.
74-
2. Prompt for Superuser Status
75-
You’ll be asked whether the user should be a superuser (y for yes, n for no).
76-
3. User Creation/Update
77-
- The script will either create a new user or update an existing user with the given email.
78-
- The username and password will both be set to the email address as a default (consider changing the password later for security).
123+
You will be prompted to:
124+
- Choose the operation mode:
125+
1: Save PDF URLs to CSV only.
126+
2: Save to CSV and download PDFs.
127+
3: Full process (CSV + download + upload to RAG).
79128

80-
### Example
129+
- Enter the number of documents to import.
130+
- Provide a description for the RAG knowledge base.
81131

132+
## 📁 Directory Structure
82133
```bash
83-
=== Create or Update User ===
84-
85-
Is Super User? (y/n): y
134+
./downloads/tdt/tdt_files.csv – Stores PDF URLs and offsets.
135+
./downloads/tdt/ – Folder where downloaded PDF files are saved.
86136
```
87137

88-
This creates or updates the user `[email protected]` and marks them as a superuser.
138+
---

0 commit comments

Comments
 (0)