Added string replace and modified trained prompt
Showing
1 changed file
with
18 additions
and
3 deletions
| ... | @@ -109,7 +109,7 @@ function App() { | ... | @@ -109,7 +109,7 @@ function App() { |
| 109 | userModifiedInput = chatInput + "?"; | 109 | userModifiedInput = chatInput + "?"; |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | let trained_prompt = chatInput + '. Respond without using markdown, HTML tags, asterisks, hashtags, or any special symbols for formatting.'; | 112 | let trained_prompt = chatInput + '. Avoiding any tags, markdown syntax, hashtags, or asterisks for formatting.'; |
| 113 | let chatLogNew = [...chatLog, { user: "user", message: `${userModifiedInput}`} ] | 113 | let chatLogNew = [...chatLog, { user: "user", message: `${userModifiedInput}`} ] |
| 114 | setChatInput(""); | 114 | setChatInput(""); |
| 115 | setChatLog(chatLogNew) | 115 | setChatLog(chatLogNew) |
| ... | @@ -191,9 +191,24 @@ function App() { | ... | @@ -191,9 +191,24 @@ function App() { |
| 191 | const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi'); | 191 | const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi'); |
| 192 | const matches = parsedData.match(regex); | 192 | const matches = parsedData.match(regex); |
| 193 | if (!matches) { | 193 | if (!matches) { |
| 194 | var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>')) | 194 | var replaceTags = ( |
| 195 | parsedData | ||
| 196 | .replace(/(?:\r\n|\r|\n)/g, '<br>') | ||
| 197 | .replace(/\*\*(.*?)\*\*/g, '$1') | ||
| 198 | .replace(/#\s(.+)/g, "$1") | ||
| 199 | .replace(/#[A-Za-z0-9_]+:?/g, "") | ||
| 200 | ) | ||
| 195 | } else { | 201 | } else { |
| 196 | replaceTags = (parsedData.replace(':',':<code>').replace('<?','<?').replace('?>','?>').replace(/\n/g, '<br>')) | 202 | replaceTags = ( |
| 203 | parsedData | ||
| 204 | .replace(':',':<code>') | ||
| 205 | .replace('<?','<?') | ||
| 206 | .replace('?>','?>') | ||
| 207 | .replace(/\n/g, '<br>') | ||
| 208 | .replace(/\*\*(.*?)\*\*/g, '$1') | ||
| 209 | .replace(/#\s(.+)/g, "$1") | ||
| 210 | .replace(/#[A-Za-z0-9_]+:?/g, "") | ||
| 211 | ) | ||
| 197 | } | 212 | } |
| 198 | 213 | ||
| 199 | for (let i = 0; i < replaceTags.length; i++) { | 214 | for (let i = 0; i < replaceTags.length; i++) { | ... | ... |
-
Please register or sign in to post a comment