Skip to content

Commit

Permalink
ai assistant bug fix and user model update
Browse files Browse the repository at this point in the history
  • Loading branch information
tharoosha committed Nov 1, 2023
1 parent 7823148 commit 6acbb8a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 14 deletions.
45 changes: 45 additions & 0 deletions backend/models/User.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,51 @@ export const UserSchema = new mongoose.Schema({
// Saturday: { Joy: Number, Surprise: Number, Anger: Number, Sad: Number, Happy: Number },
// Sunday: { Joy: Number, Surprise: Number, Anger: Number, Sad: Number, Happy: Number },
// },

emotions: {
Monday: {
Joy: {type: Number},
Surprise: {type: Number},
Anger: {type: Number},
Sad: {type: Number},
Happy: {type: Number} },
Tuesday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
Wednesday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
Thursday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
Friday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
Saturday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
Sunday: {
Joy: {type:Number},
Surprise: {type:Number},
Anger: {type:Number},
Sad: {type:Number},
Happy: {type:Number} },
},
});

export default mongoose.model.Users || mongoose.model('User', UserSchema );
29 changes: 15 additions & 14 deletions frontend/src/pages/AI_Assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ const AI_Assistant = () => {
setChatLog(updatedChatLog);
// console.log('{$process.env.REACT_APP_SERVER_ENDPOINT}')



setLoading(true);

axios
Expand All @@ -133,24 +131,27 @@ const AI_Assistant = () => {
setChatLog(updatedChatLogWithAI);
setResponse(response.data.result);
setLoading(false);

axios
.post(`http://localhost:5001/api/emotion_analyze`, { message: message })
.then((response) => {
setEmotion(response.data.emotion);
console.log(message)
console.log(response.data.emotion);
updateRecommendation({"recommendation" : response.data.emotion})
console.log('database update done')
})
.catch((error) => console.error(error));

})
.catch((error) => {
console.error(error);
setLoading(false);
});

axios
.post(`http://localhost:5001/api/emotion_analyze`, { message: message })
.then((response) => {
setEmotion(response.data.emotion);

console.log(emotion);
updateRecommendation({"recommendation" : emotion})
console.log('database update done')

})
.catch((error) => console.error(error));




setMessage('');
};

Expand Down

0 comments on commit 6acbb8a

Please sign in to comment.