044faa07 by Ryan

Merge branch '26797_chatgpt_format3' into 'master'

26797 chatgpt format3

See merge request !9
2 parents 0a4a261d 520d1069
...@@ -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)
...@@ -83,7 +83,6 @@ function App() { ...@@ -83,7 +83,6 @@ 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');
...@@ -96,11 +95,8 @@ function App() { ...@@ -96,11 +95,8 @@ function App() {
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!