From 3876eb5038c89a3080aa1d67dfb566170dbcdd77 Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 03:53:46 +0000 Subject: [PATCH 01/11] Update askMe.js --- js/askMe.js | 92 ++++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/js/askMe.js b/js/askMe.js index eea4ef1..7fbbaa3 100644 --- a/js/askMe.js +++ b/js/askMe.js @@ -10,52 +10,58 @@ document.addEventListener("DOMContentLoaded", () => { let access_token = null; let refresh_token = null; responseDiv.style.display = "none"; + const handleAsk = () => { const question = questionInput.value; - questionInput.innerHTML = " " + questionInput.innerHTML = " "; if (question) { - askButton.innerHTML = 'Loading'; - setResponse('Please wait! Response is coming....') - setIsLoading(true) + askButton.innerHTML = 'Loading'; + setResponse('Please wait! Response is coming....'); + setIsLoading(true); - // if (access_token) { - const headers = { - 'Content-Type': 'application/json', - // 'Authorization': `Bearer ${access_token}`, - }; - const api_url = "https://awesome-terra-400014.lm.r.appspot.com/chat/"; - const data = { "user_input": question }; - - fetch(api_url, { - method: "POST", - headers: headers, - body: JSON.stringify(data), - }) - .then((response) => { - if (response.status === 401) { - refreshAccessToken(refresh_token, makeApiRequest); - } else { - console.log("I'm not in response mode", response); - return response.json(); - } - }) - .then((result) => { - forVoice = result.chatbot_response; - const ans = result.chatbot_response; - setResponse(ans); - setIsLoading(false) - // toogle() - }) - .catch((error) => { - responseDiv.textContent = "Request failed with an error."; - setIsLoading(false) - setResponse('Something went wrong. Please try again') - }); - // } else { - // setIsLoading(false) - // setResponse('No access token found.') - // } - }}; + // OpenAI API integration + const apiKey = process.env.OPENAI_APIKEY // || ''; Replace with your OpenAI API key + + const headers = { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${apiKey}` + }; + + const data = { + model: "gpt-4", + messages: [ + { role: "system", content: "You are a helpful assistant." }, + { role: "user", content: question } + ] + }; + + const api_url = "https://api.openai.com/v1/chat/completions"; + + fetch(api_url, { + method: "POST", + headers: headers, + body: JSON.stringify(data), + }) + .then((response) => { + if (response.ok) { + return response.json(); + } else { + throw new Error("Request failed!"); + } + }) + .then((result) => { + const ans = result.choices[0].message.content; // Extract OpenAI's response + forVoice = ans; + setResponse(ans); + setIsLoading(false); + }) + .catch((error) => { + responseDiv.textContent = "Request failed with an error."; + setIsLoading(false); + setResponse('Something went wrong. Please try again'); + }); + } + }; // const refreshAccessToken = (refreshToken, onSuccess) => { // console.log('Refresh token') @@ -294,4 +300,4 @@ const toogle = () => { } } speaker.addEventListener('click', toogle) -}); \ No newline at end of file +}); From 188c025bf3914493dacbf6afde382df0b9aea693 Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:06:54 +0000 Subject: [PATCH 02/11] Update askMe.js --- js/askMe.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/askMe.js b/js/askMe.js index 7fbbaa3..d53c1db 100644 --- a/js/askMe.js +++ b/js/askMe.js @@ -21,6 +21,7 @@ document.addEventListener("DOMContentLoaded", () => { // OpenAI API integration const apiKey = process.env.OPENAI_APIKEY // || ''; Replace with your OpenAI API key + console.log(process.env.OPENAI_APIKEY); const headers = { 'Content-Type': 'application/json', @@ -37,6 +38,8 @@ document.addEventListener("DOMContentLoaded", () => { const api_url = "https://api.openai.com/v1/chat/completions"; + console.log(api_url, data, headers); + fetch(api_url, { method: "POST", headers: headers, From 87142aad4857573bccd6ef55de269f834f5b5410 Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:15:38 +0000 Subject: [PATCH 03/11] Update askMe.js --- js/askMe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/askMe.js b/js/askMe.js index d53c1db..19867d3 100644 --- a/js/askMe.js +++ b/js/askMe.js @@ -20,7 +20,7 @@ document.addEventListener("DOMContentLoaded", () => { setIsLoading(true); // OpenAI API integration - const apiKey = process.env.OPENAI_APIKEY // || ''; Replace with your OpenAI API key + const apiKey = window.OPENAI_APIKEY; console.log(process.env.OPENAI_APIKEY); const headers = { From e155f1dfa4bf3b62ea88126fb70b5cae1faef139 Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:22:21 +0000 Subject: [PATCH 04/11] Update askMe.js --- js/askMe.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/askMe.js b/js/askMe.js index 19867d3..b5dfeec 100644 --- a/js/askMe.js +++ b/js/askMe.js @@ -20,8 +20,12 @@ document.addEventListener("DOMContentLoaded", () => { setIsLoading(true); // OpenAI API integration - const apiKey = window.OPENAI_APIKEY; - console.log(process.env.OPENAI_APIKEY); + const apiKey = prompt("Please enter your OpenAI API key:"); + if (!apiKey) { + alert("API key is required to proceed."); + return; + } + console.log(apiKey); const headers = { 'Content-Type': 'application/json', From aa81ba6547a67fbf4967e3e4d147d3b4f49e7b74 Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:35:29 +0000 Subject: [PATCH 05/11] Update index.html --- index.html | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index 9947517..7f63a7b 100644 --- a/index.html +++ b/index.html @@ -4,27 +4,27 @@ - AiProf + AICoder + content="Unlock the future of learning with AICoder. Elevate your educational experience and discover how AI is reshaping the way you learn and teach" /> - - - + + + + content="Unlock the future of learning with AICoder. Elevate your educational experience and discover how AI is reshaping the way you learn and teach"> - + content="Unlock the future of learning with AICoder. Elevate your educational experience and discover how AI is reshaping the way you learn and teach" /> + @@ -97,7 +97,7 @@ + href="https://getsomesleepbro.github.io/AICoder/blog/BlogIndex">Blog @@ -380,7 +380,7 @@

Increased Productivity

- About AIProf @@ -509,7 +509,7 @@

Our Progress so far

How To Use AIProf + class='featured-text'>AICoder Book Your Teacher With A Group

04.
-
Book Your Own AiProf
+
Book Your Own AICoder
@@ -809,7 +809,7 @@
-

AiProf transforms education +

AICoder transforms education by revolutionizing learning experiences, improving knowledge retention, and offering instant support, enhancing students' educational journeys. @@ -840,14 +840,14 @@

+ Is AICoder for Charity?

- Yes, AiProf also operates as a charity, + Yes, AICoder also operates as a charity, dedicated to providing free educational resources and support to students.

@@ -858,13 +858,13 @@
+ AICoder Safe?
-

AIProf is committed to data security, employing stringent measures to safeguard +

AICoder is committed to data security, employing stringent measures to safeguard your personal and business information, guaranteeing its protection.

@@ -899,7 +899,7 @@
email:
@@ -945,7 +945,7 @@
Partners:
@@ -983,7 +983,7 @@
Influencers:
Services @@ -1003,7 +1003,7 @@
Influencers:
@@ -1027,7 +1027,7 @@
  • From d82b30ace98918207904acdc21457b3a35da829d Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:39:08 +0000 Subject: [PATCH 06/11] Update askMe.js --- js/askMe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/askMe.js b/js/askMe.js index b5dfeec..1acf6bb 100644 --- a/js/askMe.js +++ b/js/askMe.js @@ -35,7 +35,7 @@ document.addEventListener("DOMContentLoaded", () => { const data = { model: "gpt-4", messages: [ - { role: "system", content: "You are a helpful assistant." }, + { role: "system", content: "You are the best coder, writing clean, efficient code in a user-friendly manner. Write only code and avoid providing extra text. Include comments wherever necessary to explain key steps and logic." }, { role: "user", content: question } ] }; From 840dd4bab0598ff974d15d39e0cfc9e864cb7c8a Mon Sep 17 00:00:00 2001 From: GetSomeSleepBro <152909604+GetSomeSleepBro@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:40:58 +0000 Subject: [PATCH 07/11] Update index.html --- index.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 7f63a7b..bc02e67 100644 --- a/index.html +++ b/index.html @@ -8,11 +8,11 @@ + content="Ai, free learning, Artificial Intelligence, education, AI Coder, Meet Your AI, teaching, free lessons, math, history, sports"> - + @@ -21,7 +21,7 @@ - + @@ -125,7 +125,7 @@
    -

    Ai Prof The Most
    Helpful TeacherAI Coder The Most
    Helpful Teacher @@ -291,7 +291,7 @@

    Our Services

    @@ -552,7 +552,7 @@
    Book Your Own AICoder
    @@ -803,7 +803,7 @@