Merge branch '32993_CHATBOT_PLUS_GPT4o_MINI' into 'master'
32993_CHATBOT_PLUS_GPT4o_MINI See merge request !132
Showing
2 changed files
with
5 additions
and
13 deletions
| ... | @@ -109,7 +109,7 @@ function App() { | ... | @@ -109,7 +109,7 @@ function App() { |
| 109 | userModifiedInput = chatInput + "?"; | 109 | userModifiedInput = chatInput + "?"; |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | let trained_prompt = chatInput + '. Respond without using markdown, HTML tags, or any special symbols 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) |
| ... | @@ -120,7 +120,7 @@ function App() { | ... | @@ -120,7 +120,7 @@ function App() { |
| 120 | var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") | 120 | var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") |
| 121 | let endpoint = getEndpoint(currentModel); | 121 | let endpoint = getEndpoint(currentModel); |
| 122 | if(endpoint === "openAI") { | 122 | if(endpoint === "openAI") { |
| 123 | let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }]; | 123 | let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: trained_prompt }]; |
| 124 | setChatLogTurbo(chatLogTurboNew); | 124 | setChatLogTurbo(chatLogTurboNew); |
| 125 | messages = JSON.stringify(chatLogTurboNew); | 125 | messages = JSON.stringify(chatLogTurboNew); |
| 126 | } | 126 | } |
| ... | @@ -191,16 +191,9 @@ function App() { | ... | @@ -191,16 +191,9 @@ 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>')).replace(/\*\*(.*?)\*\*/g, '$1').replace(/###\s(.+)/g, '$1'); | 194 | var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>')) |
| 195 | } else { | 195 | } else { |
| 196 | replaceTags = (parsedData | 196 | replaceTags = (parsedData.replace(':',':<code>').replace('<?','<?').replace('?>','?>').replace(/\n/g, '<br>')) |
| 197 | .replace(':',':<code>') | ||
| 198 | .replace('<?','<?') | ||
| 199 | .replace('?>','?>') | ||
| 200 | .replace(/\n/g, '<br>') | ||
| 201 | .replace(/\*\*(.*?)\*\*/g, '$1') | ||
| 202 | .replace(/###\s(.+)/g, '$1') | ||
| 203 | ) | ||
| 204 | } | 197 | } |
| 205 | 198 | ||
| 206 | for (let i = 0; i < replaceTags.length; i++) { | 199 | for (let i = 0; i < replaceTags.length; i++) { | ... | ... |
| ... | @@ -54,7 +54,6 @@ const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput, startedInterac | ... | @@ -54,7 +54,6 @@ const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput, startedInterac |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | const ChatMessage = ({ message }) => { | 56 | const ChatMessage = ({ message }) => { |
| 57 | const formattedMessage = message.message.replace(/\*\*(.*?)\*\*/g, '$1').replace(/###\s(.+)/g, '$1'); | ||
| 58 | return ( | 57 | return ( |
| 59 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | 58 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> |
| 60 | <div className="chat-message-center" style={ message.user === "gpt" ? { background: "#ddf1f9"} : {}}> | 59 | <div className="chat-message-center" style={ message.user === "gpt" ? { background: "#ddf1f9"} : {}}> |
| ... | @@ -64,7 +63,7 @@ const ChatMessage = ({ message }) => { | ... | @@ -64,7 +63,7 @@ const ChatMessage = ({ message }) => { |
| 64 | {/* <div className="message"> | 63 | {/* <div className="message"> |
| 65 | {message.message} | 64 | {message.message} |
| 66 | </div> */} | 65 | </div> */} |
| 67 | <div className="message" dangerouslySetInnerHTML={{ __html: formattedMessage }} /> | 66 | <div className="message" dangerouslySetInnerHTML={{ __html: message.message }} /> |
| 68 | </div> | 67 | </div> |
| 69 | </div> | 68 | </div> |
| 70 | ) | 69 | ) | ... | ... |
-
Please register or sign in to post a comment