A prototype chatbot for recording health metrics for patients; project for the DS50 ("data science") class
To run the code, you will need the following tools installed:
git
git-lfs
(optional, used to download bigger files)python >= 3.10
(earlier versions might work but haven't been tested)pip
nodejs >= 14
(tested withnodejs == 20.2.0
)npm
python-pytorch
(optional, but your system's package manager might offer a version of pytorch with AVX or CUDA optimizations, which you should prefer if your system supports them)
git clone https://github.com/adri326/ds50-project
cd ds50-project
# Only needs to be run once per user, used to download bigger files
git lfs install
# Use your favorite python package management thing:
conda env create
# Install all the dependencies:
pip install -r requirements.txt
# Run the server (takes a few minutes on the first run as it needs to download the models from huggingface)
python src/server.py
# Navigate to the frontend directory
cd chatbot-frontend
# Use yarn to pull all the dependencies (npm can work too, although it is a bit slower)
npx yarn
# Run the frontend application
npx yarn dev
src/
: the backend part of the application, implemented in Pythonsrc/sentiment.py
: entrypoint for the analysis of message sentiments/intents, to try and extract data from messagessrc/sentiment_huggingface.py
: an alternative implementation of sentiment analysis, using an off-the-shelf model from huggingfacesrc/chatgpt.py
: calls the OpenAI API to query answers from GPT-3src/similarity.py
: computes a semantic vector for each question in the dataset and augments these questions using the acronym dictionary, and compares the user's question using cosinus similaritysrc/acronym.py
: loads a dictionary of acronymssrc/chatbot.py
: entrypoint for the chatbot, which should answer to messagessrc/server.py
: entrypoint for a server to host an API for the chatbot
chatbot-frontend
: the frontend part of the application, implemented in TypeScript using Solid.JS and Vitechatbot-frontend/src/App.tsx
: the entrypoint of the applicationchatbot-frontend/src/api.ts
: communicates with the API, by wrapping the data returned in typescript types
dataset
: the datasets built or useddataset/acro.json
: the acronym dictionarydataset/dataset_5Q.json
: the dataset with augmented questions and french translations (with the acronyms correctly translated)