fixes
Showing
4 changed files
with
111 additions
and
18 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 | } | ... | ... |
| 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"> |
| 6 | <SuggestedOptions /> | 10 | {!startedInteraction ? ( |
| 11 | <SuggestedOptions setChatInput={setChatInput}/> | ||
| 12 | ) : ( | ||
| 13 | <> | ||
| 7 | <div className="chat-log"> | 14 | <div className="chat-log"> |
| 8 | {chatLog.map((message, index) => ( | 15 | {chatLog.map((message, index) => ( |
| 9 | <ChatMessage key={index} message={message} /> | 16 | <ChatMessage key={index} message={message} /> |
| 10 | ))} | 17 | ))} |
| 11 | </div> | 18 | </div> |
| 19 | |||
| 20 | </> | ||
| 21 | )} | ||
| 12 | <div className="chat-input-holder"> | 22 | <div className="chat-input-holder"> |
| 13 | <form className="form" onSubmit={handleSubmit}> | 23 | <form className="form" onSubmit={handleSubmit }> |
| 14 | <input | 24 | <input |
| 15 | rows="1" | 25 | rows="1" |
| 16 | value={chatInput} | 26 | value={chatInput} |
| 17 | onChange={(e)=> setChatInput(e.target.value)} | 27 | onChange={(e)=> { |
| 18 | className="chat-input-textarea" ></input> | 28 | setChatInput(e.target.value); |
| 19 | <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> | ||
| 20 | </form> | 35 | </form> |
| 21 | </div> | 36 | </div> |
| 22 | </section> | 37 | </section> |
| 38 | ) | ||
| 39 | } | ||
| 23 | 40 | ||
| 24 | // Individual Chat Message | ||
| 25 | const ChatMessage = ({ message }) => { | 41 | const ChatMessage = ({ message }) => { |
| 26 | return ( | 42 | return ( |
| 27 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | 43 | <div className={`chat-message ${message.user === "gpt" && "chatgpt"}`}> | ... | ... |
| 1 | const SuggestedOptions = () => ( | 1 | const SuggestedOptions = ({ setChatInput }) => { |
| 2 | <div> | 2 | const examples = ["What is the capital of France?", "Generate a poem about love", "Tell me a joke"]; |
| 3 | <h1>Welcome to ChatGPT Clone</h1> | 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> | ||
| 4 | <p>This chatbot is capable of answering questions and generating text based on the input you provide.</p> | 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"> | ||
| 5 | <h2>Examples</h2> | 14 | <h2>Examples</h2> |
| 6 | <ul> | 15 | <ul className="suggested-options"> |
| 7 | <li>What is the capital of France?</li> | 16 | {examples.map((example, index) => ( |
| 8 | <li>Generate a poem about love</li> | 17 | <li key={index} |
| 9 | <li>What is the most populous country in the world?</li> | 18 | onClick={() => handleExampleClick(example)}> |
| 19 | {example} | ||
| 20 | </li> | ||
| 21 | ))} | ||
| 10 | </ul> | 22 | </ul> |
| 23 | </div> | ||
| 24 | <div className="suggestedcol rack2"> | ||
| 11 | <h2>Capabilities</h2> | 25 | <h2>Capabilities</h2> |
| 12 | <ul> | 26 | <ul> |
| 13 | <li>Answering questions</li> | 27 | <li>Answering questions</li> |
| 14 | <li>Generating text</li> | 28 | <li>Generating text</li> |
| 15 | <li>Providing information on a variety of topics</li> | 29 | <li>Providing information on a variety of topics</li> |
| 16 | </ul> | 30 | </ul> |
| 31 | </div> | ||
| 32 | <div className="suggestedcol rack3"> | ||
| 17 | <h2>Limitations</h2> | 33 | <h2>Limitations</h2> |
| 18 | <ul> | 34 | <ul> |
| 19 | <li>The chatbot may not have the latest information</li> | 35 | <li>The chatbot may not have the latest information</li> |
| ... | @@ -21,6 +37,9 @@ const SuggestedOptions = () => ( | ... | @@ -21,6 +37,9 @@ const SuggestedOptions = () => ( |
| 21 | <li>The chatbot may not provide information in the desired format</li> | 37 | <li>The chatbot may not provide information in the desired format</li> |
| 22 | </ul> | 38 | </ul> |
| 23 | </div> | 39 | </div> |
| 24 | ); | 40 | </div> |
| 41 | ); | ||
| 42 | |||
| 43 | }; | ||
| 25 | 44 | ||
| 26 | export default SuggestedOptions; | 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