Skip to content

Commit

Permalink
Merge pull request #56 from appatalks/core_updates
Browse files Browse the repository at this point in the history
core updates, removed legacy models, added newer models
  • Loading branch information
appatalks authored Oct 12, 2024
2 parents b25f2e2 + e9e2023 commit 5f98065
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 168 deletions.
145 changes: 0 additions & 145 deletions core/js/chatgpt.js

This file was deleted.

14 changes: 7 additions & 7 deletions core/js/chatgpt-turbo.js → core/js/gpt-core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Javascript
// For OpenAI API

// API Call for gpt-4 classes
// API Call for latest gpt classes
function trboSend() {

// Remove occurrences of the specific syntax from the txtMsg element
Expand All @@ -27,7 +27,7 @@ function trboSend() {
// Check for errors
if (oHttp.status === 500) {
txtOutput.innerHTML += "<br> Error 500: Internal Server Error" + "<br>" + oHttp.responseText;
console.log("Error 500: Internal Server Error chatgpt-turbo.js Line 26");
console.log("Error 500: Internal Server Error chatgpt-turbo.js Line 30");
return;
}
if (oHttp.status === 429) {
Expand All @@ -53,7 +53,7 @@ function trboSend() {
console.log("oJson", oJson);
} catch (ex) {
txtOutput.innerHTML += "Error: " + ex.message;
console.log("Error: chatgpt-turbo.js Line 52");
console.log("Error: gpt-core.js Line 56");
return;
}

Expand Down Expand Up @@ -86,14 +86,14 @@ function trboSend() {
}
else {
txtOutput.innerHTML += "Error Other: " + oJson.error.message;
console.log("Error Other: chatgpt-turbo.js Line 87");
console.log("Error Other: gpt-core.js Line 89");
retryCount = 0;
}
}

// Interpret AI Response after Error Handling
else if (oJson.choices && oJson.choices[0].message) {
// console.log("chatgpt-turbo.js Line 96" + oJson.choices + "" + oJson.choices[0].message);
// console.log("gpt-core.js Line 96" + oJson.choices + "" + oJson.choices[0].message);
// Always Run Response
var s = oJson.choices[0].message;
// Empty Response Handling
Expand Down Expand Up @@ -149,7 +149,7 @@ function trboSend() {

// Set lastResponse
lastResponse = s.content + "\n";
// console.log("chatgpt-turbo.js Line 152" + lastResponse);
// console.log("gpt-core.js Line 152" + lastResponse);
}
}

Expand Down Expand Up @@ -311,7 +311,7 @@ function trboSend() {

// Sending API Payload
oHttp.send(JSON.stringify(data));
// console.log("chatgpt-turbo.js Line 314" + JSON.stringify(data));
// console.log("gpt-core.js Line 314" + JSON.stringify(data));

// Relay Send to Screen

Expand Down
20 changes: 10 additions & 10 deletions core/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function autoSelect() {

// Define keywords for different conditions

// coding-related, math, logic, reasoning, language tasks
const gptHuristics = ["code", "programming", "debug", "bash", "python", "javascript", "script", "language", "한글", "weather", "news", "space", "solar", "stock", "markets", "symbol", "ticker", "Google", "google", "date", "math", "fraction", "problem", "+", "="];
// coding-related, math, logic, math, science
const gptHuristics = ["code", "programming", "debug", "bash", "python", "javascript", "script", "space", "solar", "math", "fraction", "problem", "+", "="];

// For complex queries
const glHuristics = ["gemini"];
Expand All @@ -69,23 +69,24 @@ function autoSelect() {
selModel.value = "gpt-4o"; // Long queries might not need more token resources
}
else if (gptHuristics.some(keyword => userInput.includes(keyword))) {
selModel.value = "gpt-4o"; // For coding-related, math, logic, reasoning, language tasks.
selModel.value = "o1-mini"; // For coding-related, math, logic, science.
}
else if (glHuristics.some(keyword => userInput.includes(keyword))) {
selModel.value = "gemini"; // For complex queries, a different model could be preferred
selModel.value = "gemini"; // For Google Gemini's model
}
else if (dalHuristics.some(keyword => userInput.includes(keyword))) {
selModel.value = "dall-e-3"; // For dall-e-3 generated images
}
else {
selModel.value = "gpt-4o"; // Default to a different model if none of the above conditions are met
selModel.value = "gpt-4o-mini"; // Default to a different model if none of the above conditions are met
}

// Now trigger the appropriate send function based on the selected model
switch (selModel.value) {
case "gpt-3.5-turbo":
case "gpt-4-turbo-preview":
case "gpt-4o-mini":
case "gpt-4o":
case "o1-mini":
case "o1-preview":
trboSend();
break;
case "gemini":
Expand Down Expand Up @@ -114,7 +115,7 @@ function updateButton() {
clearText();
autoSelect();
};
} else if (selModel.value == "gpt-3.5-turbo" || selModel.value == "gpt-4-turbo-preview" || selModel.value == "gpt-4o" ) {
} else if (selModel.value == "gpt-4o-mini" || selModel.value == "o1-mini" || selModel.value == "gpt-4o" || selModel.value == "o1-preview") {
btnSend.onclick = function() {
clearText();
trboSend();
Expand Down Expand Up @@ -146,7 +147,7 @@ function sendData() {
if (selModel.value == "auto") {
clearText();
autoSelect();
} else if (selModel.value == "gpt-3.5-turbo" || selModel.value == "gpt-4-turbo-preview" || selModel.value == "gpt-4o") {
} else if (selModel.value == "gpt-4o-mini" || selModel.value == "o1-mini" || selModel.value == "gpt-4o" || selModel.value == "o1-preview") {
clearText();
trboSend();
} else if (selModel.value == "gemini") {
Expand Down Expand Up @@ -263,7 +264,6 @@ function mobile_txtmsd() {
var input = document.getElementById("imgInput");
input.style.display = "block";


// Mic Button
let micButton = document.querySelector(".mic-button");
micButton.style.top = "-49px";
Expand Down
11 changes: 5 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<title>Eva - ChatGPT</title>
<script src="core/js/options.js"></script>
<script src="core/js/external.js"></script>
<!-- <script src="core/js/chatgpt.js"></script> // Legacy no longer used // -->
<script src="core/js/chatgpt-turbo.js"></script>
<script src="core/js/gpt-core.js"></script>
<script src="core/js/gl-google.js"></script>
<script src="core/js/dalle3.js"></script>
<script src="core/js/aws-sdk-2.1304.0.min.js"></script>
Expand Down Expand Up @@ -75,11 +74,11 @@
<button type="button" onclick="sendData()" id="btnSend">Send</button>
<select id="selModel" onchange="updateButton()">
<option value="auto" title="Default">auto</option>
<option value="gpt-3.5-turbo" title="gpt-3.5-turbo">gpt-3.5-turbo</option>
<option value="gpt-4o-mini" title="gpt-4o-mini">gpt-4o-mini</option>
<option value="gpt-4o" title="gpt-4o">gpt-4o</option>
<option value="o1-preview" title="o1-preview">o1-preview</option>
<option value="o1-mini" title="o1-mini">o1-mini</option>
<option value="dall-e-3" title="Image Generation">dall-e-3</option>
<!-- <option value="gpt-3.5-turbo-16k" title="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option> -->
<option value="gpt-4-turbo-preview" title="GPT-4-Turbo">gpt-4-turbo-preview</option>
<option value="gpt-4o" title="GPT-4o">gpt-4o</option>
<option value="gemini" title="Google Gemini">gemini</option>
<!-- <option value="palm" title="Legacy Google PaLM ie Bard">palm</option> -->
</select>
Expand Down

0 comments on commit 5f98065

Please sign in to comment.