376c7f7c by RSA

fixes

1 parent 489d95f0
......@@ -64,7 +64,11 @@ function App() {
setChatInput("");
setChatLog(chatLogNew)
const userMessage = { user: "gpt", message: "..." };
setChatLog(prevChatLog => [...prevChatLog, userMessage]);
const messages = chatLogNew.map((message) => message.message).join("\n")
let intervalId = startInterval();
try {
const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", {
......@@ -79,6 +83,7 @@ function App() {
});
const data = await response.json();
const parsedData = data.message.trim();
clearInterval(intervalId);
const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
......@@ -113,6 +118,21 @@ function App() {
const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again.";
setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ])
}
function startInterval() {
return setInterval(function() {
if (userMessage.message.length === 3) {
userMessage.message = ".";
} else if (userMessage.message.length === 1) {
userMessage.message = "..";
} else {
userMessage.message = "...";
}
var thinkingDots = document.getElementsByClassName("message");
var thinkingDot = thinkingDots[thinkingDots.length - 1];
thinkingDot.innerHTML = userMessage.message;
}, 500);
}
}
function handleTemp(temp) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!