Welcome to the code repository for GPT4DFCI-API, an example of how to call the API of GPT4DFCI, which a allows you to leverage GPT4DFCI programmatically in your application.
ℹ️ GPT4DFCI is a private and secure generative AI tool, based on GPT-4 and deployed for non-clinical use at Dana-Farber Cancer Institute. See all details about it in its code repository.
This repository is organized in the following sections:
- Prerequisites
- Run the GPT4DFCI API demo
- License
- Contact
Poetry is a tool for dependency management and packaging in Python.
If you are already familiar with Poetry, or are comfortable setting up your own environment with other tools, you can probably skip this.
https://python-poetry.org/docs/#installation
- Install brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install poetry using:
brew install poetry
After installing Poetry, navigate to the directory you are interested in and run:
poetry install --no-root
This should create a virtual environment with the dependencies specified in pyproject.toml
installed.
To activate the virtual environment, run:
poetry shell
or, alternatively, if you don't want to use Poetry's sub-shell pattern, you can run:
source .venv/bin/activate
In a file called .env
, fill in the following values:
AZURE_OPENAI_ENDPOINT=https://...
AZURE_OPENAI_ENTRA_SCOPE=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
AZURE_OPENAI_ENDPOINT
should be the GPT4DFCI API endpoint, without the /openai
suffix.
AZURE_OPENAI_ENTRA_SCOPE
should be the scope required for the bearer token, the UUID client_id
.
Prerequisites: Azure CLI
For macOS this would be
brew install azure-cli
If you are using DFCI AI Studio, you should use %sh curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Then, make sure you are logged in via the Azure CLI to an account that has been granted access to the GPT4DFCI API.
az login --allow-no-subscriptions
Close the window after logging in and get back to the shell.
Turn on the VPN or make sure you are running from an on-prem resource.
export $(cat .env | xargs) && python demo.py
When finished working, shut the current virtual environment with
deactivate
When you are read to resume working on this, come back to this folder and resume working with
source .venv/bin/activate
export $(cat .env | xargs) && python demo.py
The GNU GPL v2 version of GPT4DFCI is made available via Open Source licensing. The user is free to use, modify, and distribute under the terms of the GNU General Public License version 2.
Commercial license options are available also, and include additional features.
Questions? Comments? Suggestions? Get in touch!