This project demonstrates the integration of ChatGPT with various tools (functions) using JavaScript in a Node.js environment. It includes a function to fetch current weather data and integrates it with the ChatGPT model.
Before running the project, ensure you have the following installed:
- Node.js (v18.x or later). Run
node -vin the terminal. - npm (usually comes with Node.js) Run
npm -vin the terminal
-
Clone the Repository
- Clone this repository to your local machine using
git clone git@github.com:haakonjacobsen/chatgpt-tools-workshop.git
- Clone this repository to your local machine using
-
Install Dependencies
- Navigate to the project directory in your terminal.
- Run
npm installto install the required packages listed inpackage.json.
-
Environment Variables🔐
-
Create a
.envfile in the root of the project. -
Add your OpenAI API key and OpenWeather API key in the
.envfile:(If you don't have one, you can create one for OpenAI here, you need an OpenAI account and some dollars in your account to get started. For OpenWeather, it's free, follow this link and follow the instructions: OpenWeather link).
OPENAI_API_KEY=your_openai_api_key_here OPEN_WEATHER_API_KEY=your_openweather_api_key_here
-
-
Start the Application🚀
- In the project directory, run the command
node index.jsto start the application.
- In the project directory, run the command
-
Interact with ChatGPT
- Once the application is running, you can interact with ChatGPT through the command line.
- Type your query and press Enter.
- To exit, type 'q' and press Enter.
- The current setup includes a function for fetching weather data. You can add more functions as needed.
- Ensure that you have a stable internet connection, as the project makes API calls to OpenAI and OpenWeather.