6c5b307b by RSA

fix

1 parent 61372a96
......@@ -43,7 +43,7 @@ function App() {
async function handleSubmit(e){
e.preventDefault();
// console.log(chatInput)
const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who', 'hey'];
const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who'];
const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi');
const inputMatches = chatInput.match(userInputRegex);
......
const SuggestedOptions = ({ setChatInput }) => {
const examples = ["What is the capital of France?", "Generate a poem about love", "Tell me a joke"];
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."];
const handleExampleClick = (example) => {
setChatInput(example);
};
......@@ -24,17 +24,17 @@ const SuggestedOptions = ({ setChatInput }) => {
<div className="suggestedcol rack2">
<h2>Capabilities</h2>
<ul>
<li>Answering questions</li>
<li>Generating text</li>
<li>Providing information on a variety of topics</li>
<li>Remembers the user's earlier statement in the ongoing discussion.</li>
<li>Allows the user to add more information or correct errors.</li>
<li>Trained to deny requests that are not appropriate.</li>
</ul>
</div>
<div className="suggestedcol rack3">
<h2>Limitations</h2>
<ul>
<li>The chatbot may not have the latest information</li>
<li>The chatbot may not be able to answer all questions</li>
<li>The chatbot may not provide information in the desired format</li>
<li>May sometimes give wrong or incorrect information.</li>
<li>May at times produce harmful instructions or biased content.</li>
<li>Limited knowledge of what's been happening in the world since 2021.</li>
</ul>
</div>
</div>
......
......@@ -26,14 +26,24 @@ app.use(require('morgan')('dev'))
// Primary Open AI Route
app.post('/api', async (req, res) => {
const { message, currentModel, temperature } = req.body;
let greetingPrompt = 'Hello, how can I assist you?'
const greetings = ['hi', 'hello', 'hey']
if (greetings.some((greeting) => message.toLowerCase().includes(greeting))) {
greetingPrompt = 'Hello, how can I help you today?'
}
const prompt = `${greetingPrompt}\n${message}`;
const response = await openai.createCompletion({
model: `${currentModel}`,// "text-davinci-003",
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.
${message}`,
prompt,
max_tokens: 2500,
temperature,
});
res.json({
message: response.data.choices[0].text,
})
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!