http://localhost:11434 Aucune clé API n’est requise.
Browse filesVeuillez démarrer votre instance locale pour activer l’intelligence artificielle.
- ai-adapter.js +2 -2
- app.js +26 -5
- style.css +11 -0
ai-adapter.js
CHANGED
|
@@ -17,8 +17,8 @@ async function callAI(prompt) {
|
|
| 17 |
if (!available) {
|
| 18 |
return {
|
| 19 |
status: "offline",
|
| 20 |
-
text: "Ollama
|
| 21 |
-
|
| 22 |
};
|
| 23 |
}
|
| 24 |
// Case 2: Ollama running
|
|
|
|
| 17 |
if (!available) {
|
| 18 |
return {
|
| 19 |
status: "offline",
|
| 20 |
+
text: "Ollama n'est pas détecté sur http://localhost:11434\n\n1. Téléchargez Ollama: https://ollama.com/download\n2. Installez et lancez l'application\n3. Dans un terminal, exécutez: ollama serve\n4. Configurez l'URL dans les paramètres\n\nAucune clé API n'est requise - tout fonctionne localement",
|
| 21 |
+
type: 'text'
|
| 22 |
};
|
| 23 |
}
|
| 24 |
// Case 2: Ollama running
|
app.js
CHANGED
|
@@ -29,11 +29,32 @@ async function sendPrompt() {
|
|
| 29 |
try {
|
| 30 |
const result = await callAI(input.value);
|
| 31 |
const formattedText = result.text.replace(/\n/g, '<br>');
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
// Clear input
|
| 38 |
input.value = '';
|
| 39 |
} catch (error) {
|
|
|
|
| 29 |
try {
|
| 30 |
const result = await callAI(input.value);
|
| 31 |
const formattedText = result.text.replace(/\n/g, '<br>');
|
| 32 |
+
if (result.status === "offline") {
|
| 33 |
+
preview.innerHTML = `
|
| 34 |
+
<div class="bg-gray-700 p-4 rounded-lg">
|
| 35 |
+
<h4 class="font-medium text-red-400 mb-2 flex items-center">
|
| 36 |
+
<i data-feather="alert-triangle" class="mr-2"></i>
|
| 37 |
+
Ollama non détecté
|
| 38 |
+
</h4>
|
| 39 |
+
<div class="text-sm space-y-2">
|
| 40 |
+
${formattedText}
|
| 41 |
+
</div>
|
| 42 |
+
<button
|
| 43 |
+
onclick="showSettings()"
|
| 44 |
+
class="mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm transition-colors"
|
| 45 |
+
>
|
| 46 |
+
<i data-feather="settings" class="w-4 h-4 mr-2"></i>
|
| 47 |
+
Configurer Ollama
|
| 48 |
+
</button>
|
| 49 |
+
</div>
|
| 50 |
+
`;
|
| 51 |
+
} else {
|
| 52 |
+
preview.innerHTML = `
|
| 53 |
+
<div class="ai-output">
|
| 54 |
+
${formattedText}
|
| 55 |
+
</div>
|
| 56 |
+
`;
|
| 57 |
+
}
|
| 58 |
// Clear input
|
| 59 |
input.value = '';
|
| 60 |
} catch (error) {
|
style.css
CHANGED
|
@@ -68,6 +68,17 @@ body {
|
|
| 68 |
line-height: 1.5;
|
| 69 |
}
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
#previewBox .text-sm {
|
| 72 |
line-height: 1.5;
|
| 73 |
}
|
|
|
|
| 68 |
line-height: 1.5;
|
| 69 |
}
|
| 70 |
|
| 71 |
+
.bg-gray-700 {
|
| 72 |
+
background-color: #374151;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.text-red-400 {
|
| 76 |
+
color: #f87171;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.text-sm {
|
| 80 |
+
font-size: 0.875rem;
|
| 81 |
+
}
|
| 82 |
#previewBox .text-sm {
|
| 83 |
line-height: 1.5;
|
| 84 |
}
|