e5ab7e31 by RSA

fix conflict

2 parents cefc0887 6c5b307b
...@@ -42,7 +42,7 @@ function App() { ...@@ -42,7 +42,7 @@ function App() {
42 42
43 async function handleSubmit(e){ 43 async function handleSubmit(e){
44 e.preventDefault(); 44 e.preventDefault();
45 const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who', 'hey']; 45 const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who'];
46 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); 46 const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi');
47 const inputMatches = chatInput.match(userInputRegex); 47 const inputMatches = chatInput.match(userInputRegex);
48 48
......
1 const SuggestedOptions = ({ setChatInput }) => { 1 const SuggestedOptions = ({ setChatInput }) => {
2 const examples = ["What is the capital of France?", "Generate a poem about love", "Tell me a joke"]; 2 const examples = ["Write an email requesting a 3-day vacation leave to my manager.", "Compose a song about nationalism and love for the country.", "Give me 3 easy-to-cook food recipes that I can prepare for a date night at home."];
3 const handleExampleClick = (example) => { 3 const handleExampleClick = (example) => {
4 setChatInput(example); 4 setChatInput(example);
5 }; 5 };
...@@ -24,17 +24,17 @@ const SuggestedOptions = ({ setChatInput }) => { ...@@ -24,17 +24,17 @@ const SuggestedOptions = ({ setChatInput }) => {
24 <div className="suggestedcol rack2"> 24 <div className="suggestedcol rack2">
25 <h2>Capabilities</h2> 25 <h2>Capabilities</h2>
26 <ul> 26 <ul>
27 <li>Answering questions</li> 27 <li>Remembers the user's earlier statement in the ongoing discussion.</li>
28 <li>Generating text</li> 28 <li>Allows the user to add more information or correct errors.</li>
29 <li>Providing information on a variety of topics</li> 29 <li>Trained to deny requests that are not appropriate.</li>
30 </ul> 30 </ul>
31 </div> 31 </div>
32 <div className="suggestedcol rack3"> 32 <div className="suggestedcol rack3">
33 <h2>Limitations</h2> 33 <h2>Limitations</h2>
34 <ul> 34 <ul>
35 <li>The chatbot may not have the latest information</li> 35 <li>May sometimes give wrong or incorrect information.</li>
36 <li>The chatbot may not be able to answer all questions</li> 36 <li>May at times produce harmful instructions or biased content.</li>
37 <li>The chatbot may not provide information in the desired format</li> 37 <li>Limited knowledge of what's been happening in the world since 2021.</li>
38 </ul> 38 </ul>
39 </div> 39 </div>
40 </div> 40 </div>
......
...@@ -26,14 +26,24 @@ app.use(require('morgan')('dev')) ...@@ -26,14 +26,24 @@ app.use(require('morgan')('dev'))
26 // Primary Open AI Route 26 // Primary Open AI Route
27 app.post('/api', async (req, res) => { 27 app.post('/api', async (req, res) => {
28 const { message, currentModel, temperature } = req.body; 28 const { message, currentModel, temperature } = req.body;
29
30 let greetingPrompt = 'Hello, how can I assist you?'
31 const greetings = ['hi', 'hello', 'hey']
32
33 if (greetings.some((greeting) => message.toLowerCase().includes(greeting))) {
34 greetingPrompt = 'Hello, how can I help you today?'
35 }
36
37 const prompt = `${greetingPrompt}\n${message}`;
38
29 const response = await openai.createCompletion({ 39 const response = await openai.createCompletion({
30 model: `${currentModel}`,// "text-davinci-003", 40 model: `${currentModel}`,// "text-davinci-003",
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. 41 prompt,
32 ${message}`,
33 max_tokens: 2500, 42 max_tokens: 2500,
34 temperature, 43 temperature,
35 }); 44 });
36 45
46
37 res.json({ 47 res.json({
38 message: response.data.choices[0].text, 48 message: response.data.choices[0].text,
39 }) 49 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!