Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Patient convo #19

Merged
merged 35 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
02db8d0
show user message on patient home page
jdrco Jan 7, 2024
e6bf59a
faster response for user message
jdrco Jan 7, 2024
bdabf99
first fetch of the convo
jdrco Jan 7, 2024
146501d
add basic practitioner dash
owencooke Jan 7, 2024
e235615
fix auth user problem
owencooke Jan 7, 2024
e84b86c
add snapshot listener and clear form
owencooke Jan 7, 2024
a9a3066
clickable rows lead to patient deets page
owencooke Jan 7, 2024
d86f5e3
Add files via upload
mfdavies Jan 7, 2024
02e2bf4
Delete cloudbuild.yaml
mfdavies Jan 7, 2024
0067bed
Add files via upload
mfdavies Jan 7, 2024
700d596
Update .gitignore and firebase.json, delete unused images and files, …
ldbonkowski Jan 7, 2024
e75ce06
Add Firebase API URL and update API endpoints
ldbonkowski Jan 7, 2024
cc03a36
Add new images and update HTML files
ldbonkowski Jan 7, 2024
085344e
Update Dockerfile
mfdavies Jan 7, 2024
42a6fb5
Update hosting public directory
ldbonkowski Jan 7, 2024
31c717e
Update build and outDir paths in firebase.json and vite.config.js
ldbonkowski Jan 7, 2024
1def292
Update Dockerfile
mfdavies Jan 7, 2024
b66d311
Create main.py
mfdavies Jan 7, 2024
b739d21
Add files via upload
mfdavies Jan 7, 2024
91d1224
Add files via upload
mfdavies Jan 7, 2024
87b6dc2
Delete backend/server/Dockerfile
mfdavies Jan 7, 2024
fd5bb88
Add files via upload
mfdavies Jan 7, 2024
3e3ae08
Add files via upload
mfdavies Jan 7, 2024
3a47b54
Update main.py
mfdavies Jan 7, 2024
9982fa7
Update main.py
mfdavies Jan 7, 2024
89329bb
Update main.py
mfdavies Jan 7, 2024
48620f9
Test Railway
mfdavies Jan 7, 2024
915e410
Update Main
mfdavies Jan 7, 2024
f5ed9b1
Update main.py
mfdavies Jan 7, 2024
602979f
Update main.py
mfdavies Jan 7, 2024
3b27182
Update main.py
mfdavies Jan 7, 2024
398d884
mac requirements
bhagya2002 Jan 7, 2024
4e09d69
completed exercise page patients
bhagya2002 Jan 7, 2024
91208a6
Merge branch 'main' into patient-convo
jdrco Jan 7, 2024
63173dd
fix merge conflicts
jdrco Jan 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/venv
*venv
*.env
*.pyc
Expand Down
28 changes: 26 additions & 2 deletions backend/server/src/conversation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def send_message():
user_doc_ref=user_doc_ref, conversaton_id=conversation_id
)

# Store audio in a temp file
message = request.json.get("message")

# Generate a reply using the Conversation object
reply = conversation.generate_reply(message)
return jsonify({"reply": reply}), 200

@conversation_blueprint.route("/transcribe", methods=["POST"])
def transcribe():

# Store audio in a temp file
audio = request.files["audioFile"]
temp_audio_path = os.path.join(tempfile.gettempdir(), "received_audio.wav")
Expand All @@ -54,5 +64,19 @@ def send_message():
os.remove(temp_audio_path)

# Generate a reply using the Conversation object
reply = conversation.generate_reply(message)
return jsonify({"reply": reply}), 200
return jsonify({"user_msg": message}), 200

@conversation_blueprint.route('/end', methods=['POST'])
def end():
if 'conversation_id' not in session:
return jsonify({'reply': 'No Conversation to end'}), 200
conversation_id = session.pop('conversation_id')
practitioner = request.args.get('practitioner')
patient = request.args.get('patient')

user_doc_ref = users_ref.document(practitioner).collection("patients").document(patient)

# Retrieve the Conversation object based on the conversation ID
conversation = Conversation(user_doc_ref, conversaton_id=conversation_id)
summary = conversation.end_conversation()
return jsonify({'reply': summary}), 200
1 change: 1 addition & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
'warn',
{ allowConstantExport: true },
],
"react/prop-types": "off"
},
}
35 changes: 30 additions & 5 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"@splinetool/runtime": "^1.0.18",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.1"
"react-router-dom": "^6.21.1",
"typewriter-effect": "^2.21.0"
},
"devDependencies": {
"@types/react": "^18.2.43",
Expand Down
87 changes: 56 additions & 31 deletions frontend/src/views/patient/PatientHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,42 @@ import RecordButton from "./components/RecordButton";
import Conversation from './components/Conversation';
import Exercises from './components/Exercises';
import "./styles.css";
import { useState, useEffect, useCallback } from 'react';
import VoiceAI from './components/VoiceAI';
import axios from 'axios';
import Skeleton from './components/Skeleton';

const PatientHome = () => {
const messages = [
{
sender: 'patient',
text: 'Hi there, and I was hoping to try something new today. Can you guide me through a specific exercise from the set you provided?',
},
{
sender: 'ai',
text: "Of course! I'm glad to hear you've been keeping up with your exercises. Which one were you thinking of trying, or do you have a specific area you'd like to focus on today?",
},
{
sender: 'patient',
text: 'Hi there, and I was hoping to try something new today. Can you guide me through a specific exercise from the set you provided?',
},
{
sender: 'ai',
text: "Of course! I'm glad to hear you've been keeping up with your exercises. Which one were you thinking of trying, or do you have a specific area you'd like to focus on today?",
},
];
const [convo, setConvo] = useState({
user: null,
gpt: null,
});

const updateUserMessage = useCallback((newMessage) => {
setConvo((prevConvo) => ({ ...prevConvo, user: newMessage }));
}, []);

const updateGptResponse = useCallback((newResponse) => {
setConvo((prevConvo) => ({ ...prevConvo, gpt: newResponse }));
}, []);

useEffect(() => {
const startConversation = async () => {
const queryParams = new URLSearchParams({
patient: 'demo',
practitioner: 'demo',
});
try {
const response = await axios.get(
`http://localhost:8080/conversation/start?${queryParams.toString()}`
);
setConvo((prevConvo) => ({ ...prevConvo, gpt: response.data.reply }));
} catch (error) {
console.error('Error fetching conversation start:', error);
}
};
startConversation();
}, []);

return (
<div className="flex flex-col h-screen">
Expand All @@ -35,28 +51,37 @@ const PatientHome = () => {
<h1 className="text-4xl font-medium">Welcome Back</h1>
<div className="text-3xl">John</div>
</header>
<Conversation messages={messages} />
<form className="flex items-center">
<input
type="text"
placeholder="You can type here..."
className="input input-bordered w-full max-w-xs mr-2"
/>
<button className="btn btn-neutral">Prompt</button>
</form>
{/* <Conversation messages={messages} /> */}
<div className="flex flex-col gap-4">
<p className="text-base">{convo.user}</p>
<p className="text-xl font-medium transition-opacity">
{convo.gpt !== null
? convo.gpt
: <Skeleton />}
</p>
</div>
<form className="flex items-center">
<input
type="text"
placeholder="You can type here..."
className="input input-bordered w-full max-w-xs mr-2"
/>
<button className="btn btn-neutral">Prompt</button>
</form>
</div>
<div className="w-px mt-40 mb-40 bg-gray-200"></div>
<div className="w-1/3 right-column">
<Exercises />
</div>
</div>
</main>
<RecordButton />
<div className="relative">
<div className="absolute bottom-8 left-1/2 transform -translate-x-1/2">
{/* <Ai3D /> */}
</div>
<VoiceAI
updateUserMessage={updateUserMessage}
updateGptResponse={updateGptResponse}
/>
</div>
{/* TODO: finish button that calls conversation/end */}
</div>
);
};
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/views/patient/components/Ai3D.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/views/patient/components/Conversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Conversation = ({ messages }) => {
}, [messages]);

return (
<div className="h-64 overflow-y-auto pr-24">
<div className="h-64 overflow-y-auto pr-32">
{messages.map((message, index) => (
<div key={index} className={`h-32 flex items-center justify-center ${message.sender === 'patient' ? 'text-sm text-gray-700' : 'text-sm font-medium text-gray-900'}`}>
<p className="-center text-lg">{message.text}</p>
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/views/patient/components/Skeleton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const Skeleton = () => {
return (
<div className="flex flex-col gap-4 w-52">
<div className="skeleton h-4 w-28"></div>
<div className="skeleton h-4 w-full"></div>
<div className="skeleton h-4 w-full"></div>
</div>
);
};

export default Skeleton;
Loading