292766e9 by Ryan

Merge branch '26797_chatgpt_format3' into '1DEVT'

26797 chatgpt format3

See merge request !18
2 parents 65baf6b8 3ae8a87d
......@@ -51,16 +51,16 @@ function App() {
const userPunctuationRegex = new RegExp(`${userPunctuation.join('')}$`, 'gi');
const punctuationMatches = chatInput.match(userPunctuationRegex);
// console.log(punctuationMatches)
console.log(punctuationMatches)
var userModifiedInput = chatInput
if (!punctuationMatches) {
if (!inputMatches) {
userModifiedInput = chatInput + ".";
// console.log("not a question!")
console.log("not a question!")
} else {
userModifiedInput = chatInput + "?";
// console.log("its a question!")
console.log("its a question!")
}
}
......@@ -83,24 +83,20 @@ function App() {
});
const data = await response.json();
const parsedData = data.message.trim();
// console.log(parsedData)
const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
// console.log(regex)
const matches = parsedData.match(regex);
// console.log(matches);
console.log(matches);
if (!matches) {
var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. '))
// console.log("not programming!")
console.log("not programming!")
} else {
replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>'))
// console.log("programming!")
//.replace('<?','&#60;' + '?').replace('?>','?'+'&#62;')
console.log("programming!")
}
setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ])
// setChatLog([...chatLogNew, { user: "gpt", message: `<div>${parsedData}</div>`} ])
var scrollToTheBottomChatLog = document.getElementsByClassName("chat-log")[0];
scrollToTheBottomChatLog.scrollTop = scrollToTheBottomChatLog.scrollHeight;
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!