55cd85e1 by RSA

fix conflict

2 parents dc3576bd 37b3831b
...@@ -42,7 +42,6 @@ function App() { ...@@ -42,7 +42,6 @@ function App() {
42 42
43 async function handleSubmit(e){ 43 async function handleSubmit(e){
44 e.preventDefault(); 44 e.preventDefault();
45 console.log(chatInput)
46 const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who', 'hey']; 45 const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who', 'hey'];
47 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); 46 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi');
48 const inputMatches = chatInput.match(userInputRegex); 47 const inputMatches = chatInput.match(userInputRegex);
...@@ -51,16 +50,13 @@ function App() { ...@@ -51,16 +50,13 @@ function App() {
51 const userPunctuationRegex = new RegExp(`[${userPunctuation.join('')}]$`); 50 const userPunctuationRegex = new RegExp(`[${userPunctuation.join('')}]$`);
52 const punctuationMatches = chatInput.match(userPunctuationRegex); 51 const punctuationMatches = chatInput.match(userPunctuationRegex);
53 52
54 console.log(punctuationMatches)
55 var userModifiedInput = chatInput 53 var userModifiedInput = chatInput
56 54
57 if (!punctuationMatches) { 55 if (!punctuationMatches) {
58 if (!inputMatches) { 56 if (!inputMatches) {
59 userModifiedInput = chatInput + "."; 57 userModifiedInput = chatInput + ".";
60 console.log("not a question!")
61 } else { 58 } else {
62 userModifiedInput = chatInput + "?"; 59 userModifiedInput = chatInput + "?";
63 console.log("its a question!")
64 } 60 }
65 } 61 }
66 62
...@@ -71,6 +67,7 @@ function App() { ...@@ -71,6 +67,7 @@ function App() {
71 // fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post 67 // fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post
72 const messages = chatLogNew.map((message) => message.message).join("\n") 68 const messages = chatLogNew.map((message) => message.message).join("\n")
73 69
70 try {
74 const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { 71 const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", {
75 method: "POST", 72 method: "POST",
76 headers: { 73 headers: {
...@@ -86,19 +83,20 @@ function App() { ...@@ -86,19 +83,20 @@ function App() {
86 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; 83 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
87 84
88 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi'); 85 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
89 // console.log(regex)
90 const matches = parsedData.match(regex); 86 const matches = parsedData.match(regex);
91 console.log(matches);
92 if (!matches) { 87 if (!matches) {
93 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. ')) 88 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. '))
94 console.log("not programming!")
95 } else { 89 } else {
96 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>')) 90 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>'))
97 console.log("programming!")
98 } 91 }
99 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ]) 92 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ])
93
100 var scrollToTheBottomChatLog = document.getElementsByClassName("chat-log")[0]; 94 var scrollToTheBottomChatLog = document.getElementsByClassName("chat-log")[0];
101 scrollToTheBottomChatLog.scrollTop = scrollToTheBottomChatLog.scrollHeight; 95 scrollToTheBottomChatLog.scrollTop = scrollToTheBottomChatLog.scrollHeight;
96 } catch (error) {
97 const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again.";
98 setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ])
99 }
102 } 100 }
103 101
104 function handleTemp(temp) { 102 function handleTemp(temp) {
......
...@@ -2,6 +2,33 @@ ...@@ -2,6 +2,33 @@
2 background-color: #101827 !important; 2 background-color: #101827 !important;
3 } 3 }
4 4
5 .errormsg {
6 border: 1px solid #7ac5ff;
7 padding: 15px 25px;
8 border-radius: 10px;
9 background: rgb(0 139 245 / 6%);
10 }
11
12 .errormsg .msg {
13 display: inline-block;
14 width: 90%;
15 font-weight: 600;
16 }
17 .errormsg span {
18 background: #008BF5;
19 padding: 1px 11px;
20 border-radius: 50px;
21 width: 25px;
22 height: 25px;
23 margin-right: 10px;
24 color: #fff;
25 font-weight: 900;
26 display: inline-block;
27 vertical-align: top;
28 font-family: auto;
29 font-size: 15px;
30 }
31
5 .side-menu-button { 32 .side-menu-button {
6 border:0 solid white; 33 border:0 solid white;
7 /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#cedbe9+0,aac5de+17,6199c7+50,3a84c3+51,419ad6+59,4bb8f0+71,3a8bc2+84,26558b+100;Blue+Gloss */ 34 /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#cedbe9+0,aac5de+17,6199c7+50,3a84c3+51,419ad6+59,4bb8f0+71,3a8bc2+84,26558b+100;Blue+Gloss */
...@@ -175,6 +202,10 @@ code br:nth-child(-n+2) { ...@@ -175,6 +202,10 @@ code br:nth-child(-n+2) {
175 .message { 202 .message {
176 font-size: 14px; 203 font-size: 14px;
177 } 204 }
205 .errormsg {
206 padding: 10px;
207 width: 80%;
208 }
178 .chat-message-center { 209 .chat-message-center {
179 padding: 20px 5vw !important; 210 padding: 20px 5vw !important;
180 } 211 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!