about summary refs log tree commit diff stats
path: root/html/matt-chat
diff options
context:
space:
mode:
Diffstat (limited to 'html/matt-chat')
-rw-r--r--html/matt-chat/index.html48
1 files changed, 34 insertions, 14 deletions
diff --git a/html/matt-chat/index.html b/html/matt-chat/index.html
index d987f21..391bb95 100644
--- a/html/matt-chat/index.html
+++ b/html/matt-chat/index.html
@@ -200,16 +200,35 @@
 
         let isCatMode = false; // Flag to track cat mode
 
-        function populateModelSelect() {
+        async function populateModelSelect() {
             const modelSelect = document.getElementById("model-select");
             modelSelect.innerHTML = ""; // Clear existing options
 
-            config.models.forEach(model => {
-                const option = document.createElement("option");
-                option.value = model.value;
-                option.textContent = model.label;
-                modelSelect.appendChild(option);
-            });
+            try {
+                const response = await fetch("http://localhost:11434/v1/models"); // Adjust the endpoint as needed
+                if (!response.ok) {
+                    throw new Error('Failed to fetch models');
+                }
+                const data = await response.json(); // Get the JSON response
+
+                console.log("API Response:", data); // Log the response for debugging
+
+                // Check if the response contains a data array
+                if (Array.isArray(data.data)) { // Access the data array
+                    data.data.forEach(model => {
+                        const option = document.createElement("option");
+                        option.value = model.id; // Use the id from the model
+                        option.textContent = model.id; // Use the id for display (you can customize this)
+                        modelSelect.appendChild(option);
+                    });
+                } else {
+                    console.error("Expected an array of models, but got:", data);
+                    addMessage("Error: Expected an array of models, but got an unexpected response.", "bot");
+                }
+            } catch (error) {
+                console.error("Error fetching models:", error);
+                addMessage("Error fetching models. Please check the console for details.", "bot");
+            }
         }
 
         document.addEventListener("DOMContentLoaded", () => {
@@ -292,7 +311,7 @@
             if (!userMessage) return;
 
             // Check for slash commands
-            if (userMessage.toLowerCase() === '/darkmode') {
+            if (userMessage.toLowerCase() === '/dark' || userMessage.toLowerCase() === '/darkmode') {
                 toggleDarkMode();
                 userInput.value = ""; // Clear input after command
                 updateCounter(); // Reset counters
@@ -313,7 +332,7 @@
                 return;
             }
 
-            if (userMessage.toLowerCase() === '/cat') {
+            if (userMessage.toLowerCase() === '/cat' || userMessage.toLowerCase() === '/catmode') {
                 toggleCatMode(); // Toggle cat mode
                 userInput.value = ""; // Clear input after command
                 updateCounter(); // Reset counters
@@ -475,11 +494,12 @@
 
         function displayHelp() {
             const helpMessage = `
-                Available commands:\n
-                /darkmode - Toggle dark mode
-                /cat - Toggle cat mode
-                /clear - Clear the chat history
-                /help - Show this message
+Available commands:\n
+  /darkmode - Toggle dark mode
+  /cat - Toggle cat mode
+  /context - Show the current conversation's context
+  /clear - Clear the chat history
+  /help - Show this message
             `;
             addMessage(helpMessage, "bot"); // Display help message as a bot message
         }