Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empathy #3

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e7b4cf3
update README.md
masonwang025 Aug 6, 2022
e2cc867
update README.md
masonwang025 Aug 6, 2022
e9733ed
done restructuring /data and updated README to contain repo structure
masonwang025 Aug 6, 2022
3e42900
restructured utility components and removed unused components
masonwang025 Aug 6, 2022
64c0dd7
repo restructuring done
masonwang025 Aug 6, 2022
f8cead0
fix typo
masonwang025 Aug 6, 2022
9346026
prevent lag issue
masonwang025 Aug 6, 2022
ffb9486
message box restructure
masonwang025 Aug 6, 2022
16883c8
update README.md
masonwang025 Aug 7, 2022
ef3516c
audio and text toggle added
masonwang025 Aug 7, 2022
9e5ef5b
toggle done
masonwang025 Aug 7, 2022
768aa50
update prompts to be more lenient regarding capitalization
masonwang025 Aug 7, 2022
33154b4
change wording in reading
masonwang025 Aug 8, 2022
cd7d6dc
change wording on message render
masonwang025 Aug 8, 2022
c1a86b6
change it to me
masonwang025 Aug 8, 2022
fd2da83
Update Preamble.tsx
masonwang025 Aug 8, 2022
660e071
fixed sentiment selection edge case
masonwang025 Aug 8, 2022
ca12a03
restructure /scripts and write local storage function
masonwang025 Aug 8, 2022
1c7325b
utility functions for writing to local storage
masonwang025 Aug 8, 2022
fb001a9
writing to local storage base done
masonwang025 Aug 8, 2022
f010b25
done writing parsed result to local storage
masonwang025 Aug 8, 2022
8becb8a
local storage dashboard progess done
masonwang025 Aug 8, 2022
4795ef0
reset default params
masonwang025 Aug 8, 2022
251cd95
add key
masonwang025 Aug 8, 2022
5af2e9b
fix attempt history saving reverse() issue
masonwang025 Aug 9, 2022
3c469bc
add ask noora page to navbar
masonwang025 Aug 9, 2022
cbf0aba
update styles for ask noora page
masonwang025 Aug 9, 2022
a584637
update github repo link
masonwang025 Aug 9, 2022
15aab9e
refactor onAudioEnd()
masonwang025 Aug 12, 2022
462dae5
remove autoplaying feature for ios devices
masonwang025 Aug 12, 2022
e712c93
update react-device-detect
masonwang025 Aug 12, 2022
d91bdc2
refactor message code and add exampleturns element
masonwang025 Aug 15, 2022
fbd2490
refactored into MessageStyleWrapper component
masonwang025 Aug 15, 2022
84e9048
refactor further
masonwang025 Aug 15, 2022
169f976
restructure logic behind messages
masonwang025 Aug 15, 2022
43b82d9
examples added for noora
masonwang025 Aug 15, 2022
450c1c7
change social skills to conversation skills
masonwang025 Aug 15, 2022
7c4c5fe
update spacing for letters on xl screen hero
masonwang025 Aug 15, 2022
2331687
update website wording again
masonwang025 Aug 15, 2022
60fadda
one last (hopefully) change to the wording
masonwang025 Aug 15, 2022
b873bc7
remove example turns
masonwang025 Aug 24, 2022
7667bb3
audio stops on route changes
masonwang025 Aug 29, 2022
3afe331
done adding instructions to noora module chat
masonwang025 Aug 29, 2022
3b06c4f
escape apostrophe
masonwang025 Aug 29, 2022
297ab51
microphone stops on second click implemented
masonwang025 Sep 6, 2022
e36ed3d
fix deploy error
masonwang025 Sep 6, 2022
c9f74ec
updated logo on homepage
masonwang025 Sep 30, 2022
88885a6
update chat window height
masonwang025 Sep 30, 2022
a04ce30
inital file for Empathy to be modified by Nathan
abhinavg4 Nov 2, 2022
00569c1
inital file for Empathy to be modified by Nathan
abhinavg4 Nov 2, 2022
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
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<p align="center">
<br/>
<a href="https://noora.stanford.edu" target="_blank"><img width="100px" style="margin-bottom:-20px; margin-left:20px" src="./public/img/logos/noora/lamp.png" /></a>
<h2 align="center"><b>Noora</b></h2>
<p align="center">Use AI to improve your social skills.</p>
<h1 align="center"><b>Noora</b></h1>
<p align="center">Use AI to improve your social conversation.</p>
<p align="center">
A platform utilizing conversational AI to improve the social skills of individuals with Autism Spectrum Disorder (ASD).
A platform utilizing conversational AI to improve the social conversation of individuals with Autism Spectrum Disorder (ASD).
</p>
<p align="center" style="align: center;">
<a href="https://med.stanford.edu/" target="_blank">
<img src="./public/img/logos/stanford/medicine.png" width="140px" alt="Stanford Medicine" style="margin-bottom:5px" />
</a>
<span style="visibility: hidden">x</span>
<a href="https://stanford.edu" target="_blank">
<img src="./public/img/logos/stanford/university.png" width="140px" alt="Stanford University" />
</a>
</p>
<p align="center" style="align: center;">
<a href="https://vercel.com/?utm_source=[stanford-oval]&utm_campaign=oss" target="_blank">
<img src="./public/img/logos/vercel/powered-by.svg" width="120px" alt="Powered by Vercel" />
<img src="./public/img/logos/vercel/powered-by.svg" width="150px" alt="Powered by Vercel" />
</a>
</p>
</p>
Expand All @@ -26,9 +20,9 @@

## Overview

Noora is is a research project led by Prof. Monica Lam, from Stanford University, with the goal of improving the social skills of people with Autism Spectrum Disorder (ASD). The project is a collaboration between <a href="https://oval.cs.stanford.edu" target="_blank">Stanford's Open Virtual Assistant Lab</a> and <a href="https://profiles.stanford.edu/lynn-koegel" target="_blank">Dr. Lynn Koegel</a> in Stanford's Dept. of Psychiatry and Behavioral Sciences.
Noora is is a research project led by Prof. Monica Lam, from Stanford University, with the goal of improving the social conversation of people with Autism Spectrum Disorder (ASD). The project is a collaboration between <a href="https://oval.cs.stanford.edu" target="_blank">Stanford's Open Virtual Assistant Lab</a> and <a href="https://profiles.stanford.edu/lynn-koegel" target="_blank">Dr. Lynn Koegel</a> from Stanford's Dept. of Psychiatry and Behavioral Sciences.

Dr. Koegel's intervention method, pivotal response training, has been shown to help individuals make friends, have romantic relationships, collaborate in the workplace, and engage in leisure activities. Because pivotal response training's applicability is restricted by the lack of trained professionals, Noora's goal is to automate the intervention, the success of which can have a great impact on society, as 1 in 54 children is currently diagnosed with ASD.
<!-- Dr. Koegel's intervention method, pivotal response training, has been shown to help individuals make friends, have romantic relationships, collaborate in the workplace, and engage in leisure activities. Because pivotal response training's applicability is restricted by the lack of trained professionals, Noora's goal is to automate the intervention, the success of which can have a great impact on society, as 1 in 54 children is currently diagnosed with ASD. -->

This project built with Next.js, Tailwind CSS, OpenAI's GPT-3, and Microsoft Azure.

Expand All @@ -52,4 +46,22 @@ For the speech-to-text and text-to-speech functionality, create an Azure speech
OPENAI_API_KEY=[your API key]
SPEECH_KEY=[your API key]
SPEECH_REGION=[your API key]
```
```

## Repo Structure

**`pages`**: all of the Next.js app's paths (e.g., `noora.tsx`, `_404.tsx`). These files simply return components, typically wrapped by the `<Page>` component.

**`components`**: the bulk of the website code. Folders under this directory reference the pages of the website, with the exception of `components/global` and `components/interfaces`.
- `components/interfaces` contains the code behind the Noora Chat feature and the Ask Noora feature.

**`data`**: all static or pre-written data, such as GPT-3 prompts, statement banks, routes.

**`scripts`**: code that is called by components.
- `/scripts/noora-chat` (and, more specifically, `get-reply.ts`) contains the logic and flow for Noora's replies, and is used in `MessageBox.tsx` (where users submit their message in the Noora Chat).

**`pages/api`**: the REST API endpoints. Rate limiting is in place for endpoints (implementation found in `scripts/rate-limit.ts`).
- `api/openai` calls OpenAI's Completion endpoint and returns the resulting `text` and `logprobs`.
- `api/get-speech-token.ts` retrieves an ephemeral authentication token for Microsoft Azure's speech service.

**`public`**: the public assets including images and static files.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@
"@headlessui/react": "^1.6.6",
"@heroicons/react": "^1.0.6",
"@tailwindcss/forms": "^0.5.2",
"@types/dateformat": "^5.0.0",
"@types/uuid": "^8.3.4",
"clsx": "^1.2.1",
"dateformat": "^5.0.3",
"fs": "^0.0.1-security",
"heroicons": "^2.0.10",
"lru-cache": "^7.13.1",
"microsoft-cognitiveservices-speech-sdk": "^1.22.0",
"next": "12.2.2",
"openai": "^3.0.0",
"openai-api": "^1.3.1",
"react": "18.2.0",
"react-anchor-link-smooth-scroll": "^1.0.12",
"react-circular-progressbar": "^2.1.0",
"react-device-detect": "^2.2.2",
"react-dom": "18.2.0",
"react-joyride": "^2.5.0",
"react-spinners": "^0.13.3",
"reactjs-percentage-circle": "^1.0.0",
"swr": "^1.3.0",
"universal-cookie": "^4.0.4",
"uuid": "^8.3.2"
},
Expand Down
Binary file added public/img/logos/stanford/engineering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/ask-noora/AskNoora.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import AskNooraComponent from "../interfaces/ask-noora-interface/AskNooraComponent";
import AskNooraComponent from "../interfaces/ask-noora/AskNooraComponent";

export default function AskNoora() {
const [q, setQ] = useState("");
Expand Down
70 changes: 70 additions & 0 deletions src/components/dashboard/AttemptHistory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from "react";
import useSWR from 'swr'
import dateFormat from "dateformat";
import { CircularProgressbarWithChildren } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';
import clsx from "clsx";
import Progress from "../interfaces/noora-chat/menu/sections/Progress";

export default function AttemptHistory() {
const { data } = useSWR("progress", key => {
const value = localStorage.getItem(key);
return !!value ? JSON.parse(value) : undefined;
})

return (
<div className="grid grid-cols-12 pt-3 gap-y-3">
{data && data.map((attempt: any, idx: number) => {
let dateStr = dateFormat(new Date(attempt.timeCompleted), "mmmm dS, h:MM TT");
return (
<div key={idx} className="col-span-12 flex gap-y-4 flex-col md:flex-row rounded-lg justify-between items-center text-noora-secondary px-5 py-6 bg-gray-100 border-2 border-gray-200">
<div className="text-center sm:text-left">
<p className="text-sm text-slate-500">
{dateStr}
</p>
<h1 className="text-2xl font-medium">Attempt {data.length - idx}</h1>
</div>
<div className="flex items-stretch flex-wrap justify-center flex-row gap-x-4 gap-y-3">
<ProgressCircle num={attempt.scores.total[0]} denom={attempt.scores.total[1]} title="total" />
<div className="border-gray-300 bg-gray-300 border-1 hidden sm:block"></div>
{Object.keys(attempt.scores).map((k: any) => {
k = k as keyof typeof attempt.scores
if (k == "total" || attempt.scores[k][1] == 0) return <div key={k}></div>
return <ProgressCircle key={k} num={attempt.scores[k][0]} denom={attempt.scores[k][1]} title={k} />
})}
</div>
</div>)
})
}
</div >
);
}

function ProgressCircle({ num, denom, title }: any) {
return <div className="w-24 h-24 text-xl">
<CircularProgressbarWithChildren styles={{
// Customize the root svg element
root: {},
// Customize the path, i.e. the "completed progress"
path: {
// Path color
stroke: `rgba(${title == "total" ? "105, 64, 182" : "62, 152, 199"}, ${num / denom})`,
// Whether to use rounded or flat corners on the ends - can use 'butt' or 'round'
strokeLinecap: 'butt',
},
// Customize the circle behind the path, i.e. the "total progress"
trail: {
// Trail color
stroke: '#dbdbdb',
// Whether to use rounded or flat corners on the ends - can use 'butt' or 'round'
strokeLinecap: 'butt',
// Rotate the trail
transform: 'rotate(0.25turn)',
transformOrigin: 'center center',
},
}} value={num} maxValue={denom} strokeWidth={12}>
<div className={clsx("text-xl", title == "total" ? "font-bold text-noora-primary-dark" : "text-noora-secondary")}>{`${num}/${denom}`}</div>
<div className={clsx("text-xs -mt-1 text-gray-600", title)}>{title}</div>
</CircularProgressbarWithChildren>
</div>
}
8 changes: 5 additions & 3 deletions src/components/dashboard/ProgressSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import React from "react";
import { ArrowSmRightIcon } from "@heroicons/react/solid";
import Link from "next/link";
import AttemptHistory from "./AttemptHistory";

export default function ProgressSummary() {
return (
<div>
<div className="pb-4 text-slate-700 flex flex-col gap-y-2">
<h1 className="inline font-bold text-noora-secondary font-display text-3xl tracking-tight">
Practice your{" "}
<span className="special-underline">social skills</span>.
<span className="special-underline">social conversation</span>.
</h1>
<p>
Noora helps you practice challenging aspects of social conversation, such as{" "}
<b>responding empathetically and positively to others</b>.
</p>
</div>
<div className="grid grid-cols-12">
<div className="col-span-12 flex justify-between items-center text-white px-5 py-6 bg-noora-primary rounded-lg bg-gradient-to-br from-noora-primary-light via-noora-primary to-noora-secondary-bright">
<div id="progress" className="grid grid-cols-12">
<div className="col-span-12 flex flex-col sm:flex-row gap-y-4 text-center sm:text-left justify-between items-center text-white px-5 py-6 bg-noora-primary rounded-lg bg-gradient-to-br from-noora-primary-light via-noora-primary to-noora-secondary-bright">
<div>
<h1 className="text-2xl font-bold">Up Next</h1>
<p className="text-lg">
Expand All @@ -33,6 +34,7 @@ export default function ProgressSummary() {
</div>
</div>
</div>
<AttemptHistory />
</div>
);
}
78 changes: 0 additions & 78 deletions src/components/global/utility/Microphone.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import Header from "../global/header/Header";
import Footer from "../global/footer/Footer";
import Header from "../../global/header/Header";
import Footer from "../../global/footer/Footer";
import Head from "next/head";

export default function Page({ fullTitle, title, desc, children }: PageProps) {
Expand Down
44 changes: 0 additions & 44 deletions src/components/global/utility/RateLimitingTest.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/components/home/CTA.tsx

This file was deleted.

Loading