a0d3a866 by Leff Tubat

Fixed prompt response

1 parent 47ae0d7c
......@@ -109,7 +109,7 @@ function App() {
userModifiedInput = chatInput + "?";
}
}
let trained_prompt = chatInput + '. Respond without using markdown, HTML tags, or any special symbols for formatting.';
let chatLogNew = [...chatLog, { user: "user", message: `${userModifiedInput}`} ]
setChatInput("");
setChatLog(chatLogNew)
......@@ -120,7 +120,7 @@ function App() {
var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n")
let endpoint = getEndpoint(currentModel);
if(endpoint === "openAI") {
let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }];
let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: trained_prompt }];
setChatLogTurbo(chatLogTurboNew);
messages = JSON.stringify(chatLogTurboNew);
}
......@@ -191,16 +191,9 @@ function App() {
const regex = new RegExp(`\\b(${programmingKeywords.join('|')})\\b`, 'gi');
const matches = parsedData.match(regex);
if (!matches) {
var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>')).replace(/\*\*(.*?)\*\*/g, '$1').replace(/###\s(.+)/g, '$1');
var replaceTags = (parsedData.replace(/(?:\r\n|\r|\n)/g, '<br>'))
} else {
replaceTags = (parsedData
.replace(':',':<code>')
.replace('<?','&#60;?')
.replace('?>','?&#62;')
.replace(/\n/g, '<br>')
.replace(/\*\*(.*?)\*\*/g, '$1')
.replace(/###\s(.+)/g, '$1')
)
replaceTags = (parsedData.replace(':',':<code>').replace('<?','&#60;?').replace('?>','?&#62;').replace(/\n/g, '<br>'))
}
for (let i = 0; i < replaceTags.length; i++) {
......
......@@ -54,7 +54,6 @@ const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput, startedInterac
}
const ChatMessage = ({ message }) => {
const formattedMessage = message.message.replace(/\*\*(.*?)\*\*/g, '$1').replace(/###\s(.+)/g, '$1');
return (
<div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}>
<div className="chat-message-center" style={ message.user === "gpt" ? { background: "#ddf1f9"} : {}}>
......@@ -64,7 +63,7 @@ const ChatMessage = ({ message }) => {
{/* <div className="message">
{message.message}
</div> */}
<div className="message" dangerouslySetInnerHTML={{ __html: formattedMessage }} />
<div className="message" dangerouslySetInnerHTML={{ __html: message.message }} />
</div>
</div>
)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!