Coder Social home page Coder Social logo

dana-farber-aios / gpt4dfci-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 62 KB

An example on how to call the API of GPT4DFCI, a private and secure generative AI tool, based on GPT-4 and deployed for non-clinical use at Dana-Farber Cancer Institute.

License: GNU General Public License v2.0

Python 100.00%

gpt4dfci-api's Introduction

GPT4DFCI-API ๐Ÿ”Œ

image

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

โš™๏ธ Prerequisites

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.

Installing Poetry

https://python-poetry.org/docs/#installation

For macOS this would be the suggested way:

  • Install brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install poetry using:
brew install poetry

Installing GPT4DFCI API dependencies

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

๐ŸŸข Run the GPT4DFCI API demo

Set up environment variables

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.

Authenticate via Azure CLI

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.

VPN

Turn on the VPN or make sure you are running from an on-prem resource.

Run the demo

export $(cat .env | xargs) && python demo.py

Shutting down

When finished working, shut the current virtual environment with

deactivate

Resuming work

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

๐ŸŽซ License

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.

๐Ÿ“ง Contact

Questions? Comments? Suggestions? Get in touch!

[email protected]

gpt4dfci-api's People

Contributors

dana-farber avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.