End-to-end deployment of a Streamlit application to detect adverse effects from free text using OpenAI GPT-3 model.
-
Navigate into the project directory
$ cd ae_detection
-
Create a new virtual environment
$ python -m venv venv $ . venv/bin/activate
-
Install the requirements
$ pip install -r api/requirements.txt streamlit/requirements.txt
-
Add your [OpenAI API key] to the
.env
file -
Run the FastAPI service
$ uvicorn main:app --reload
FastAPI service is running at http://127.0.0.1:8000
-
Run the Streamlit App
$ streamlit run app.py
Streamlit App is running at http://127.0.0.1:8501
-
Launch the services using docker-compose
$ docker-compose build $ docker-compose up
-
Create an EC2 instance (Amazon Linux AMI)
-
In the security group, allow inbound traffic on port 8000 and 8501.
-
Connect to the instance
-
Install docker and docker-compose (1.31.1)
$ sudo yum update -y $ sudo amazon-linux-extras install docker $ sudo service docker start $ sudo systemctl enable docker $ sudo usermod -a -G docker ec2-user $ sudo curl -L https://github.com/docker/compose/releases/download/1.31.1/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null $ sudo chmod +x /usr/local/bin/docker-compose $ ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4.2 Install docker and docker-compose using Ubuntu AMI
$ sudo apt-get update $ sudo apt-get install docker.io $ sudo systemctl start docker $ sudo docker run hello-world $ sudo apt-get install docker-compose
-
(Optional) Start a new tmux session
$ sudo yum install tmux $ tmux new -s StreamlitSession
To detach from the TMUX session, use: Ctrl+B and then D
To reattach to the same session, use:
$ tmux attach -t StreamlitSession