/openai_api_demo

based on the open AI quick start demo for BCU students

Primary LanguageJavaScript

Based on OpenAI API Quickstart - Node.js example app

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.

Setup

  1. 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.

  2. Clone this repository

    git clone https://github.com/wyonghao/openai_api_demo.git
  3. Navigate into the project directory

    $ cd openai_api_demo
  4. Install the requirements

    $ npm install
  5. Make a copy of the example environment variables file

    $ cp .env.example .env
  6. Add your API key to the newly created .env file. The Key shall start with sk-****

    nano .env
  7. Run the app

    $ npm run dev
  8. 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:

Screenshot

You should now be able to access the app at http://localhost:5555, which maps to the guest OS' http://localhost:3000!

website

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