0e07a1b8 by Ryan

Merge branch '26903_chatgpt_output_error' into '1DEVT'

26903 chatgpt output error

See merge request !13
2 parents 2f8573ff 9937506d
......@@ -42,9 +42,32 @@ function App() {
async function handleSubmit(e){
e.preventDefault();
let chatLogNew = [...chatLog, { user: "me", message: `${chatInput}`} ]
// console.log(chatInput)
const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are'];
const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi');
const inputMatches = chatInput.match(userInputRegex);
const userPunctuation = ['.', '?', '!', ':', ';', ','];
const userPunctuationRegex = new RegExp(`[${userPunctuation.join('')}]`, 'gi');
const punctuationMatches = chatInput.match(userPunctuationRegex);
// console.log(punctuationMatches)
var userModifiedInput = chatInput
if (!punctuationMatches) {
if (!inputMatches) {
userModifiedInput = chatInput + ".";
// console.log("not a question!")
} else {
userModifiedInput = chatInput + "?";
// console.log("its a question!")
}
}
let chatLogNew = [...chatLog, { user: "me", message: `${userModifiedInput}`} ]
setChatInput("");
setChatLog(chatLogNew)
// fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post
const messages = chatLogNew.map((message) => message.message).join("\n")
......
import OpenAISVGLogo from './OpenAISVGLogo'
// import OpenAISVGLogo from './OpenAISVGLogo'
// Primary Chat Window
const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput}) =>
......@@ -26,7 +26,7 @@ const ChatMessage = ({ message }) => {
<div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}>
<div className="chat-message-center">
<div className={`avatar ${message.user === "gpt" && "chatgpt"}`}>
{message.user === "gpt" ? <img className="ai-logo" src="../assets/images/bot.png" width="30px"/> : <img className="ai-logo" src="../assets/images/user.svg" />}
{message.user === "gpt" ? <img className="ai-logo" alt="Ai-pro bot" src="../assets/images/bot.png" width="30px"/> : <img className="ai-logo" alt="Ai-pro user" src="../assets/images/user.svg" />}
</div>
{/* <div className="message">
{message.message}
......
const SideMenu = ({ clearChat, currentModel, setCurrentModel, models, setTemperature, temperature }) =>
<aside className="sidemenu">
<div className="ai-logo-container">
<img className="ai-logo" src="../assets/images/AIPRO-WHITE.png" height="50px"/>
<img className="ai-logo" alt="Ai-pro logo" src="../assets/images/AIPRO-WHITE.png" height="50px"/>
</div>
<div className="side-menu-button" onClick={clearChat}>
<span>+</span>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!