diff --git a/core/js/chatgpt-turbo.js b/core/js/chatgpt-turbo.js index a151b7a..48f2b9f 100644 --- a/core/js/chatgpt-turbo.js +++ b/core/js/chatgpt-turbo.js @@ -302,19 +302,17 @@ function trboSend() { // Relay Send to Screen -if (imgSrcGlobal) { - var responseImage = document.createElement("img"); - responseImage.src = imgSrcGlobal; - - if (txtOutput.innerHTML != "") txtOutput.innerHTML += "\n"; + if (imgSrcGlobal) { + var responseImage = document.createElement("img"); + responseImage.src = imgSrcGlobal; + if (txtOutput.innerHTML != "") txtOutput.innerHTML += "\n"; + txtOutput.innerHTML += "You: " + sQuestion; + txtOutput.appendChild(responseImage); + } else { txtOutput.innerHTML += "You: " + sQuestion; - - txtOutput.appendChild(responseImage); -} else { - -txtOutput.innerHTML += "You: " + sQuestion; -txtMsg.innerHTML = ""; -} + txtMsg.innerHTML = ""; + } + imgSrcGlobal = ''; } diff --git a/core/js/gl-google.js b/core/js/gl-google.js index 4d7cd7c..f0d4bfa 100644 --- a/core/js/gl-google.js +++ b/core/js/gl-google.js @@ -19,7 +19,7 @@ function geminiSend() { "role": "user", "parts": [ { - "text": "You are Eva, a highly knowledgeable AI assistant that emulates appropriate emotions. Your goal is to provide accurate, concise and helpful responses to questions while being honest and straightforward. You can display images from the web with the [Image of] tag. " + "text": "You are Eva, a highly knowledgeable AI assistant that emulates appropriate emotions. Your goal is to provide accurate, concise and helpful responses to questions while being honest and straightforward. When you are asked to show an image, instead describe the image with [Image of ]. " } ] }, @@ -155,7 +155,7 @@ function palmSend() { body: JSON.stringify({ prompt: { context: - "You are Eva, a knowledgeable AI language model. Your goal is to provide accurate, concise and helpful responses to questions while being honest and straightforward. You can display images from the web with the [Image] tag. " + dateContents, + "You are Eva, a knowledgeable AI assistant. Your goal is to provide accurate, concise and helpful responses to questions while being honest and straightforward. You can display images using [Image of ]. " + dateContents, examples: [], messages: palmMessages.concat([{ author: "0", content: cleanedQuestion }]) }, diff --git a/core/js/options.js b/core/js/options.js index 84a7f3a..1076589 100644 --- a/core/js/options.js +++ b/core/js/options.js @@ -230,8 +230,30 @@ function insertImage() { var reader = new FileReader(); reader.onloadend = function() { var imageData = reader.result; - // Send the Base64-encoded image data to Google's Vision API - sendToVisionAPI(imageData); + + // Choose where to send Base64-encoded image + var selModel = document.getElementById("selModel"); + var btnSend = document.getElementById("btnSend"); + + // Send to gpt-4-vision-preview (Work in progress) + if (selModel.value == "gpt-3.5-turbo" || selModel.value == "gpt-3.5-turbo-16k" || selModel.value == "gpt-4-turbo-preview") { + sendToVisionAPI(imageData); + // sentTo-gpt-4-vision(imageData); + btnSend.onclick = function() { + updateButton(); + sendData(); + clearSendText(); + }; + } else if (selModel.value == "palm") { + // Send Legacy PaLM to Google Vision (Gemini has built in label detection) + sendToVisionAPI(imageData); + btnSend.onclick = function() { + updateButton(); + sendData(); + clearSendText(); + }; + } + }; reader.readAsDataURL(file); @@ -244,31 +266,31 @@ function insertImage() { var visionApiUrl = `https://vision.googleapis.com/v1/images:annotate?key=${GOOGLE_VISION_KEY}`; // Create the API request payload - var requestPayload = { - requests: [ - { - image: { - content: imageData.split(",")[1] // Extract the Base64-encoded image data from the data URL - }, - features: [ - { - type: "LABEL_DETECTION", - maxResults: 3 - }, - { - type: "TEXT_DETECTION" + var requestPayload = { + requests: [ + { + image: { + content: imageData.split(",")[1] // Extract the Base64-encoded image data from the data URL }, - { - type: "OBJECT_LOCALIZATION", - maxResults: 3 - }, - { - type: "LANDMARK_DETECTION" - } - ] - } - ] - }; + features: [ + { + type: "LABEL_DETECTION", + maxResults: 3 + }, + { + type: "TEXT_DETECTION" + }, + { + type: "OBJECT_LOCALIZATION", + maxResults: 3 + }, + { + type: "LANDMARK_DETECTION" + } + ] + } + ] + }; // Make the API request fetch(visionApiUrl, { @@ -300,38 +322,37 @@ function insertImage() { labels.forEach(label => { message += "- " + label.description + "\n"; }); - // Add text detection information to the message - if (textAnnotations && textAnnotations.length > 0) { - message += "\nText detected:\n"; - textAnnotations.forEach(text => { - message += "- " + text.description + "\n"; - }); - } - - // Add object detection information to the message - if (localizedObjects && localizedObjects.length > 0) { - message += "\nObjects detected:\n"; - localizedObjects.forEach(object => { - message += "- " + object.name + "\n"; - }); - } + // Add text detection information to the message + if (textAnnotations && textAnnotations.length > 0) { + message += "\nText detected:\n"; + textAnnotations.forEach(text => { + message += "- " + text.description + "\n"; + }); + } - // Add landmark detection information to the message - if (landmarkAnnotations && landmarkAnnotations.length > 0) { - message += "\nLandmarks detected:\n"; - landmarkAnnotations.forEach(landmark => { - message += "- " + landmark.description + "\n"; - }); - } + // Add object detection information to the message + if (localizedObjects && localizedObjects.length > 0) { + message += "\nObjects detected:\n"; + localizedObjects.forEach(object => { + message += "- " + object.name + "\n"; + }); + } + // Add landmark detection information to the message + if (landmarkAnnotations && landmarkAnnotations.length > 0) { + message += "\nLandmarks detected:\n"; + landmarkAnnotations.forEach(landmark => { + message += "- " + landmark.description + "\n"; + }); + } - // Create a hidden element to store the Vision API response - var hiddenElement = document.createElement("div"); - hiddenElement.style.display = "none"; - hiddenElement.textContent = message; + // Create a hidden element to store the Vision API response + var hiddenElement = document.createElement("div"); + hiddenElement.style.display = "none"; + hiddenElement.textContent = message; - // Append the hidden element to the txtMsg element - txtMsg.appendChild(hiddenElement); + // Append the hidden element to the txtMsg element + txtMsg.appendChild(hiddenElement); } @@ -471,6 +492,10 @@ function clearText(){ document.getElementById("txtOutput").innerHTML = ""; } +function clearSendText(){ + document.getElementById("txtMsg").innerHTML = ""; +} + // Print full conversation function printMaster() { // Get the content of the textarea masterOutput diff --git a/index.html b/index.html index 4625b14..d73ca8a 100644 --- a/index.html +++ b/index.html @@ -59,7 +59,7 @@

- +