Merge branch 'master' of https://gitlab.baytech.ph/baytech/chatgpt.ai-pro.org in…
…to 26797_chatgpt_format3
Showing
4 changed files
with
28 additions
and
4 deletions
| ... | @@ -42,9 +42,32 @@ function App() { | ... | @@ -42,9 +42,32 @@ function App() { |
| 42 | 42 | ||
| 43 | async function handleSubmit(e){ | 43 | async function handleSubmit(e){ |
| 44 | e.preventDefault(); | 44 | e.preventDefault(); |
| 45 | let chatLogNew = [...chatLog, { user: "me", message: `${chatInput}`} ] | 45 | // console.log(chatInput) |
| 46 | const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who', 'hey']; | ||
| 47 | const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); | ||
| 48 | const inputMatches = chatInput.match(userInputRegex); | ||
| 49 | |||
| 50 | const userPunctuation = ['.', '?', '!', ':', ';', ',']; | ||
| 51 | const userPunctuationRegex = new RegExp(`${userPunctuation.join('')}$`, 'gi'); | ||
| 52 | const punctuationMatches = chatInput.match(userPunctuationRegex); | ||
| 53 | |||
| 54 | // console.log(punctuationMatches) | ||
| 55 | var userModifiedInput = chatInput | ||
| 56 | |||
| 57 | if (!punctuationMatches) { | ||
| 58 | if (!inputMatches) { | ||
| 59 | userModifiedInput = chatInput + "."; | ||
| 60 | // console.log("not a question!") | ||
| 61 | } else { | ||
| 62 | userModifiedInput = chatInput + "?"; | ||
| 63 | // console.log("its a question!") | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | let chatLogNew = [...chatLog, { user: "me", message: `${userModifiedInput}`} ] | ||
| 46 | setChatInput(""); | 68 | setChatInput(""); |
| 47 | setChatLog(chatLogNew) | 69 | setChatLog(chatLogNew) |
| 70 | |||
| 48 | // fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post | 71 | // fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post |
| 49 | const messages = chatLogNew.map((message) => message.message).join("\n") | 72 | const messages = chatLogNew.map((message) => message.message).join("\n") |
| 50 | 73 | ... | ... |
| 1 | import OpenAISVGLogo from './OpenAISVGLogo' | 1 | // import OpenAISVGLogo from './OpenAISVGLogo' |
| 2 | 2 | ||
| 3 | // Primary Chat Window | 3 | // Primary Chat Window |
| 4 | const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput}) => | 4 | const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput}) => |
| ... | @@ -26,7 +26,7 @@ const ChatMessage = ({ message }) => { | ... | @@ -26,7 +26,7 @@ const ChatMessage = ({ message }) => { |
| 26 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | 26 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> |
| 27 | <div className="chat-message-center"> | 27 | <div className="chat-message-center"> |
| 28 | <div className={`avatar ${message.user === "gpt" && "chatgpt"}`}> | 28 | <div className={`avatar ${message.user === "gpt" && "chatgpt"}`}> |
| 29 | {message.user === "gpt" ? <img className="ai-logo" src="../assets/images/bot.png" width="30px"/> : <img className="ai-logo" src="../assets/images/user.svg" />} | 29 | {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" />} |
| 30 | </div> | 30 | </div> |
| 31 | {/* <div className="message"> | 31 | {/* <div className="message"> |
| 32 | {message.message} | 32 | {message.message} | ... | ... |
| 1 | const SideMenu = ({ clearChat, currentModel, setCurrentModel, models, setTemperature, temperature }) => | 1 | const SideMenu = ({ clearChat, currentModel, setCurrentModel, models, setTemperature, temperature }) => |
| 2 | <aside className="sidemenu"> | 2 | <aside className="sidemenu"> |
| 3 | <div className="ai-logo-container"> | 3 | <div className="ai-logo-container"> |
| 4 | <img className="ai-logo" src="../assets/images/AIPRO-WHITE.png" height="50px"/> | 4 | <img className="ai-logo" alt="Ai-pro logo" src="../assets/images/AIPRO-WHITE.png" height="50px"/> |
| 5 | </div> | 5 | </div> |
| 6 | <div className="side-menu-button" onClick={clearChat}> | 6 | <div className="side-menu-button" onClick={clearChat}> |
| 7 | <span>+</span> | 7 | <span>+</span> | ... | ... |
| ... | @@ -35,6 +35,7 @@ span.info { | ... | @@ -35,6 +35,7 @@ span.info { |
| 35 | color: #101827 !important; | 35 | color: #101827 !important; |
| 36 | font-size: 16px !important; | 36 | font-size: 16px !important; |
| 37 | box-shadow: 0px 7px 6px -6px black !important; | 37 | box-shadow: 0px 7px 6px -6px black !important; |
| 38 | height: 45px; | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | .chat-message.chatgpt { | 41 | .chat-message.chatgpt { | ... | ... |
-
Please register or sign in to post a comment