Git Product home page Git Product logo

chatgpt-io's Issues

Error: Request failed with status code 400 at ChatGPT.getTokens node_modules/chatgpt-io/dist/classes/chatgpt.js:174:19

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.

  • Node version: v16.16.0
  • Chatgpt-io version: 1.1.4

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 

status 400

An error ocurred. Try refreshing your browser

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.