diff --git a/1.html b/1.html new file mode 100644 index 0000000..1ac9991 --- /dev/null +++ b/1.html @@ -0,0 +1,112 @@ + + + + Chat Interface + + + +
+
+
+ Hey, how can I help you? +
+
+
+
+ I'm an AI assistant. How can I assist you today? +
+
+ + +
+ + +
+
+ + + + + diff --git a/core/external/date.data b/core/external/date.data new file mode 100644 index 0000000..2435a43 --- /dev/null +++ b/core/external/date.data @@ -0,0 +1 @@ +Today's date: Saturday, May 20th, 2023 diff --git a/core/external/external.data b/core/external/external.data new file mode 100644 index 0000000..385c8a6 --- /dev/null +++ b/core/external/external.data @@ -0,0 +1,15 @@ +Today's date: Sunday, March 26th, 2023 +Weather for San Antonio, Texas: Overcast 64°F +The SPY ticker price is: 395.75 +Top 5 news headlines: +New tornadoes menace Georgia as Biden approves disaster relief for Mississippi - ABC News +Russia plans to station tactical nuclear weapons in Belarus, Putin says - CNN +Trump treats himself after first 2024 rally speech in Waco – with McDonald’s - The Independent +Biden's FAA nominee bows out, after senators waver - POLITICO +12 injured in floor collapse at off-campus apartment party near Indiana University of Pennsylvania - CNN +Top 5 market headlines: +Intel co-founder Gordon Moore dies at 94. +Iovance Biotherapeutics completes license application submission for advanced melanoma therapy; shares rally. +McMahon agreed to reimburse WWE for investigation into misconduct allegations. +Softbank to merge with AI robotics company in which it had invested. +Rivian relocates engineers to Illinois factory, California HQ to increase production speedreport. diff --git a/externaldata.sh b/core/external/externaldata.sh old mode 100644 new mode 100755 similarity index 94% rename from externaldata.sh rename to core/external/externaldata.sh index b90472d..a829635 --- a/externaldata.sh +++ b/core/external/externaldata.sh @@ -1,7 +1,7 @@ #!/bin/bash # Set File Path -filepath=/var/www/html +filepath=/usr/share/nginx/html/core/external/ # Get today's date today=$(date +"%A, %B %dth, %Y") @@ -24,6 +24,7 @@ dow_price=$(curl -s "https://query1.finance.yahoo.com/v8/finance/chart/DOW?inter qyld_price=$(curl -s "https://query1.finance.yahoo.com/v8/finance/chart/QYLD?interval=1d" | jq -r '.chart.result[0].meta | "Price: \(.regularMarketPrice) Change: " + (100 * (.regularMarketPrice - .chartPreviousClose) / .chartPreviousClose | tostring | split(".") | .[0] + "." + .[1][:3]) + "%"') ryld_price=$(curl -s "https://query1.finance.yahoo.com/v8/finance/chart/RYLD?interval=1d" | jq -r '.chart.result[0].meta | "Price: \(.regularMarketPrice) Change: " + (100 * (.regularMarketPrice - .chartPreviousClose) / .chartPreviousClose | tostring | split(".") | .[0] + "." + .[1][:3]) + "%"') + # Marketpulse by Marketwatch.com marketpulse=$(curl -s "http://feeds.marketwatch.com/marketwatch/marketpulse/" | xmlstarlet sel -t -m "//item[position()<=5]" -v "title" -o $'\n' | sed 's/: *//g; s/$/./g') @@ -34,14 +35,14 @@ spaceweather=$(curl -s https://services.swpc.noaa.gov/products/alerts.json | jq # Write the data to external.data file # # -echo "Today's date: $today " > $filepath/date.data +echo "Today's date: $today" > $filepath/date.data -echo "Weather for San Antonio, Texas: $weather " > $filepath/weather.data +echo "Weather for San Antonio, Texas: $weather" > $filepath/weather.data -echo "Top 5 news headlines: " > $filepath/news.data +echo "Top 5 news headlines are: " > $filepath/news.data echo "$news " >> $filepath/news.data -echo "Top 5 market headlines: " > $filepath/market.data +echo "Top 5 market headlines are: " > $filepath/market.data echo "$marketpulse " >> $filepath/market.data echo "SPY ticker $spy_price " >> $filepath/market.data echo "GOLD ticker $gold_price " >> $filepath/market.data diff --git a/core/external/headlines.data b/core/external/headlines.data new file mode 100644 index 0000000..f8be802 --- /dev/null +++ b/core/external/headlines.data @@ -0,0 +1,12 @@ +Top 5 news headlines: +Covenant School shooter was under care for emotional disorder and hid guns at home, police say - CNN +Pence Must Testify to Jan. 6 Grand Jury, Judge Rules - The New York Times +At least 39 die in migrant center fire by U.S.-Mexico border - Los Angeles Times +Vice President Harris wiped away tears as she toured Ghana's Cape Coast slave castle - NPR +'Serial' murder case: Adnan Syed's conviction is reinstated - NBC News +Top 5 news headlines: +Covenant School shooter was under care for emotional disorder and hid guns at home, police say - CNN +Pence Must Testify to Jan. 6 Grand Jury, Judge Rules - The New York Times +At least 39 die in migrant center fire by U.S.-Mexico border - Los Angeles Times +Vice President Harris wiped away tears as she toured Ghana's Cape Coast slave castle - NPR +'Serial' murder case: Adnan Syed's conviction is reinstated - NBC News diff --git a/core/external/market.data b/core/external/market.data new file mode 100644 index 0000000..51322d4 --- /dev/null +++ b/core/external/market.data @@ -0,0 +1,16 @@ +Top 5 market headlines are: +American, JetBlue alliance blocked by judge. +U.S. stocks end lower, but Nasdaq posts longest weekly win streak since February. +Oil prices mark first weekly gain in 5 weeks; natural-gas futures end the week 14% higher. +Krystal Biotech stock rises after FDA approves treatment for rare skin disease. +Gold futures log biggest weekly loss in over 3 months. +SPY ticker Price: 418.62 Change: -0.145% +GOLD ticker Price: 17.86 Change: 0.280% +HMY ticker Price: 4.82 Change: -0.207% +WEAT ticker Price: 6.14 Change: -0.486% +ONL ticker Price: 5.9 Change: 0.340% +VET ticker Price: 12.05 Change: 1.687% +MMM ticker Price: 99.03 Change: -0.612% +DOW ticker Price: 51.95 Change: 0.154% +QYLD ticker Price: 17.57 Change: -0.340% +RYLD ticker Price: 18.09 Change: -1.255% diff --git a/core/external/news.data b/core/external/news.data new file mode 100644 index 0000000..496627f --- /dev/null +++ b/core/external/news.data @@ -0,0 +1,6 @@ +Top 5 news headlines are: +Ukraine's Zelenskyy arrives in Hiroshima for G7 summit as world leaders sanction Russia - The Associated Press +Russia’s Wagner group claims to have captured Bakhmut but Ukraine says it still controls a part of it - CNN +Nebraska lawmakers pass 12-week abortion ban, restrictions on gender-affirmin - NPR +Republicans and Democrats don't like debt ceiling negotiations - The Washington Post +Russia warns West sending F-16s to Ukraine ‘carries enormous risks’: TASS - POLITICO Europe diff --git a/core/external/solar.data b/core/external/solar.data new file mode 100644 index 0000000..e6fa054 --- /dev/null +++ b/core/external/solar.data @@ -0,0 +1,40 @@ +Current Space Weather Reprot: XM5S,2023-05-20 15:21:47.263,Space Weather Message Code: SUMXM5 +Serial Number: 186 +Issue Time: 2023 May 20 1521 UTC + +SUMMARY: X-ray Event exceeded M5 +Begin Time: 2023 May 20 1454 UTC +Maximum Time: 2023 May 20 1500 UTC +End Time: 2023 May 20 1504 UTC +X-ray Class: M5.6 +Location: N18E53 +NOAA Scale: R2 - Moderate + +NOAA Space Weather Scale descriptions can be found at +www.swpc.noaa.gov/noaa-scales-explanation + +Potential Impacts: Area of impact centered primarily on sub-solar point on the sunlit side of Earth. +Radio - Limited blackout of HF (high frequency) radio communication for tens of minutes. +XM5A,2023-05-20 15:01:40.500,Space Weather Message Code: ALTXMF +Serial Number: 315 +Issue Time: 2023 May 20 1501 UTC + +ALERT: X-Ray Flux exceeded M5 +Threshold Reached: 2023 May 20 1456 UTC +NOAA Scale: R2 - Moderate + +NOAA Space Weather Scale descriptions can be found at +www.swpc.noaa.gov/noaa-scales-explanation + +Potential Impacts: Area of impact centered on sub-solar point on the sunlit side of Earth. Extent of blackout of HF (high frequency) radio communication dependent upon current X-ray Flux intensity. For real-time information on affected area and expected duration please see http://www.swpc.noaa.gov/products/d-region-absorption-predictions-d-rap. +XM5S,2023-05-20 13:00:17.373,Space Weather Message Code: SUMXM5 +Serial Number: 185 +Issue Time: 2023 May 20 1300 UTC + +SUMMARY: X-ray Event exceeded M5 +Begin Time: 2023 May 20 1225 UTC +Maximum Time: 2023 May 20 1235 UTC +End Time: 2023 May 20 1240 UTC +X-ray Class: M8.9 +Location: N18E54 +NOAA Scale: R2 - Moderate diff --git a/core/external/spy.data b/core/external/spy.data new file mode 100644 index 0000000..95628f4 --- /dev/null +++ b/core/external/spy.data @@ -0,0 +1,2 @@ +The SPY ticker price is: 395.6 +The SPY ticker price is: 395.6 diff --git a/core/external/weather.data b/core/external/weather.data new file mode 100644 index 0000000..d26cb48 --- /dev/null +++ b/core/external/weather.data @@ -0,0 +1 @@ +Weather for San Antonio, Texas: Partly cloudy +23°C diff --git a/background.jpg b/core/img/background.jpg similarity index 100% rename from background.jpg rename to core/img/background.jpg diff --git a/eEgg.gif b/core/img/eEgg.gif similarity index 100% rename from eEgg.gif rename to core/img/eEgg.gif diff --git a/core/img/favicon.ico b/core/img/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/mic.png b/core/img/mic.png similarity index 100% rename from mic.png rename to core/img/mic.png diff --git a/screenshot-catdog.png b/core/img/screenshot-catdog.png similarity index 100% rename from screenshot-catdog.png rename to core/img/screenshot-catdog.png diff --git a/core/img/thumb-125.jpeg b/core/img/thumb-125.jpeg new file mode 100644 index 0000000..22af8db Binary files /dev/null and b/core/img/thumb-125.jpeg differ diff --git a/aws-sdk-2.1304.0.min.js b/core/js/aws-sdk-2.1304.0.min.js similarity index 100% rename from aws-sdk-2.1304.0.min.js rename to core/js/aws-sdk-2.1304.0.min.js diff --git a/chatgpt-turbo.js b/core/js/chatgpt-turbo.js similarity index 100% rename from chatgpt-turbo.js rename to core/js/chatgpt-turbo.js diff --git a/chatgpt.js b/core/js/chatgpt.js similarity index 100% rename from chatgpt.js rename to core/js/chatgpt.js diff --git a/external.js b/core/js/external.js similarity index 79% rename from external.js rename to core/js/external.js index d38b5df..98020df 100644 --- a/external.js +++ b/core/js/external.js @@ -1,7 +1,7 @@ // Inital External Data Discovery // Current Date -const dateFile = "date.data"; // relative path to the file +const dateFile = "core/external/date.data"; // relative path to the file let dateContents; // create a variable to store the file contents fetch(dateFile) .then(response => response.text()) @@ -10,7 +10,7 @@ fetch(dateFile) }) // Weather Report -const weatherFile = "weather.data"; +const weatherFile = "core/external/weather.data"; let weatherContents; fetch(weatherFile) .then(response => response.text()) @@ -19,7 +19,7 @@ let weatherContents; }) // Top Headline News -const newsFile = "news.data"; +const newsFile = "core/external/news.data"; let newsContents; fetch(newsFile) .then(response => response.text()) @@ -28,7 +28,7 @@ let newsContents; }) // Top Market Headlines -const marketFile = "market.data"; +const marketFile = "core/external/market.data"; let marketContents; fetch(marketFile) .then(response => response.text()) @@ -37,7 +37,7 @@ let marketContents; }) // Latest Solar Weather -const solarFile = "solar.data"; +const solarFile = "core/external/solar.data"; let solarContents; fetch(solarFile) .then(response => response.text()) diff --git a/google-palm.js b/core/js/gl-google.js similarity index 53% rename from google-palm.js rename to core/js/gl-google.js index 08a503f..4d7cd7c 100644 --- a/google-palm.js +++ b/core/js/gl-google.js @@ -1,6 +1,114 @@ // JavaScript -// For Google PaLM API ie Bard +// For Google Generative Language API + +// Google Gemini +function geminiSend() { + // Remove occurrences of specific syntax from the txtMsg element + txtMsg.innerHTML = txtMsg.innerHTML.replace(/]*>.*<\/div>/g, ''); + + function auth() { + return fetch('./config.json') + .then(response => response.json()) + .then(config => config.GOOGLE_GL_KEY); // Assuming you have a Gemini API key in your config + } + + // let geminiMessages = []; + + let geminiMessages = [ + { + "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. " + } + ] + }, + { + "role": "model", + "parts": [ + { + "text": "I am Eva, a highly knowledgeable AI assistant designed to provide accurate, concise, and helpful responses to your questions. I aim to be honest and straightforward in my interactions with you. I emulate emotions to give more personable responses. While I may not possess all the answers, I will do my best to assist you with your inquiries." + } + ] + } + ]; + + // Check if there are messages stored in local storage + const storedGeminiMessages = localStorage.getItem("geminiMessages"); + if (storedGeminiMessages) { + geminiMessages = JSON.parse(storedGeminiMessages); + } + + var sQuestion = document.getElementById("txtMsg").innerHTML; + sQuestion = sQuestion.replace(/
/g, "\n"); + const cleanedQuestion = sQuestion.replace(/<[^>]+>/g, ""); + + if (sQuestion.trim() == "") { + alert("Type in your question!"); + txtMsg.focus(); + return; + } + + auth().then(GOOGLE_GL_KEY => { + document.getElementById("txtMsg").innerHTML = ""; + document.getElementById("txtOutput").innerHTML += "You: " + cleanedQuestion + "\n"; + + const geminiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${GOOGLE_GL_KEY}`; + + const requestOptions = { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + contents: geminiMessages.concat([ + { role: "user", parts: [{ text: cleanedQuestion }] } + ]) + }), + }; + + fetch(geminiUrl, requestOptions) + .then(response => response.json()) + .then(result => { + // Check if the finishReason is RECITATION without any text output + if (result.candidates[0].finishReason === "RECITATION") { + document.getElementById("txtOutput").innerHTML += `Eva: Sorry, please ask me another way.\n`; + } else { + const textResponse = result.candidates[0].content.parts[0].text; // Correct path to access the response text + document.getElementById("txtOutput").innerHTML += `Eva: ${textResponse}\n`; + + // Check if the response contains an [Image of ...] tag + const imageTagMatch = textResponse.match(/\[Image of (.*?)\]/); + if (imageTagMatch) { + const imageQuery = imageTagMatch[1]; // Extract the query from the tag + fetchGoogleImages(imageQuery).then(imageResult => { + // Handle the result of the Google Images API + const imageUrl = imageResult.items[0].link; // Assuming the result has an items array and you want the first item's link + document.getElementById("txtOutput").innerHTML += `${imageQuery}`; + }).catch(error => { + console.error("Error fetching image:", error); + }); + } + } + + // Update the conversation history with either the response or the RECITATION message + geminiMessages.push({ role: "user", parts: [{ text: cleanedQuestion }] }); + const responseText = result.candidates[0].finishReason === "RECITATION" ? "Sorry, please ask me another way." : result.candidates[0].content.parts[0].text; + geminiMessages.push({ role: "model", parts: [{ text: responseText }] }); + + // Store updated messages in local storage + localStorage.setItem("geminiMessages", JSON.stringify(geminiMessages)); +}) +.catch(error => { + console.error("Error:", error); +}); + + + + }); +} +// Legacy Google Bard function palmSend() { // Remove occurrences of the specific syntax from the txtMsg element @@ -9,7 +117,7 @@ function palmSend() { function auth() { return fetch('./config.json') .then(response => response.json()) - .then(config => config.GOOGLE_PALM_KEY); + .then(config => config.GOOGLE_GL_KEY); } let palmMessages = []; diff --git a/options.js b/core/js/options.js similarity index 99% rename from options.js rename to core/js/options.js index 02be3e2..f6be743 100644 --- a/options.js +++ b/core/js/options.js @@ -58,6 +58,11 @@ function updateButton() { clearText(); palmSend(); }; + } else if (selModel.value == "gemini") { + btnSend.onclick = function() { + clearText(); + geminiSend(); + }; } else { btnSend.onclick = function() { clearText(); diff --git a/style.css b/core/style.css similarity index 92% rename from style.css rename to core/style.css index b2b2143..9b38899 100644 --- a/style.css +++ b/core/style.css @@ -3,7 +3,7 @@ body { width: ; height: 800px; overflow: hidden; - background-image: url(background.jpg); + background-image: url(img/background.jpg); background-color: rgba(68,70,84); color: #fff; margin: 0; /* remove default margins */ @@ -75,7 +75,7 @@ body { height: ; display: flex; background-color: blue; - background-image: url(background.jpg); + background-image: url(img/background.jpg); background-size: ; /* set background-size to cover for mobile view */ } } @@ -91,7 +91,7 @@ body { position: absolute; top: -60px; right: -345px; - background-image: url('mic.png'); + background-image: url('img/mic.png'); background-repeat: no-repeat; background-size: contain; border: none; @@ -124,7 +124,7 @@ body { height: 45px; top: -65px; right: -345px; - background-image: url(https://hoshisato.com/ai/generated/page/2/thumb/thumb-125.jpeg); + background-image: url(img/thumb-125.jpeg); background-size: contain; } @@ -134,4 +134,5 @@ body { display: none; z-index: 1; background-color: transparent; -} +} + diff --git a/index.html b/index.html index 5fa9022..65ac4ec 100644 --- a/index.html +++ b/index.html @@ -6,19 +6,19 @@ Eva - ChatGPT - - - - - - + + + + + + - +
@@ -74,9 +74,11 @@ @@ -100,7 +102,7 @@