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() { ...@@ -51,16 +51,16 @@ function App() {
51 const userPunctuationRegex = new RegExp(`${userPunctuation.join('')}$`, 'gi'); 51 const userPunctuationRegex = new RegExp(`${userPunctuation.join('')}$`, 'gi');
52 const punctuationMatches = chatInput.match(userPunctuationRegex); 52 const punctuationMatches = chatInput.match(userPunctuationRegex);
53 53
54 // console.log(punctuationMatches) 54 console.log(punctuationMatches)
55 var userModifiedInput = chatInput 55 var userModifiedInput = chatInput
56 56
57 if (!punctuationMatches) { 57 if (!punctuationMatches) {
58 if (!inputMatches) { 58 if (!inputMatches) {
59 userModifiedInput = chatInput + "."; 59 userModifiedInput = chatInput + ".";
60 // console.log("not a question!") 60 console.log("not a question!")
61 } else { 61 } else {
62 userModifiedInput = chatInput + "?"; 62 userModifiedInput = chatInput + "?";
63 // console.log("its a question!") 63 console.log("its a question!")
64 } 64 }
65 } 65 }
66 66
...@@ -83,24 +83,20 @@ function App() { ...@@ -83,24 +83,20 @@ function App() {
83 }); 83 });
84 const data = await response.json(); 84 const data = await response.json();
85 const parsedData = data.message.trim(); 85 const parsedData = data.message.trim();
86 // console.log(parsedData)
87 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; 86 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
88 87
89 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi'); 88 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
90 // console.log(regex) 89 // console.log(regex)
91 const matches = parsedData.match(regex); 90 const matches = parsedData.match(regex);
92 // console.log(matches); 91 console.log(matches);
93 if (!matches) { 92 if (!matches) {
94 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. ')) 93 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. '))
95 // console.log("not programming!") 94 console.log("not programming!")
96 } else { 95 } else {
97 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>')) 96 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>'))
98 // console.log("programming!") 97 console.log("programming!")
99 //.replace('<?','&#60;' + '?').replace('?>','?'+'&#62;')
100 } 98 }
101 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ]) 99 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ])
102
103 // setChatLog([...chatLogNew, { user: "gpt", message: `<div>${parsedData}</div>`} ])
104 var scrollToTheBottomChatLog = document.getElementsByClassName("chat-log")[0]; 100 var scrollToTheBottomChatLog = document.getElementsByClassName("chat-log")[0];
105 scrollToTheBottomChatLog.scrollTop = scrollToTheBottomChatLog.scrollHeight; 101 scrollToTheBottomChatLog.scrollTop = scrollToTheBottomChatLog.scrollHeight;
106 } 102 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!