Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yav-ai/nodejs-openai-function-calling-example

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.
https://github.com/yav-ai/nodejs-openai-function-calling-example

chatgpt chatgpt-api openai openai-api openai-function-call openai-function-example openai-functions openai-nodejs

Last synced: about 2 months ago
JSON representation

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.

Awesome Lists containing this project

README

        

# 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:

```shell
git clone
```

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):

```shell
node index.js
```

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

```shell
node index[Deprecated].js
```

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