updated on 2024-2-12
This is a modified example based on the "Pet Name Generator App" from the OpenAI API quickstart tutorial. The example is built using the Next.js framework with React, and is designed to provide a demonstration for network automation students using the DevNet environment. To get set up, please either follow the instructions outlined below.
-
If you don’t have Node.js installed, install it from here
for you use ubuntu Linux devasc virtualbox, you can install nodejs version 18+ using this link, using the option2.
-
Clone this repository
git clone https://github.com/wyonghao/openai_api_demo.git
-
Navigate into the project directory
$ cd openai_api_demo
-
Install the requirements
$ npm install
-
Make a copy of the example environment variables file
$ cp .env.example .env
-
Add your API key to the newly created
.env
file. The Key shall start withsk-****
nano .env
-
Run the app
$ npm run dev
-
Setup the port forward in virtualbox settings to forward 3000 to the port that the host using for example you can use 5555 as the below picture:
You should now be able to access the app at http://localhost:5555, which maps to the guest OS' http://localhost:3000!
For the full context behind this example app, check out the official open AI tutorial.
Note, you might need to run
$ npm install
$ npm update
again after the source code or the APIs are updated