File size: 1,955 Bytes
967ec2e 56d50b0 c155fff 56d50b0 c155fff 56d50b0 f92563c 56d50b0 1a3e788 c155fff 56d50b0 32f7fd8 f92563c 56d50b0 a9e751b 56d50b0 32f7fd8 56d50b0 32f7fd8 c155fff 967ec2e |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Intégration API Gradio avec Bootstrap</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js"></script>
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-12">
<input type="text" id="question" class="form-control" placeholder="Entrez votre question ici">
</div>
<div class="col-12 mt-3">
<button onclick="getResponse()" class="btn btn-primary">Soumettre</button>
<div id="spinner" class="spinner-border text-primary" role="status" style="display: none;">
<span class="sr-only">Chargement...</span>
</div>
</div>
<div class="col-12 mt-3">
<div id="response" class="border p-3"></div>
</div>
</div>
</div>
<script type="module">
import { client } from "@gradio/client";
async function getResponse() {
const spinner = document.getElementById('spinner');
const responseDiv = document.getElementById('response');
// Afficher le spinner et effacer la réponse précédente
spinner.style.display = 'inline-block';
responseDiv.innerHTML = '';
const question = document.getElementById('question').value;
const app = await client("https://docfile-gemi.hf.space/--replicas/p1sej/");
const result = await app.predict("/predict", [question]);
const converter = new showdown.Converter();
const html = converter.makeHtml(result.data);
// Mettre à jour la réponse et masquer le spinner
responseDiv.innerHTML = html;
spinner.style.display = 'none';
}
</script>
</body>
</html>
|