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

https://github.com/quytechabhinav/chatgpt-npm

chatgpt-npm is NPM package provide a powerful tool that allows Node.js developers to generate natural language responses using the OpenAI ChatGPT API.
https://github.com/quytechabhinav/chatgpt-npm

javascript nodejs openai openai-api

Last synced: 3 months ago
JSON representation

chatgpt-npm is NPM package provide a powerful tool that allows Node.js developers to generate natural language responses using the OpenAI ChatGPT API.

Awesome Lists containing this project

README

        

# **chatgpt-npm NPM Package**

chatgpt-npm is NPM package provide a powerful tool that allows Node.js developers to generate natural language responses using the OpenAI ChatGPT API.

# Table of Contents
* [Features](#chatgpt-npm)
* [Getting Started](#Installation)
* [Usage](#usage)
* [Example](#example)
* [API Server-axios](#axios)
* [API Server-OpenAI](#OpenAI)
* [Prerequisites](#prerequisites)
* [License](#license)
* [About the Author](#About-the-Author)
* [How to reach me?](#How-to-reach-me?)

## **Installation**
To install this package, simply run the following command in your Node.js project directory:

```javascript
npm i chatgpt-npm
```

# **Usage**
To use the generateChatGPTResponse function in your JavaScript code, you need to import it like this:

### Example

```javascript
const chatgpt = require('chatgpt-npm');
```
Once you've imported the function, you can use it to generate responses like this:

### axios
```javascript
let searchData = req.body.search;
const searchResult = await chatgpt.generateChatGPTResponse(searchData);
console.log(searchResult)

```
In this example, we are passing the searchData object from the request body to the generateChatGPTResponse function, which will use the OpenAI GPT-3 model to generate a response. The response is then logged to the console using console.log(searchResult).

Note that generateChatGPTResponse is an asynchronous function, so you need to use the await keyword when calling it. Also, make sure that you have properly configured the OpenAI API credentials in order to use the function.

The generateChatGPTResponse function takes a string prompt as input and returns a string response generated by the ChatGPT API. Note that you will need to set the OPENAI_API_KEY environment variable with your actual OpenAI API key before using this package.

### OpenAI
```javascript
let searchData = req.body.search;
const searchResult = await chatgpt.generateChatGPTOpenAIResponse(searchData);
console.log(searchResult)
```
You can use the generateChatGPTOpenAIResponse function from the chatgpt module to generate a response and store the conversation history using the OpenAI ChatGPT API.

## Prerequisites
- Node.js >= 12.0.0
- npm
- [OpenAI API key](https://platform.openai.com/account/api-keys)

# License
This package is licensed under the MIT license. See the LICENSE file for more details.

## **How to reach me?**
If you have any questions or comments about this package, feel free to reach out to me on:

## **About the Author**

This package is made with ❤️ by Abhinav Kashyap. Abhinav is a Node.js developer with extensive experience in developing chatbot applications using natural language processing (NLP) techniques.