Docfile commited on
Commit
b34f4ff
·
verified ·
1 Parent(s): 32f7fd8

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +162 -36
index.html CHANGED
@@ -1,50 +1,176 @@
1
  <!DOCTYPE html>
2
- <html>
3
  <head>
4
- <title>Intégration API Gradio avec Bootstrap</title>
5
- <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
6
- <script src="https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
- <div class="container mt-5">
10
- <div class="row">
11
- <div class="col-12">
12
- <input type="text" id="question" class="form-control" placeholder="Entrez votre question ici">
13
- </div>
14
- <div class="col-12 mt-3">
15
- <button onclick="getResponse()" class="btn btn-primary">Soumettre</button>
16
- <div id="spinner" class="spinner-border text-primary" role="status" style="display: none;">
17
- <span class="sr-only">Chargement...</span>
18
- </div>
19
- </div>
20
- <div class="col-12 mt-3">
21
- <div id="response" class="border p-3"></div>
 
 
 
22
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  </div>
 
25
 
26
- <script type="module">
27
- import { client } from "@gradio/client";
 
 
28
 
29
- async function getResponse() {
30
- const spinner = document.getElementById('spinner');
31
- const responseDiv = document.getElementById('response');
 
 
32
 
33
- // Afficher le spinner et effacer la réponse précédente
34
- spinner.style.display = 'inline-block';
35
- responseDiv.innerHTML = '';
 
 
 
 
 
 
 
36
 
37
- const question = document.getElementById('question').value;
38
- const app = await client("https://docfile-gemi.hf.space/--replicas/p1sej/");
39
- const result = await app.predict("/predict", [question]);
 
 
40
 
41
- const converter = new showdown.Converter();
42
- const html = converter.makeHtml(result.data);
 
 
43
 
44
- // Mettre à jour la réponse et masquer le spinner
45
- responseDiv.innerHTML = html;
46
- spinner.style.display = 'none';
47
- }
48
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  </body>
50
- </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="fr">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Chatbot Islamique</title>
7
+ <!-- Lien vers la bibliothèque Bootstrap -->
8
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
9
+ <!-- Lien vers la bibliothèque Font Awesome -->
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
11
+ <style>
12
+ /* ... (autres styles CSS) ... */
13
+
14
+ /* Suggestions de questions */
15
+ #suggestions {
16
+ margin-top: 20px;
17
+ }
18
+
19
+ .suggestion {
20
+ display: inline-block;
21
+ margin: 5px;
22
+ cursor: pointer;
23
+ color: #007bff;
24
+ }
25
+
26
+ /* Icône */
27
+ .icon {
28
+ font-size: 36px;
29
+ margin-right: 10px;
30
+ }
31
+
32
+ /* Mode sombre */
33
+ body.dark-mode {
34
+ background-color: #343a40;
35
+ color: white;
36
+ }
37
+
38
+ /* Animation de chargement */
39
+ .loader {
40
+ border: 4px solid #f3f3f3;
41
+ border-top: 4px solid #3498db;
42
+ border-radius: 50%;
43
+ width: 20px;
44
+ height: 20px;
45
+ animation: spin 2s linear infinite;
46
+ }
47
+
48
+ @keyframes spin {
49
+ 0% { transform: rotate(0deg); }
50
+ 100% { transform: rotate(360deg); }
51
+ }
52
+ </style>
53
  </head>
54
  <body>
55
+ <div class="container">
56
+ <div class="card mt-5">
57
+ <div class="card-header">
58
+ <span class="icon">&#9776;</span> YouTube Text Extractor
59
+ </div>
60
+ <div class="card-body">
61
+ <div class="text-center">
62
+ <strong>V :</strong>
63
+ <p id="randomNumber" class="mt-2"></p>
64
+ </div>
65
+ <div class="form-group mt-4">
66
+ <label for="question">Link :</label>
67
+ <div class="input-group">
68
+ <textarea class="form-control" id="question" rows="3" placeholder="Entrez votre question"></textarea>
69
+ <div class="input-group-append">
70
+ <button class="btn btn-outline-secondary" type="button" id="clearBtn"><i class="fas fa-times"></i></button>
71
  </div>
72
+ </div>
73
+ </div>
74
+ <div class="text-center">
75
+ <button type="button" class="btn btn-primary" id="submitBtn">Obtenir la réponse</button>
76
+ </div>
77
+ <div id="loading" class="text-center mt-4" style="display: none;">
78
+ <div class="spinner-border text-primary" role="status">
79
+ <span class="sr-only">Chargement...</span>
80
+ </div>
81
+ </div>
82
+ <div class="mt-4 text-center">
83
+ <strong>Réponse :</strong>
84
+ <p id="answer" class="mt-2"></p>
85
  </div>
86
+ </div>
87
+ </div>
88
+
89
+ <div id="suggestions">
90
+ <strong>Suggestions :</strong>
91
+ <div class="suggestion">https://youtu.be/i0E3Vsz-Y7Q?si=y22asNjKrvN8UYAj?</div>
92
+ <div class="suggestion">https://youtu.be/82KLS2C_gNQ?si=fubHTocMBQeP_P5D</div>
93
+
94
+ <!-- Ajoutez plus de suggestions ici -->
95
+ </div>
96
+
97
+ <div id="about" class="mt-5">
98
+ <h2>À Propos </h2> <p> Cette app a été créée par Youssouf pour bref le titre est simple. Bon maintenant si tu ne comprends pas pends toi . </p>
99
  </div>
100
+ </div>
101
 
102
+ <!-- Lien vers la bibliothèque jQuery -->
103
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
104
+ <!-- Lien vers la bibliothèque Bootstrap JavaScript -->
105
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
106
 
107
+ <script>
108
+ // Fonction pour insérer une suggestion de question dans le champ de saisie
109
+ function insertSuggestion(suggestion) {
110
+ document.getElementById('question').value = suggestion;
111
+ }
112
 
113
+ // Gestion du clic sur une suggestion de question
114
+ document.addEventListener('DOMContentLoaded', function() {
115
+ const suggestions = document.querySelectorAll('.suggestion');
116
+ suggestions.forEach(suggestion => {
117
+ suggestion.addEventListener('click', function() {
118
+ const question = suggestion.innerText;
119
+ insertSuggestion(question);
120
+ });
121
+ });
122
+ });
123
 
124
+ // Gestion du clic sur le bouton de soumission
125
+ document.getElementById('submitBtn').addEventListener('click', function() {
126
+ const question = document.getElementById('question').value;
127
+ getAnswer(question);
128
+ });
129
 
130
+ // Gestion du clic sur le bouton pour effacer le contenu du champ de saisie
131
+ document.getElementById('clearBtn').addEventListener('click', function() {
132
+ document.getElementById('question').value = '';
133
+ });
134
 
135
+ // ... (autre code JavaScript)
136
+ // Fonction pour obtenir la réponse à partir de la question en utilisant l'API
137
+ function getAnswer(question) {
138
+ // Afficher l'indicateur de chargement
139
+ document.getElementById('loading').style.display = 'block';
140
+ // Masquer la réponse précédente
141
+ document.getElementById('answer').innerHTML = '';
142
+ fetch('https://docfile-gemi.hf.space/run/predict', {
143
+ method: 'POST',
144
+ headers: {
145
+ 'Content-Type': 'application/json'
146
+ },
147
+ body: JSON.stringify({
148
+ data: [question]
149
+ })
150
+ })
151
+ .then(response => response.json())
152
+ .then(data => {
153
+ var answer = data.data[0];
154
+ document.getElementById('answer').innerHTML = answer;
155
+ })
156
+ .catch(error => {
157
+ console.error('Une erreur s\'est produite :', error);
158
+ })
159
+ .finally(() => {
160
+ // Masquer l'indicateur de chargement après avoir reçu la réponse
161
+ document.getElementById('loading').style.display = 'none';
162
+ });
163
+ }
164
+ // Générer et afficher le nombre aléatoire au chargement du site
165
+ document.addEventListener('DOMContentLoaded', function() {
166
+ var randomNumber = Math.floor(Math.random() * 19) + 2;
167
+ document.getElementById('randomNumber').innerHTML = randomNumber;
168
+ });
169
+ // Fonction pour gérer le clic sur le bouton de soumission
170
+ document.getElementById('submitBtn').addEventListener('click', function() {
171
+ var question = document.getElementById('question').value;
172
+ getAnswer(question);
173
+ });
174
+ </script>
175
  </body>
176
+ </html>