Skip to content

Commit

Permalink
Revert "Merge branch 'main' into dev"
Browse files Browse the repository at this point in the history
This reverts commit 5758d96, reversing
changes made to 0807318.
  • Loading branch information
janthonysantana committed Jun 26, 2024
1 parent 5758d96 commit 09642cc
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 237 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/main_mental-health-app-api.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/main_mental-health-app-web.yml

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name="description"
content="This AI-Driven Mental Health Companion app provides mental health support through conversational AI, offering personalized advice, mood tracking, and mental health resources based on user inputs and interaction history. "
/>
<title>Earlent - Mental Health Companion</title>
<title>Mental Health Companion</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mental-health-app-client",
"private": true,
"version": "1.1.2",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite --port 3000 ",
Expand Down
7 changes: 3 additions & 4 deletions client/src/Components/authComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useContext } from 'react';
import axios from 'axios';
import apiServerAxios from '../api/axios';
import { useNavigate } from 'react-router-dom';
import { UserContext } from './userContext';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -106,7 +105,7 @@ function AuthComponent() {
e.preventDefault();
setLoading(true);
try {
const response = await apiServerAxios.post('/api/user/login', { username, password });
const response = await axios.post('/api/user/login', { username, password });
if (response && response.data) {
const userId = response.data.userId;
localStorage.setItem('token', response.data.access_token); // Ensure this is correctly saving the token
Expand Down Expand Up @@ -134,7 +133,7 @@ function AuthComponent() {
e.preventDefault();
setLoading(true);
try {
const response = await apiServerAxios.post('/api/user/signup', {
const response = await axios.post('/api/user/signup', {
username,
email,
password,
Expand Down Expand Up @@ -172,7 +171,7 @@ function AuthComponent() {
e.preventDefault();
setLoading(true);
try {
const response = await apiServerAxios.post('/api/user/anonymous_signin');
const response = await axios.post('/api/user/anonymous_signin');
if (response && response.data) {
const userId = null;
localStorage.setItem('token', response.data.access_token); // Ensure this is correctly saving the token
Expand Down
52 changes: 28 additions & 24 deletions client/src/Components/chatComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect, useContext, useCallback, useRef } from 'react';
import axios from 'axios';
import apiServerAxios from '../api/axios';
import { InputAdornment, IconButton, Box, Card, CardContent, Typography, TextField, Button, List, ListItem, ListItemAvatar, ListItemText, CircularProgress, Snackbar, Divider, Avatar, Tooltip } from '@mui/material';
import { InputAdornment,Switch, IconButton, Box, Card, CardContent, Typography, TextField, Button, List, ListItem, ListItemAvatar, ListItemText, CircularProgress, Snackbar, Divider, Avatar, Tooltip } from '@mui/material';
import MuiAlert from '@mui/material/Alert';
import SendIcon from '@mui/icons-material/Send';
import MicIcon from '@mui/icons-material/Mic';
Expand Down Expand Up @@ -49,7 +48,7 @@ const ChatComponent = () => {
event.preventDefault(); // Prevents the IconButton from triggering form submissions if used in forms
setVoiceEnabled(!voiceEnabled);
};

const speak = (text) => {

if (!voiceEnabled || text === currentPlayingMessage) {
Expand Down Expand Up @@ -79,7 +78,7 @@ const ChatComponent = () => {
synth.speak(utterance);
};

if (synth.getVoices().length === 0) {
if (synth.getVoices().length === 0){
synth.onvoiceschanged = setVoiceAndSpeak;
} else {
setVoiceAndSpeak();
Expand All @@ -92,13 +91,15 @@ const ChatComponent = () => {
setIsLoading(true);
setIsFetchingMessage(true);
try {
const response = await apiServerAxios.post(`/api/ai/mental_health/welcome/${userId}`, {
const response = await fetch(`/api/ai/mental_health/welcome/${userId}`, {
method: 'POST',
headers: {
"Content-Type": "application/json"
'Content-Type': 'application/json'
}
});
if (response && response.data) {
const data = response.data
const data = await response.json();
console.log(data);
if (response.ok) {
setWelcomeMessage(data.message);
if (voiceEnabled && data.message) { // Ensure voice is enabled and the message is not empty
speak(data.message);
Expand Down Expand Up @@ -133,10 +134,13 @@ const ChatComponent = () => {
if (chatId === null) return;
setIsLoading(true);
try {
const response = await apiServerAxios.patch(`/api/ai/mental_health/finalize/${userId}/${chatId}`, {
const response = await fetch(`/api/ai/mental_health/finalize/${userId}/${chatId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
if (response) {

const data = await response.json();
if (response.ok) {
setSnackbarMessage('Chat finalized successfully');
setSnackbarSeverity('success');
// Reset chat state to start a new chat
Expand Down Expand Up @@ -165,19 +169,19 @@ const ChatComponent = () => {


try {
const body = {
const body = JSON.stringify({
prompt: input,
turn_id: turnId
};
const response = await apiServerAxios.post(`/api/ai/mental_health/${userId}/${chatId}`, {
headers: {
"Content-Type": "application/json"
},
...body
});
const response = await fetch(`/api/ai/mental_health/${userId}/${chatId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: body
});

const data = response.data;
if (response && data) {
const data = await response.json();
console.log(data);
if (response.ok) {
setMessages(prev => [...prev, { message: input, sender: 'user' }, { message: data, sender: 'agent' }]);
// Speak the agent's message immediately after it's received and processed
if (voiceEnabled && data) { // Ensure voice is enabled and the message is not empty
Expand Down Expand Up @@ -277,11 +281,11 @@ const sendAudioToServer = (audioBlob) => {
formData.append('audio', audioBlob);
setIsLoading(true);

apiServerAxios.post('/api/ai/mental_health/voice-to-text', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
axios.post('/api/ai/mental_health/voice-to-text', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
const { message } = response.data;
setInput(message);
Expand Down
12 changes: 5 additions & 7 deletions client/src/Components/chatInterface.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect, useContext,useCallback, useRef } from 'react';
import axios from 'axios';
import apiServerAxios from '../api/axios';
import { InputAdornment,IconButton,Box, Card, CardContent, Typography, TextField, Button, List, ListItem,ListItemAvatar, ListItemText, CircularProgress, Snackbar, Divider, Avatar, Tooltip } from '@mui/material';
import { InputAdornment,IconButton,Box,Switch, Card, CardContent, Typography, TextField, Button, List, ListItem,ListItemAvatar, ListItemText, CircularProgress, Snackbar, Divider, Avatar, Tooltip } from '@mui/material';
import MuiAlert from '@mui/material/Alert';
import SendIcon from '@mui/icons-material/Send';
import MicIcon from '@mui/icons-material/Mic';
Expand Down Expand Up @@ -227,11 +226,10 @@ const sendAudioToServer = (audioBlob) => {
formData.append('audio', audioBlob);
setIsLoading(true);

apiServerAxios.post('/api/ai/mental_health/voice-to-text', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
axios.post('/api/ai/mental_health/voice-to-text', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
const { message } = response.data;
Expand Down
5 changes: 2 additions & 3 deletions client/src/Components/chatLogManager.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import axios from 'axios';
import apiServerAxios from '../api/axios';
import {
Button, Snackbar, Alert, Tooltip, Paper, Typography, CircularProgress, TextField,
Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle
Expand Down Expand Up @@ -59,7 +58,7 @@ function ChatLogManager() {
const endpoint = range ? '/api/user/download_chat_logs/range' : '/api/user/download_chat_logs';
const params = range ? { params: { start_date: startDate, end_date: endDate } } : {};

const response = await apiServerAxios.get(endpoint, {
const response = await axios.get(endpoint, {
...params,
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
Expand Down Expand Up @@ -92,7 +91,7 @@ function ChatLogManager() {
const endpoint = dialogRange ? '/api/user/delete_chat_logs/range' : '/api/user/delete_chat_logs';
const params = dialogRange ? { params: { start_date: startDate, end_date: endDate } } : {};

const response = await apiServerAxios.delete(endpoint, {
const response = await axios.delete(endpoint, {
...params,
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
Expand Down
5 changes: 2 additions & 3 deletions client/src/Components/checkInForm.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import apiServerAxios from '../api/axios';
import PropTypes from 'prop-types';
import { useParams } from 'react-router-dom';
import {
Expand Down Expand Up @@ -35,7 +34,7 @@ function CheckInForm({ userId, update }) {
if (update && checkInId) {
// Fetch existing check-in data
setLoading(true);
apiServerAxios.get(`/api/check-in/${checkInId}`,{
axios.get(`/api/check-in/${checkInId}`,{
headers: {
'Authorization': `Bearer ${token}` // Ensure the Authorization header is set
}
Expand Down Expand Up @@ -79,7 +78,7 @@ function CheckInForm({ userId, update }) {
const data = { user_id: userId, check_in_time: checkInTime, frequency, notify };
console.log('Submitting:', data);
try {
const response = await apiServerAxios[method](url, data, config);
const response = await axios[method](url, data, config);
console.log('Success:', response.data.message);
setSnackbar({ open: true, message: response.data.message, severity: 'success' });
// Optionally reset form or handle next steps
Expand Down
Loading

0 comments on commit 09642cc

Please sign in to comment.