fd0c65d6 by RSA

fix conflict

2 parents 3e569df6 044faa07
...@@ -10,8 +10,8 @@ Create an .env file in the root directory of your application. ...@@ -10,8 +10,8 @@ Create an .env file in the root directory of your application.
10 Duplicate the env-template and rename to .env 10 Duplicate the env-template and rename to .env
11 In the .env file, define the environment variables you want to use in your application. ex. 11 In the .env file, define the environment variables you want to use in your application. ex.
12 12
13 `API_KEY="sk-xxxxxxxx"` 13 `OPENAI_API_KEY="sk-xxxxxxxx"`
14 `API_ORG="org-xxxxxxx"` 14 `OPENAI_API_ORG="org-xxxxxxx"`
15 15
16 ## Run server 16 ## Run server
17 17
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
104 padding:12px; 104 padding:12px;
105 padding-left: 24px; 105 padding-left: 24px;
106 padding-right: 24px; 106 padding-right: 24px;
107 107
108 } 108 }
109 .avatar { 109 .avatar {
110 background:white; 110 background:white;
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
114 display:flex; 114 display:flex;
115 align-items:center; 115 align-items:center;
116 justify-content:center; 116 justify-content:center;
117 padding:5px; 117 padding:15px;
118 font-size:14px; 118 font-size:14px;
119 color:#444654; 119 color:#444654;
120 } 120 }
......
...@@ -47,8 +47,8 @@ function App() { ...@@ -47,8 +47,8 @@ function App() {
47 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); 47 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi');
48 const inputMatches = chatInput.match(userInputRegex); 48 const inputMatches = chatInput.match(userInputRegex);
49 49
50 const userPunctuation = ['.', '?', '!', ':', ';', ',']; 50 const userPunctuation = ['\.', '?', '!', ':', ';', ','];
51 const userPunctuationRegex = new RegExp(`${userPunctuation.join('')}$`, 'gi'); 51 const userPunctuationRegex = new RegExp(`[${userPunctuation.join('')}]$`);
52 const punctuationMatches = chatInput.match(userPunctuationRegex); 52 const punctuationMatches = chatInput.match(userPunctuationRegex);
53 53
54 // console.log(punctuationMatches) 54 // console.log(punctuationMatches)
...@@ -84,20 +84,14 @@ function App() { ...@@ -84,20 +84,14 @@ function App() {
84 }); 84 });
85 const data = await response.json(); 85 const data = await response.json();
86 const parsedData = data.message.trim(); 86 const parsedData = data.message.trim();
87 // console.log(parsedData)
88 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; 87 const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table'];
89 88
90 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi'); 89 const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
91 // console.log(regex)
92 const matches = parsedData.match(regex); 90 const matches = parsedData.match(regex);
93 // console.log(matches);
94 if (!matches) { 91 if (!matches) {
95 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. ')) 92 var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>').replace(/\./g, '. '))
96 // console.log("not programming!")
97 } else { 93 } else {
98 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>')) 94 replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>'))
99 // console.log("programming!")
100 //.replace('<?','&#60;' + '?').replace('?>','?'+'&#62;')
101 } 95 }
102 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ]) 96 setChatLog([...chatLogNew, { user: "gpt", message: `${replaceTags}`} ])
103 97
...@@ -106,7 +100,6 @@ function App() { ...@@ -106,7 +100,6 @@ function App() {
106 } catch (error) { 100 } catch (error) {
107 const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again."; 101 const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again.";
108 setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ]) 102 setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ])
109 // res.status(500).send(error || 'Something went wrong');
110 } 103 }
111 } 104 }
112 105
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!