Spaces:
Sleeping
Sleeping
Full translation + fix bugs
Browse files- static/script.js +19 -12
- static/styles.css +2 -1
- templates/index.html +13 -13
static/script.js
CHANGED
@@ -91,8 +91,8 @@ class DocumentSearchChatBot {
|
|
91 |
this.displayResults();
|
92 |
|
93 |
} catch (error) {
|
94 |
-
console.error('
|
95 |
-
this.showError(
|
96 |
} finally {
|
97 |
this.hideLoading();
|
98 |
}
|
@@ -103,7 +103,7 @@ class DocumentSearchChatBot {
|
|
103 |
const resultsSection = document.getElementById('results-section');
|
104 |
|
105 |
if (this.searchResults.length === 0) {
|
106 |
-
resultsContainer.innerHTML = '<p class="no-results">
|
107 |
resultsSection.classList.remove('hidden');
|
108 |
return;
|
109 |
}
|
@@ -123,6 +123,13 @@ class DocumentSearchChatBot {
|
|
123 |
this.updateChatButtonState();
|
124 |
}
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
createResultCard(result, index) {
|
127 |
const card = document.createElement('div');
|
128 |
card.className = 'result-card';
|
@@ -131,18 +138,18 @@ class DocumentSearchChatBot {
|
|
131 |
card.innerHTML = `
|
132 |
<div class="card-header">
|
133 |
<div class="card-info">
|
134 |
-
<div class="card-id">ID: ${result.id}</div>
|
135 |
-
<div class="card-title">${result.title}</div>
|
136 |
-
<div class="card-section">${result.section}</div>
|
137 |
</div>
|
138 |
-
<div class="similarity-score">${result.similarity}%</div>
|
139 |
</div>
|
140 |
<div class="card-actions">
|
141 |
-
<button class="view-btn" data-id="${result.id}" data-section="${result.section}" data-content="${result.content}">
|
142 |
<span class="material-icons">visibility</span>
|
143 |
Voir le contenu
|
144 |
</button>
|
145 |
-
<input type="checkbox" class="select-checkbox" onchange="app.toggleDocumentSelection(${index})">
|
146 |
</div>
|
147 |
`;
|
148 |
|
@@ -215,7 +222,7 @@ class DocumentSearchChatBot {
|
|
215 |
document.getElementById('chat-section').classList.remove('hidden');
|
216 |
|
217 |
// Ajouter un message de bienvenue
|
218 |
-
this.addChatMessage('bot', `
|
219 |
}
|
220 |
|
221 |
backToSearch() {
|
@@ -267,8 +274,8 @@ class DocumentSearchChatBot {
|
|
267 |
this.chatHistory.push({"role": "assistant", "content": data.response})
|
268 |
|
269 |
} catch (error) {
|
270 |
-
console.error('
|
271 |
-
this.addChatMessage('bot',
|
272 |
} finally {
|
273 |
submitBtn.disabled = false;
|
274 |
}
|
|
|
91 |
this.displayResults();
|
92 |
|
93 |
} catch (error) {
|
94 |
+
console.error('Error on search:', error);
|
95 |
+
this.showError(`Error on search. Please try again. : ${error}`);
|
96 |
} finally {
|
97 |
this.hideLoading();
|
98 |
}
|
|
|
103 |
const resultsSection = document.getElementById('results-section');
|
104 |
|
105 |
if (this.searchResults.length === 0) {
|
106 |
+
resultsContainer.innerHTML = '<p class="no-results">No results has been found.</p>';
|
107 |
resultsSection.classList.remove('hidden');
|
108 |
return;
|
109 |
}
|
|
|
123 |
this.updateChatButtonState();
|
124 |
}
|
125 |
|
126 |
+
escapeHtml(str) {
|
127 |
+
if (!str) return '';
|
128 |
+
const div = document.createElement('div');
|
129 |
+
div.textContent = str;
|
130 |
+
return div.innerHTML;
|
131 |
+
}
|
132 |
+
|
133 |
createResultCard(result, index) {
|
134 |
const card = document.createElement('div');
|
135 |
card.className = 'result-card';
|
|
|
138 |
card.innerHTML = `
|
139 |
<div class="card-header">
|
140 |
<div class="card-info">
|
141 |
+
<div class="card-id">ID: ${this.escapeHtml(result.id)}</div>
|
142 |
+
<div class="card-title">${this.escapeHtml(result.title)}</div>
|
143 |
+
<div class="card-section">${this.escapeHtml(result.section)}</div>
|
144 |
</div>
|
145 |
+
<div class="similarity-score">${this.escapeHtml(result.similarity)}%</div>
|
146 |
</div>
|
147 |
<div class="card-actions">
|
148 |
+
<button class="view-btn" data-id="${this.escapeHtml(result.id)}" data-section="${this.escapeHtml(result.section)}" data-content="${this.escapeHtml(result.content)}">
|
149 |
<span class="material-icons">visibility</span>
|
150 |
Voir le contenu
|
151 |
</button>
|
152 |
+
<input type="checkbox" class="select-checkbox" onchange="app.toggleDocumentSelection(${this.escapeHtml(index)})">
|
153 |
</div>
|
154 |
`;
|
155 |
|
|
|
222 |
document.getElementById('chat-section').classList.remove('hidden');
|
223 |
|
224 |
// Ajouter un message de bienvenue
|
225 |
+
this.addChatMessage('bot', `Hello ! I'm ready to answer to all of your questions regarding the ${this.selectedDocuments.size} selected section(s) of different specifications. What do you want to know ?`);
|
226 |
}
|
227 |
|
228 |
backToSearch() {
|
|
|
274 |
this.chatHistory.push({"role": "assistant", "content": data.response})
|
275 |
|
276 |
} catch (error) {
|
277 |
+
console.error('Error on sending message:', error);
|
278 |
+
this.addChatMessage('bot', `Sorry, an error has occurred. Please try again. : ${error}`);
|
279 |
} finally {
|
280 |
submitBtn.disabled = false;
|
281 |
}
|
static/styles.css
CHANGED
@@ -307,7 +307,7 @@ body {
|
|
307 |
border-radius: 8px;
|
308 |
padding: 30px;
|
309 |
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
310 |
-
height:
|
311 |
display: flex;
|
312 |
flex-direction: column;
|
313 |
}
|
@@ -337,6 +337,7 @@ body {
|
|
337 |
flex: 1;
|
338 |
display: flex;
|
339 |
flex-direction: column;
|
|
|
340 |
}
|
341 |
|
342 |
.chat-messages {
|
|
|
307 |
border-radius: 8px;
|
308 |
padding: 30px;
|
309 |
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
310 |
+
height: 75vh;
|
311 |
display: flex;
|
312 |
flex-direction: column;
|
313 |
}
|
|
|
337 |
flex: 1;
|
338 |
display: flex;
|
339 |
flex-direction: column;
|
340 |
+
overflow: hidden;
|
341 |
}
|
342 |
|
343 |
.chat-messages {
|
templates/index.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
9 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
@@ -16,27 +16,27 @@
|
|
16 |
<header class="header">
|
17 |
<div class="logo">
|
18 |
<span class="material-icons">search</span>
|
19 |
-
<h1>
|
20 |
</div>
|
21 |
</header>
|
22 |
|
23 |
<!-- Search Section -->
|
24 |
<section id="search-section" class="search-section">
|
25 |
<div class="search-container">
|
26 |
-
<h2>
|
27 |
<form id="search-form" class="search-form">
|
28 |
<div class="input-group">
|
29 |
<input type="text" id="keyword" placeholder="Entrez vos mots-clés..." required>
|
30 |
<span class="material-icons">search</span>
|
31 |
</div>
|
32 |
<div class="threshold-group">
|
33 |
-
<label for="threshold">
|
34 |
<input type="range" id="threshold" min="0" max="100" step="1" value="70">
|
35 |
<span id="threshold-value"></span>
|
36 |
</div>
|
37 |
<button type="submit" class="search-btn">
|
38 |
<span class="material-icons">search</span>
|
39 |
-
|
40 |
</button>
|
41 |
</form>
|
42 |
</div>
|
@@ -45,15 +45,15 @@
|
|
45 |
<!-- Results Section -->
|
46 |
<section id="results-section" class="results-section hidden">
|
47 |
<div class="results-header">
|
48 |
-
<h3>
|
49 |
<div class="selection-controls">
|
50 |
<button id="select-all" class="control-btn">
|
51 |
<span class="material-icons">select_all</span>
|
52 |
-
|
53 |
</button>
|
54 |
<button id="unselect-all" class="control-btn">
|
55 |
<span class="material-icons">deselect</span>
|
56 |
-
|
57 |
</button>
|
58 |
</div>
|
59 |
</div>
|
@@ -61,7 +61,7 @@
|
|
61 |
<div class="chat-launch">
|
62 |
<button id="start-chat" class="chat-btn" disabled>
|
63 |
<span class="material-icons">chat</span>
|
64 |
-
|
65 |
</button>
|
66 |
</div>
|
67 |
</section>
|
@@ -72,16 +72,16 @@
|
|
72 |
<h3>ChatBot Assistant</h3>
|
73 |
<button id="back-to-search" class="back-btn">
|
74 |
<span class="material-icons">arrow_back</span>
|
75 |
-
|
76 |
</button>
|
77 |
</div>
|
78 |
<div class="chat-container">
|
79 |
<div id="chat-messages" class="chat-messages"></div>
|
80 |
<form id="chat-form" class="chat-form">
|
81 |
<div class="chat-input-group">
|
82 |
-
<input type="text" id="chat-input" placeholder="
|
83 |
<select id="model-select">
|
84 |
-
<option value="gemini-2.5-flash
|
85 |
<option value="gemini-2.0-flash">Gemini 2.0 Flash</option>
|
86 |
<option value="gemma-3-27b-it">Gemma 3</option>
|
87 |
<option value="gemma-3n-e4b-it">Gemma 3n</option>
|
@@ -111,7 +111,7 @@
|
|
111 |
<!-- Loading overlay -->
|
112 |
<div id="loading" class="loading hidden">
|
113 |
<div class="spinner"></div>
|
114 |
-
<p>
|
115 |
</div>
|
116 |
|
117 |
<script src="/static/script.js"></script>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>RAGnarok | Chat with the specs</title>
|
7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
9 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
|
|
16 |
<header class="header">
|
17 |
<div class="logo">
|
18 |
<span class="material-icons">search</span>
|
19 |
+
<h1>RAGnarok - Chat with the specs</h1>
|
20 |
</div>
|
21 |
</header>
|
22 |
|
23 |
<!-- Search Section -->
|
24 |
<section id="search-section" class="search-section">
|
25 |
<div class="search-container">
|
26 |
+
<h2>Search specifications</h2>
|
27 |
<form id="search-form" class="search-form">
|
28 |
<div class="input-group">
|
29 |
<input type="text" id="keyword" placeholder="Entrez vos mots-clés..." required>
|
30 |
<span class="material-icons">search</span>
|
31 |
</div>
|
32 |
<div class="threshold-group">
|
33 |
+
<label for="threshold">Similarity Threshold :</label>
|
34 |
<input type="range" id="threshold" min="0" max="100" step="1" value="70">
|
35 |
<span id="threshold-value"></span>
|
36 |
</div>
|
37 |
<button type="submit" class="search-btn">
|
38 |
<span class="material-icons">search</span>
|
39 |
+
Search
|
40 |
</button>
|
41 |
</form>
|
42 |
</div>
|
|
|
45 |
<!-- Results Section -->
|
46 |
<section id="results-section" class="results-section hidden">
|
47 |
<div class="results-header">
|
48 |
+
<h3>Search result</h3>
|
49 |
<div class="selection-controls">
|
50 |
<button id="select-all" class="control-btn">
|
51 |
<span class="material-icons">select_all</span>
|
52 |
+
Select All
|
53 |
</button>
|
54 |
<button id="unselect-all" class="control-btn">
|
55 |
<span class="material-icons">deselect</span>
|
56 |
+
Unselect All
|
57 |
</button>
|
58 |
</div>
|
59 |
</div>
|
|
|
61 |
<div class="chat-launch">
|
62 |
<button id="start-chat" class="chat-btn" disabled>
|
63 |
<span class="material-icons">chat</span>
|
64 |
+
Unleash the RAGnarok !
|
65 |
</button>
|
66 |
</div>
|
67 |
</section>
|
|
|
72 |
<h3>ChatBot Assistant</h3>
|
73 |
<button id="back-to-search" class="back-btn">
|
74 |
<span class="material-icons">arrow_back</span>
|
75 |
+
Return to search
|
76 |
</button>
|
77 |
</div>
|
78 |
<div class="chat-container">
|
79 |
<div id="chat-messages" class="chat-messages"></div>
|
80 |
<form id="chat-form" class="chat-form">
|
81 |
<div class="chat-input-group">
|
82 |
+
<input type="text" id="chat-input" placeholder="Enter your query here ..." required>
|
83 |
<select id="model-select">
|
84 |
+
<option value="gemini-2.5-flash">Gemini 2.5 Flash</option>
|
85 |
<option value="gemini-2.0-flash">Gemini 2.0 Flash</option>
|
86 |
<option value="gemma-3-27b-it">Gemma 3</option>
|
87 |
<option value="gemma-3n-e4b-it">Gemma 3n</option>
|
|
|
111 |
<!-- Loading overlay -->
|
112 |
<div id="loading" class="loading hidden">
|
113 |
<div class="spinner"></div>
|
114 |
+
<p>Searching ...</p>
|
115 |
</div>
|
116 |
|
117 |
<script src="/static/script.js"></script>
|