Coder Social home page Coder Social logo

openai's Introduction

Chat GPT Prompt Engineering

Test code for ChatGPT prompt engineering course. This is based on the DeepLearning.AI, ChatGPT Prompt Engineering for Developers course. In this repository I have converted all of the examples from Python to JavaScript.

Set Up

API Key

If you want to try these out you will first need to setup your own ChatGPT secret key in your local environment. Here is how you get a key. Once you have this put it in a local (server side) environment variable. For example in Mac OS, assuming you are using zsh, append the following to the file .zshenv in you own home directory:

export OPENAI_API_KEY='your_secret_key_value'

When you restart the shell or your machine the environment value OPENAI_API_KEY will be available to the helper.js.

Node and JS

Before trying any of the exercises don't for get to run npm install in the ./openai directory to install the Node modules needed. In the root directory you will see the helper.js, all of the exercises use this to make their calls to the ChatGPT API. In each subdirectory you will find a *.js file and, sometimes, some supporting text files. Each JS file contains multiple prompts. Generally there are a couple of lines near the end of the file, such as:

let completion = await getCompletion(prompt8);
console.log(completion);

In most cases you can just change the prompt passed to the getCompletion() function to try different exercises out. In some cases you will see code block commented out using the \* ... *\ comment markers. In these cases the commented code blocks will have their own calls to getCompletion(), often in a loop of some kind. If you uncomment these blocks then be sure to comment out the last to calls above while you run that exercise.

openai's People

Contributors

nigel-daniels avatar nigel-saic avatar

Stargazers

 avatar rookie avatar Jaime Dargallo avatar thinkhy avatar Nefer Lopez avatar Pierre Therrode avatar Jérémie Zarca 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.