From 0c253f3fca60ff48d9faea270bc58dcc8a709dab Mon Sep 17 00:00:00 2001 From: John Date: Tue, 31 Jan 2023 20:20:40 -0800 Subject: [PATCH] Externalize OPENAPI_API_KEY Allows .gitignore to ignore API Key Prevents accidental upload of credentials --- .gitignore | 3 +++ README.md | 4 ++-- src/App.js | 2 +- src/OPENAI_API_KEY.template.js | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/OPENAI_API_KEY.template.js diff --git a/.gitignore b/.gitignore index 4d29575..2d0cb31 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# credentials +OPENAI_API_KEY.js diff --git a/README.md b/README.md index 64374c2..eeeb096 100644 --- a/README.md +++ b/README.md @@ -12,5 +12,5 @@ The current few-shot prompt guides GPT-3 in accurately understanding the JSON fo ## Setup 1. Run `npm install` to download required dependencies (currently just [react-graph-vis](https://github.com/crubier/react-graph-vis)). -2. Enter your OPENAI_API_KEY in `src/App.js`. -3. Run `npm run start`. GraphGPT should open up in a new browser tab. \ No newline at end of file +2. CREATE `src/OPENAI_API_KEY.js` using template in `src/OPENAI_API_KEY.template.js`. +3. Run `npm run start`. GraphGPT should open up in a new browser tab. diff --git a/src/App.js b/src/App.js index d423929..d684aa4 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,7 @@ import './App.css'; import Graph from "react-graph-vis"; import React, { useState } from "react"; -const OPENAI_API_KEY = "YOUR OPENAI API KEY"; +import OPENAI_API_KEY from "./OPENAI_API_KEY.js"; const DEFAULT_PARAMS = { "model": "text-davinci-003", diff --git a/src/OPENAI_API_KEY.template.js b/src/OPENAI_API_KEY.template.js new file mode 100644 index 0000000..effdd17 --- /dev/null +++ b/src/OPENAI_API_KEY.template.js @@ -0,0 +1,3 @@ +const OPENAI_API_KEY = + ""; +export default OPENAI_API_KEY;