#Request failed with status code 400

68 messages · Page 1 of 1 (latest)

sharp sable
#

There could be lots of reasons

earnest pendant
#

i was doing some tests

sharp sable
#

400 – Bad Request. The request could not be understood by the server due to malformed syntax.

earnest pendant
#

Yes, now i looked over and see that i got 429 error

#

that's meaning i did too many requests

#

as its saying here

sharp sable
#

Don't ask others to debug your broken code without giving a hint what sort of problem they should be searching for. Posting a few hundred lines of code, saying "it doesn't work", will get you ignored. Posting a dozen lines of code, saying "after line 7 I was expecting to see <x>, but <y> occurred instead" is much more likely to get you a response.

The most effective way to be precise about a code problem is to provide a minimal bug-demonstrating test case. What's a minimal test case? It's an illustration of the problem; just enough code to exhibit the undesirable behavior and no more. How do you make a minimal test case? If you know what line or section of code is producing the problematic behavior, make a copy of it and add just enough supporting code to produce a complete example (i.e. enough that the source is acceptable to the compiler/interpreter/whatever application processes it). If you can't narrow it down to a particular section, make a copy of the source and start removing chunks that don't affect the problematic behavior. The smaller your minimal test case is, the better (see the section called “Volume is not precision”).

Generating a really small minimal test case will not always be possible, but trying to is good discipline. It may help you learn what you need to solve the problem on your own — and even when it doesn't, hackers like to see that you have tried. It will make them more cooperative.

If you simply want a code review, say as much up front, and be sure to mention what areas you think might particularly need review and why.```
#

Happy to try to help when I have some free time but anyone would need more information than you've provided in order to help.

earnest pendant
#

There are not any other informtions i can give to you, basically i got rate limited but i don't know why

#

as I said, I just did like 20 requests for testings

#

with medium prompts

#

with few words in it

#

and got short replies

sharp sable
#

Are you using the API?

#

Did you write some code?

earnest pendant
sharp sable
#

Are you hosting a server?

earnest pendant
sharp sable
#

There is a lot more information

earnest pendant
sharp sable
#

You've just said "I have an error - fix it for me" without helping us to understand what your set up is.

earnest pendant
#

i don't think the code will help, im using the openai npm module

plucky coral
#

Rate-limiting isn't present in the API is it?

sharp sable
#

we need a minimal bug-demonstrating test case

plucky coral
#

Just max chars

earnest pendant
#

and i'm just making a simple request to get a simple response

plucky coral
#

Your headers or body are probably wrong

earnest pendant
#
        await interaction.deferReply({})
        const completion = await openai.createCompletion({
            model: "text-davinci-003",
            prompt: query,
            max_tokens: "2048"
        });
        console.log(completion.data.choices)
        await interaction.editReply({ content: completion.data.choices[0].text })```
#

this is how i make the request

sharp sable
#

thank you! That is helpful

plucky coral
#

You need to pass "temperature" too I believe

earnest pendant
plucky coral
#

So why did you change it?

sharp sable
#

Temperature is optional

#

temperature number Optional Defaults to 1

earnest pendant
#

the problem started when i moved it on the vps i think, but don't know what happend exactly

sharp sable
#

What are the logs on the server showing?

plucky coral
earnest pendant
earnest pendant
#
const { Configuration, OpenAIApi } = require("openai");
const config = require('../config.json')
const configuration = new Configuration({
    apiKey: ""
});
const openai = new OpenAIApi(configuration);
module.exports = {
    data: new SlashCommandBuilder()
        .setName('ask')
        .setDescription('Ask the bot something.')
        .addStringOption((option) =>
            option
                .setName('arguments')
                .setDescription("The arguments")
                .setRequired(true)),
    async execute(interaction) {
        const query = interaction.options.getString('arguments')
        await interaction.deferReply({})
        const completion = await openai.createCompletion({
            model: "text-davinci-003",
            prompt: query,
            max_tokens: "2048"
        });
        console.log(completion.data.choices)
        await interaction.editReply({ content: completion.data.choices[0].text })
    },
};```
#

so basically im doing an integration between openai api and discord, sending the content from discord to openai api and send the response back to discord

plucky coral
#

I asked AI to fix it for you:

const { SlashCommandBuilder } = require('discord.js');
const { Configuration, OpenAIApi } = require("openai");
const config = require('../config.json');

const configuration = new Configuration({
apiKey: config.openai.apiKey
});
const openai = new OpenAIApi(configuration);

module.exports = {
data: new SlashCommandBuilder()
.setName('ask')
.setDescription('Ask the bot something.')
.addStringOption((option) =>
option
.setName('arguments')
.setDescription("The arguments")
.setRequired(true)),
async execute(interaction) {
const query = interaction.options.getString('arguments');
await interaction.deferReply({});
const completion = await openai.createCompletion({
model: "text-davinci-003",
prompt: query,
max_tokens: "2048"
});
console.log(completion.data.choices);
await interaction.editReply({ content: completion.data.choices[0].text });
},
};

earnest pendant
earnest pendant
plucky coral
#

What's at these lines?
axios\lib\core\createError.js:16:15
core\settle.js:17:12
adapters\http.js:322:11
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

earnest pendant
#

im using node.js

#

is there a potential blacklist or something ?

plucky coral
#

Can't help if you can't be specific sorry bud.

Your code is faulty.

earnest pendant
#

But have you helped someone to fix this problem before?

plucky coral
#

400 errors from websites? Yes.

earnest pendant
#

Im saying with this api as i have problem with it

plucky coral
#

Ok. Then I guess you'd better come back when the API is fixed?

earnest pendant
#

i checked the status and is not a problem with the api, you told me that im not too specific but i cant be more specific than that as i gave you the code and also the error

plucky coral
#

You have not posted settle.js, http.js and createerror.js

All three of them have errors in your response that tell you which line those files are failing on.

#

You could have posted to gist to help us get the line numbers, but instead posted inline in discord

earnest pendant
plucky coral
#

I'm trying to help, but you seem set on rebuffing suggestions with your own

earnest pendant
#

sorry for asking but have you worked with node.js? because that's important to know

plucky coral
#

Yes. This is a frustrating conversation though so I'm going to remove myself from it. Good luck bud.

earnest pendant
#

Good luck as well i think