Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@waylaidwanderer/chatgpt-api
Advanced tools
A ChatGPT implementation using the official ChatGPT model via OpenAI's API.
This is an implementation of ChatGPT using the official ChatGPT raw model, text-chat-davinci-002-20230126
. This model name was briefly leaked while I was inspecting the network requests made by the official ChatGPT website, and I discovered that it works with the OpenAI API. Usage of this model currently does not cost any credits.
As far as I'm aware, I was the first one who discovered this, and usage of the model has since been implemented in libraries like acheong08/ChatGPT.
The previous version of this library that used transitive-bullshit/chatgpt-api is still available on the archive/old-version
branch.
By itself, the model does not have any conversational support, so this library uses a cache to store conversations and pass them to the model as context. This allows you to have persistent conversations with ChatGPT in a nearly identical way to the official website.
text-chat-davinci-002-20230126
.ChatGPTClient
class that you can use in your own Node.js applications.npm i @waylaidwanderer/chatgpt-api
import ChatGPTClient from '@waylaidwanderer/chatgpt-api';
const chatGptClient = new ChatGPTClient('OPENAI_API_KEY');
const response = await chatGptClient.sendMessage('Hello!');
console.log(response); // { response: 'Hi! How can I help you today?', conversationId: '...', messageId: '...' }
const response2 = await chatGptClient.sendMessage('Write a poem about cats.', { conversationId: response.conversationId, parentMessageId: response.messageId });
console.log(response2.response); // Cats are the best pets in the world.
const response3 = await chatGptClient.sendMessage('Now write it in French.', { conversationId: response2.conversationId, parentMessageId: response2.messageId });
console.log(response3.response); // Les chats sont les meilleurs animaux de compagnie du monde.
You can install the package using
npm i -g @waylaidwanderer/chatgpt-api
then run it using
chatgpt-api
.
This takes an optional --settings=<path_to_settings.js>
parameter, or looks for settings.js
in the current directory if not set, with the following contents:
module.exports = {
// Your OpenAI API key
openaiApiKey: '',
// Parameters as described in https://platform.openai.com/docs/api-reference/completions
// The model is set to text-chat-davinci-002-20230126 by default, but you can override
// it and any other parameters here.
chatGptClient: {
// temperature: 0.7,
},
// Options for the Keyv cache, see https://www.npmjs.com/package/keyv
// This is used for storing conversations, and supports additional drivers.
cacheOptions: {},
// The port the server will run on (optional, defaults to 3000)
port: 3000,
};
Alternatively, you can install and run the package locally:
npm install
settings.example.js
to settings.js
in the root directory and change the settings where required.npm start
or node bin/server.js
To start a conversation with ChatGPT, send a POST request to the server's /conversation
endpoint with a JSON body in the following format:
{
"message": "Hello, how are you today?",
"conversationId": "your-conversation-id (optional)",
"parentMessageId": "your-parent-message-id (optional)"
}
The server will return a JSON object containing ChatGPT's response:
{
"response": "I'm doing well, thank you! How are you?",
"conversationId": "your-conversation-id",
"messageId": "response-message-id"
}
If the request is unsuccessful, the server will return a JSON object with an error message and a status code of 503.
If there was an error sending the message to ChatGPT:
{
"error": "There was an error communicating with ChatGPT."
}
Since text-chat-davinci-002-20230126
is ChatGPT's raw model, I had to do my best to replicate the way the official ChatGPT website uses it.
This means it may not behave exactly the same in some ways:
temperature: 0.7
If you'd like to contribute to this project, please create a pull request with a detailed description of your changes.
This project is licensed under the MIT License.
FAQs
A ChatGPT implementation using the official ChatGPT model via OpenAI's API.
The npm package @waylaidwanderer/chatgpt-api receives a total of 254 weekly downloads. As such, @waylaidwanderer/chatgpt-api popularity was classified as not popular.
We found that @waylaidwanderer/chatgpt-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.