Skip to content

This repository contains a basic Node.js example demonstrating how to call functions using the OpenAI API. The example showcases a conversation with the OpenAI GPT-3.5 Turbo model, including making function calls and processing their responses.

License

Notifications You must be signed in to change notification settings

YAV-AI/NodeJS-OpenAI-Function-Calling-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Function Calling example in Node.js

This repository contains a basic Node.js example demonstrating how to call functions using the OpenAI API. The example showcases a conversation with the OpenAI GPT-3.5 Turbo model, including making function calls and processing their responses.

Whats New?

  • Uses tools and tool_choice
  • Supports parallel function calling

Getting Started

Dependencies: This project has no external dependencies, making it lightweight and easy to set up. You can run this example with just Node.js. However, if you have a preferred library or tool for making HTTP requests, feel free to integrate it as needed to enhance the functionality or suit your specific requirements.

To get started with this example:

  1. Clone this repository to your local machine:

    git clone <this-repo>
  2. Obtain an API key from OpenAI

  3. Replace Bearer sk-xxxxxxxxx in the code with your API key.

Parallel Function calling (Uses tools and tool_choice):

node index.js

Single Function call (Deprecated) (Uses function_call and functions):

node index[Deprecated].js
  1. Customise the functions and conversation as needed. In this example, a simple weather-related function is included, but you can add more functions to suit your use case.

Usage

This repository serves as a starting point for understanding how to integrate function calls into your conversational AI system using the OpenAI GPT-3.5 Turbo model. You can extend the example by adding more functions, handling different types of requests, and tailoring it to your specific application.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This repository contains a basic Node.js example demonstrating how to call functions using the OpenAI API. The example showcases a conversation with the OpenAI GPT-3.5 Turbo model, including making function calls and processing their responses.

Topics

Resources

License

Stars

Watchers

Forks