pawanosman / chatgpt-io Goto Github PK
View Code? Open in Web Editor NEWChatGPT Client API, Blazing Fast, without using browser
Home Page: https://www.npmjs.com/package/chatgpt-io
License: MIT License
ChatGPT Client API, Blazing Fast, without using browser
Home Page: https://www.npmjs.com/package/chatgpt-io
License: MIT License
Hey there!
Good idea to create this wrapper. I thought about making one myself at some point, but then I read OpenAI's policies and held back ๐ . So, it was great to find your project here!
I wanted to inform you about a strange behavior I see here. I'm getting a 400, even after triple-checking the session id, so I decided to bring this to you. I'll paste the code and the error here. If you need any other information, please let me know.
Project structure
.
โโโ .env
โโโ index.js
โโโ node_modules
โโโ package-lock.json
โโโ package.json
.env
CHATGPT_SESSION_TOKEN="__Secure-next-auth.session-token value"
index.js
require("dotenv").config();
const readline = require("readline");
let ChatGPT;
async function loadChatGPT() {
const module = await import('chatgpt-io');
ChatGPT = module.default || module;
}
loadChatGPT().then( async () => {
let response;
const bot = new ChatGPT(process.env.CHATGPT_SESSION_TOKEN).then(
() => { console.log('Bot loaded!') }).catch(err => { console.log(err) });
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
while (readline.line && readline.line != "exit") {
response = await bot.ask(readline.line);
console.log(`Bot > ${response}`);
}
rl.close().then(() => { process.exit(0) });
});
package.json
{
"name": "chatgpt-real-wrapper",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"chatgpt-io": "^1.1.4",
"dotenv": "^16.0.3"
}
}
Error
โ chatgpt-real-wrapper node index.js
Bot loaded!
You > [ERROR] 2023-05-30 17:36:24 Request failed with status code 400
file:///Users/juanpedrosugg/Dev/chatgpt-real-wrapper/node_modules/chatgpt-io/dist/classes/chatgpt.js:174
throw new Error(result.error);
^
Error: Request failed with status code 400
at ChatGPT.getTokens (file:///Users/juanpedrosugg/Dev/chatgpt-real-wrapper/node_modules/chatgpt-io/dist/classes/chatgpt.js:174:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Timeout._onTimeout (file:///Users/juanpedrosugg/Dev/chatgpt-real-wrapper/node_modules/chatgpt-io/dist/classes/chatgpt.js:42:17)
โ chatgpt-real-wrapper
I get the following error with the example
node examples/index1.js
[INFO] 2023-02-13 15:23:27 Connected to server
[WARN] 2023-02-13 15:23:28 Session token changed, re-authenticating the new session token...
[INFO] 2023-02-13 15:23:31 Ready!
[ERROR] 2023-02-13 15:23:32 An error ocurred. Try refreshing your browser.
file:///var/www/.../chatgpt-io-main/node_modules/chatgpt-io/dist/classes/chatgpt.js:251
throw new Error(data.error);
^
Error: An error ocurred. Try refreshing your browser.
at ChatGPT.send (file:///var/www/.../chatgpt-io-main/node_modules/chatgpt-io/dist/classes/chatgpt.js:251:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ChatGPT.ask (file:///var/www/.../chatgpt-io-main/node_modules/chatgpt-io/dist/classes/chatgpt.js:260:20)
at async file:///var/www/.../chatgpt-io-main/examples/index1.js:9:18
Node.js v18.13.0
Thanks for providing such a good API for us, and I am happy using it recently. Could you please check this server and restart it ?
I really appreciate that !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.