This is a Node.js Express API server meant to function as an OpenAI GPT Action. It simulates an employee directory querying service. It is meant to be deployed to Heroku.
First create a Heroku app to deploy this application by running:
heroku create <app-name>
Along with your basic Heroku app, you will need to use a PostgreSQL add-on. You can do it manually by running:
heroku addons:create heroku-postgresql:mini
Once your database is set up, you should run the SQL statements found in the following two files (in this order):
data/create_schema.sql
(which creates theemployees
table and enum types)data/create_records.sql
(which inserts 500 sample records into theemployees
table)
You can do it by running:
heroku pg:psql < data/create_schema.sql
heroku pg:psql < data/create_records.sql
Once you have the database up and running, Heroku will automatically add a config var called DATABASE_URL
. This should contain all of the information you need for connecting to the database (in src/db.js
).
This service also makes its own calls to the OpenAI Chat Completions APIs. To use the API, you will need to obtain an OpenAI API Key. Once you have that, you will need to add the following Heroku app config var:
OPENAI_API_KEY
By default, this service will use the gpt-3.5-turbo-1106
OpenAI model. In our testing, we found that the GPT-4 model performs more accurately at times, but it is too slow, often causing requests to take longer than the 30-second timeout for Heroku apps. Using a GPT-3.5 model was necessary to accomplish a fast enough response. If you want to change the model used (for speed or performance reasons), you can specify the model by setting a Heroku app config var called CHATGPT_MODEL
.
You can use any freely available password generator.
Add a new key called BEARER_AUTH_API_KEY
with this key value.
Add a new key called OPENAI_API_KEY
with this generated token value.