You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught TypeError: El especificador “ollama” era un especificador básico, pero no se reasignó a nada. Los especificadores de módulos relativos deben comenzar con “./”, “../” o “/”. ollamaCode.js:1:20
Uncaught SyntaxError: import declarations may only appear at top level of a module
importollamafrom'ollama';exportasyncfunctiongetOllamaResponse(){constresponse=awaitollama.chat({model: 'llama3',messages: [{role: 'user',content: 'Why is the sky blue?'}],});console.log(response.message.content);console.log("HOLA");return"hola";}getOllamaResponse();
chatboxscript.js
import{getOllamaResponse}from"./ollamaCode.js";constchatbotSettings={chatbotIconPath: "../img/chatbot/chatbot-icon.redimensionado.png",chatbotCloseIconPath: "../img/chatbot/close-icon.redimensionado.jpg",chatbotSendMessageIconPath: "../img/chatbot/send-button.redimensionado.png",chatbotMessageUserIcon: "../img/chatbot/usericons/customersupportman.redimensionado.png",chatbotMessageAssistantIcon: "../img/chatbot/assistanticons/robotassistant2.redimensionado.png",chatbotHeaderTitle: "Asistente de Caparrella",chatbotName: "CapaBot",}/** Configuración de la interfaz del chatbot */functionsetChatbotSettings(){// Assuming the image has an ID attribute of "myImage"constimageIcon=document.getElementById("chat-icon");imageIcon.src=chatbotSettings.chatbotIconPath;// Assuming the image has an ID attribute of "myImage"constimageCloseIcon=document.getElementById("close-icon");imageCloseIcon.src=chatbotSettings.chatbotCloseIconPath;// Assuming the image has an ID attribute of "myImage"constimageSendMessageIcon=document.getElementById("send-button");imageSendMessageIcon.src=chatbotSettings.chatbotSendMessageIconPath;// Assuming the image has an ID attribute of "myImage"document.getElementById("chatbotTitle").innerHTML=chatbotSettings.chatbotHeaderTitle;}setChatbotSettings();// Función para mostrar u ocultar el chatfunctiontoggleChat(){constchatboxBody=document.getElementById("chatbox-body");if(chatboxBody.style.display==="none"||chatboxBody.style.display===""){chatboxBody.style.display="block";//Limpiar input text}else{chatboxBody.style.display="none";}}functioncloseAssistant(){toggleChat();}// La versión moderna const closeAssistant = () => toggleChat();// Función para manejar el presionar "Enter" en el inputconstuserInput=document.getElementById('user-input');// Añade un listener para detectar cuando se presiona una teclauserInput.addEventListener('keydown',function(event){// Verifica si la tecla presionada es 'Enter' (código de tecla 13)if(event.key==='Enter'){sendMessage();}});// Función para manejar el envío de mensajesfunctionsendMessage(){constuserInput=document.getElementById("user-input").value;if(userInput.trim()!==""){displayMessage(userInput,'user');// Muestra el mensaje del usuariodocument.getElementById("user-input").value='';// Limpia el campo de entradagetAssistantResponse(userInput);// Obtiene la respuesta del asistente}}// Función para mostrar los mensajes en el chatfunctiondisplayMessage(message,sender){constchatBoxMesages=document.getElementById("chat-messages");constmessageElement=document.createElement("div");messageElement.classList.add("chat-messages",sender);letaddHTML='';if(sender==='user'){messageElement.style.textAlign="right";addHTML=` <div class="message-text-user">User</div> <div class="message-icon-user"><img src=${chatbotSettings.chatbotMessageUserIcon} alt="user-icon"></div> <div class="message-text-user">${message}</div>`}elseif(sender==='assistant'){messageElement.style.textAlign="left";addHTML=` <div class="message-text-user">${chatbotSettings.chatbotName}</div> <div class="message-icon-assistant"><img src=${chatbotSettings.chatbotMessageAssistantIcon} alt="user-assistant"></div> <div class="message-text-assistant">${message}</div>`;}else{console.log("Error en el sender");}messageElement.innerHTML=addHTML;chatBoxMesages.appendChild(messageElement);chatBoxMesages.scrollTop=chatBoxMesages.scrollHeight;}/*function getAssistantResponseStream(userMessage) { const message = {role: 'user', content: `${userMessage}`} const response = await ollama.chat({model: 'llama3.1', messages: [message], stream: true}) for await (const part of response) { process.stdout.write(part.message.content) }}*//*<div class="icon">${sender === 'user' ? '👤' : '🤖'}</div>*/// Función para obtener la respuesta del asistente usando la API de OllamafunctiongetAssistantResponse(userMessage){constmessageResponse=getOllamaResponse(userMessage);// const messageResponse ="hola";displayMessage(messageResponse,"assistant");}
and html
<!doctype html><htmlclass="no-js" lang=""><head><metacharset="utf-8"><metacontent="width=device-width, initial-scale=1" name="viewport"><title></title><linkhref="css/style.css" rel="stylesheet"><linkhref="css/chatbotstyle.css" rel="stylesheet"><metacontent="" name="description"><metacontent="" property="og:title"><metacontent="" property="og:type"><metacontent="" property="og:url"><metacontent="" property="og:image"><metacontent="" property="og:image:alt"><linkhref="/favicon.ico" rel="icon" sizes="any"><linkhref="/icon.svg" rel="icon" type="image/svg+xml"><linkhref="icon.png" rel="apple-touch-icon"><linkhref="site.webmanifest" rel="manifest"><metacontent="#fafafa" name="theme-color"><!-- Si usamos async para cargar la biblioteca "p5.js", el navegador ejecutará ese archivo inmediatamente cuando termine de cargarlo. That will make the variable p5 globally available. --><scriptsrc="js/libraries/p5.min.js"></script><scriptsrc="js/sketchpacman.js" type="module"></script><scriptsrc="js/sketch.mjs" type="module"></script><scriptsrc="js/secondsketch.mjs" type="module"></script><scriptdefertype="module" src="js/ollamaCode.js"></script><scriptdefersrc="js/chatbotscript.js"></script><!-- <script type="module" src="js/classes/Rectangle.mjs"></script>--></head><body><!-- Add your site or application content here --><p>Hello world! This is HTML5 Boilerplate.</p><divid="sketch-pacman"></div><p>Hello world! This is HTML5 Boilerplate.</p><divid="first-sketch-holder"></div><p>Hello world! This is HTML5 Boilerplate.</p><divid="second-sketch-holder"></div><divid="chatbox-container"><!-- Icono de ayuda --><inputtype="image" id="chat-icon" class="chat-icon" onclick="toggleChat()" alt="Icon of the Assistant"/><!-- Ventana del chat --><divid="chatbox-body" class="chatbox-body" ><!-- Header del chatbox --><divclass="chat-header"><spanid="chatbotTitle"></span><inputtype="image" id="close-icon" onclick="closeAssistant()" alt ="Button Close"/></div><!-- Mensajes del chatbox --><divid="chat-messages" class="chat-messages" ></div><!-- Div con el input text y boton enviar --><divclass="chat-input-container"><labelfor="user-input"></label><inputtype="text" id="user-input" placeholder="Escribe tu mensaje..." /><inputtype="image" id="send-button" onclick="sendMessage()" alt ="Button send message"/></div></div></div></body></html>
`
Any help would be apreciated
I m developing on linux, with local webstorm server http://localhost:63342/, npm i ollama was 0.5.11....and llama3 is running in ollama server
chatbotscript.js fails if i put typemodule because toggleChat() error Reference, but the code is ok, i thin its related with ollama
Im a teacher on vocational education in computer science and we are stuck
The text was updated successfully, but these errors were encountered:
Uncaught TypeError: El especificador “ollama” era un especificador básico, pero no se reasignó a nada. Los especificadores de módulos relativos deben comenzar con “./”, “../” o “/”. ollamaCode.js:1:20
Uncaught SyntaxError: import declarations may only appear at top level of a module
Made npm i ollama ( perhaps before i made pnpm i ollama)
Im running llama3 llm in http://127.0.0.1:11434/ -> ollama is running
http://127.0.0.1:11434/chat and http://127.0.0.1:11434/api got 404 error
i have in terminal also running the ollama.
ollamaCode.js:
chatboxscript.js
and html
`
Any help would be apreciated
I m developing on linux, with local webstorm server http://localhost:63342/, npm i ollama was 0.5.11....and llama3 is running in ollama server
chatbotscript.js fails if i put typemodule because toggleChat() error Reference, but the code is ok, i thin its related with ollama
Im a teacher on vocational education in computer science and we are stuck
The text was updated successfully, but these errors were encountered: