fix conflict
Showing
5 changed files
with
132 additions
and
9 deletions
| ... | @@ -209,3 +209,60 @@ | ... | @@ -209,3 +209,60 @@ |
| 209 | .submit:hover { | 209 | .submit:hover { |
| 210 | background:#066d55; | 210 | background:#066d55; |
| 211 | } | 211 | } |
| 212 | |||
| 213 | .suggested { | ||
| 214 | display: block; | ||
| 215 | z-index: 99999999; | ||
| 216 | color: #000; | ||
| 217 | position: absolute; | ||
| 218 | text-align: center; | ||
| 219 | padding: 25px; | ||
| 220 | |||
| 221 | top: 0; | ||
| 222 | right: 0; | ||
| 223 | bottom: 89px; | ||
| 224 | left: 0; | ||
| 225 | overflow-y: scroll; | ||
| 226 | } | ||
| 227 | |||
| 228 | .suggestedcol { | ||
| 229 | width: 30%; | ||
| 230 | display: inline-block; | ||
| 231 | margin: 0; | ||
| 232 | text-align: center; | ||
| 233 | vertical-align: top; | ||
| 234 | } | ||
| 235 | |||
| 236 | .suggestedcol ul { | ||
| 237 | list-style: none; | ||
| 238 | padding: 0 25px; | ||
| 239 | } | ||
| 240 | |||
| 241 | .suggestedrow.title { | ||
| 242 | padding: 100px 20px; | ||
| 243 | } | ||
| 244 | |||
| 245 | .suggestedcol ul li { | ||
| 246 | background: #5c6aa529; | ||
| 247 | padding: 10px; | ||
| 248 | border-radius: 5px; | ||
| 249 | margin: 10px 0; | ||
| 250 | margin-top: 10px; | ||
| 251 | margin-right: 0px; | ||
| 252 | margin-bottom: 10px; | ||
| 253 | margin-left: 0px; | ||
| 254 | } | ||
| 255 | |||
| 256 | ul.suggested-options { | ||
| 257 | cursor: pointer; | ||
| 258 | } | ||
| 259 | |||
| 260 | |||
| 261 | @media (max-width: 991px) { | ||
| 262 | .suggestedcol { | ||
| 263 | width: 100%; | ||
| 264 | } | ||
| 265 | .suggestedrow.title { | ||
| 266 | padding: 10px 10px 0 10px; | ||
| 267 | } | ||
| 268 | } | ... | ... |
| ... | @@ -78,6 +78,7 @@ function App() { | ... | @@ -78,6 +78,7 @@ function App() { |
| 78 | currentModel, | 78 | currentModel, |
| 79 | }) | 79 | }) |
| 80 | }); | 80 | }); |
| 81 | |||
| 81 | const data = await response.json(); | 82 | const data = await response.json(); |
| 82 | const parsedData = data.message.trim(); | 83 | const parsedData = data.message.trim(); |
| 83 | const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; | 84 | const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; |
| ... | @@ -96,6 +97,7 @@ function App() { | ... | @@ -96,6 +97,7 @@ function App() { |
| 96 | } catch (error) { | 97 | } catch (error) { |
| 97 | const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again."; | 98 | const errorMsg = "We apologize for any inconvenience caused due to the delay in the response time. Please try again."; |
| 98 | setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ]) | 99 | setChatLog([...chatLogNew, { user: "gpt", message: `<div class="errormsg"><span>i</span><div class="msg">${errorMsg}</div></div>`} ]) |
| 100 | |||
| 99 | } | 101 | } |
| 100 | } | 102 | } |
| 101 | 103 | ||
| ... | @@ -120,6 +122,7 @@ function App() { | ... | @@ -120,6 +122,7 @@ function App() { |
| 120 | temperature={temperature} | 122 | temperature={temperature} |
| 121 | clearChat={clearChat} | 123 | clearChat={clearChat} |
| 122 | /> | 124 | /> |
| 125 | |||
| 123 | <ChatBox | 126 | <ChatBox |
| 124 | chatInput={chatInput} | 127 | chatInput={chatInput} |
| 125 | chatLog={chatLog} | 128 | chatLog={chatLog} | ... | ... |
| 1 | // import OpenAISVGLogo from './OpenAISVGLogo' | 1 | import React, { useState } from "react"; |
| 2 | import SuggestedOptions from './suggestedOptions' | ||
| 2 | 3 | ||
| 3 | // Primary Chat Window | 4 | const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput}) => { |
| 4 | const ChatBox = ({chatLog, setChatInput, handleSubmit, chatInput}) => | 5 | |
| 6 | const [startedInteraction, setStartedInteraction] = useState(false); | ||
| 7 | |||
| 8 | return ( | ||
| 5 | <section className="chatbox"> | 9 | <section className="chatbox"> |
| 10 | {!startedInteraction ? ( | ||
| 11 | <SuggestedOptions setChatInput={setChatInput}/> | ||
| 12 | ) : ( | ||
| 13 | <> | ||
| 6 | <div className="chat-log"> | 14 | <div className="chat-log"> |
| 7 | {chatLog.map((message, index) => ( | 15 | {chatLog.map((message, index) => ( |
| 8 | <ChatMessage key={index} message={message} /> | 16 | <ChatMessage key={index} message={message} /> |
| 9 | ))} | 17 | ))} |
| 10 | </div> | 18 | </div> |
| 19 | |||
| 20 | </> | ||
| 21 | )} | ||
| 11 | <div className="chat-input-holder"> | 22 | <div className="chat-input-holder"> |
| 12 | <form className="form" onSubmit={handleSubmit}> | 23 | <form className="form" onSubmit={handleSubmit }> |
| 13 | <input | 24 | <input |
| 14 | rows="1" | 25 | rows="1" |
| 15 | value={chatInput} | 26 | value={chatInput} |
| 16 | onChange={(e)=> setChatInput(e.target.value)} | 27 | onChange={(e)=> { |
| 17 | className="chat-input-textarea" ></input> | 28 | setChatInput(e.target.value); |
| 18 | <button className="submit" type="submit">Submit</button> | 29 | }} |
| 30 | className="chat-input-textarea" > | ||
| 31 | </input> | ||
| 32 | <button className="submit" type="submit" onClick={(e)=> { | ||
| 33 | setStartedInteraction(true); | ||
| 34 | }}>Submit</button> | ||
| 19 | </form> | 35 | </form> |
| 20 | </div> | 36 | </div> |
| 21 | </section> | 37 | </section> |
| 38 | ) | ||
| 39 | } | ||
| 22 | 40 | ||
| 23 | // Individual Chat Message | ||
| 24 | const ChatMessage = ({ message }) => { | 41 | const ChatMessage = ({ message }) => { |
| 25 | return ( | 42 | return ( |
| 26 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | 43 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | ... | ... |
client/src/suggestedOptions.js
0 → 100644
| 1 | const SuggestedOptions = ({ setChatInput }) => { | ||
| 2 | const examples = ["What is the capital of France?", "Generate a poem about love", "Tell me a joke"]; | ||
| 3 | const handleExampleClick = (example) => { | ||
| 4 | setChatInput(example); | ||
| 5 | }; | ||
| 6 | |||
| 7 | return ( | ||
| 8 | <div className="suggested"> | ||
| 9 | <div className="suggestedrow title"> | ||
| 10 | <h1>Welcome to AI-PRO</h1> | ||
| 11 | <p>This chatbot is capable of answering questions and generating text based on the input you provide.</p> | ||
| 12 | </div> | ||
| 13 | <div className="suggestedcol rack1"> | ||
| 14 | <h2>Examples</h2> | ||
| 15 | <ul className="suggested-options"> | ||
| 16 | {examples.map((example, index) => ( | ||
| 17 | <li key={index} | ||
| 18 | onClick={() => handleExampleClick(example)}> | ||
| 19 | {example} | ||
| 20 | </li> | ||
| 21 | ))} | ||
| 22 | </ul> | ||
| 23 | </div> | ||
| 24 | <div className="suggestedcol rack2"> | ||
| 25 | <h2>Capabilities</h2> | ||
| 26 | <ul> | ||
| 27 | <li>Answering questions</li> | ||
| 28 | <li>Generating text</li> | ||
| 29 | <li>Providing information on a variety of topics</li> | ||
| 30 | </ul> | ||
| 31 | </div> | ||
| 32 | <div className="suggestedcol rack3"> | ||
| 33 | <h2>Limitations</h2> | ||
| 34 | <ul> | ||
| 35 | <li>The chatbot may not have the latest information</li> | ||
| 36 | <li>The chatbot may not be able to answer all questions</li> | ||
| 37 | <li>The chatbot may not provide information in the desired format</li> | ||
| 38 | </ul> | ||
| 39 | </div> | ||
| 40 | </div> | ||
| 41 | ); | ||
| 42 | |||
| 43 | }; | ||
| 44 | |||
| 45 | export default SuggestedOptions; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -28,7 +28,8 @@ app.post('/api', async (req, res) => { | ... | @@ -28,7 +28,8 @@ app.post('/api', async (req, res) => { |
| 28 | const { message, currentModel, temperature } = req.body; | 28 | const { message, currentModel, temperature } = req.body; |
| 29 | const response = await openai.createCompletion({ | 29 | const response = await openai.createCompletion({ |
| 30 | model: `${currentModel}`,// "text-davinci-003", | 30 | model: `${currentModel}`,// "text-davinci-003", |
| 31 | prompt: `${message}`, | 31 | prompt: `Converse as if you were an AI assistant. Be friendly and creative. Provide your answer in paragraph. If the answer have line of codes, enclose it with code tag. |
| 32 | ${message}`, | ||
| 32 | max_tokens: 2500, | 33 | max_tokens: 2500, |
| 33 | temperature, | 34 | temperature, |
| 34 | }); | 35 | }); | ... | ... |
-
Please register or sign in to post a comment