#Request failed with status code 400
68 messages · Page 1 of 1 (latest)
what do you think?
i was doing some tests
400 – Bad Request. The request could not be understood by the server due to malformed syntax.
Yes, now i looked over and see that i got 429 error
that's meaning i did too many requests
as its saying here
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.
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
yep
Are you hosting a server?
yep
There is a lot more information
first tried on my local machine then moved on a server and there i got limited i think
You've just said "I have an error - fix it for me" without helping us to understand what your set up is.
i dind't said fix it for me, i just want you to help me fixing it by saying what type of information you need, i don't know what you need to know to help me
i don't think the code will help, im using the openai npm module
Rate-limiting isn't present in the API is it?
we need a minimal bug-demonstrating test case
Just max chars
and i'm just making a simple request to get a simple response
Your headers or body are probably wrong
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
thank you! That is helpful
You need to pass "temperature" too I believe
when i tried first it worked without temperature
So why did you change it?
Temperature is optional
An API for accessing new AI models developed by OpenAI
temperature number Optional Defaults to 1
the problem started when i moved it on the vps i think, but don't know what happend exactly
What are the logs on the server showing?
drop your full code in gist.github.com
same as the ones from the machine, is a big console log there but i can send it to you
is just some lines, i can send them here
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
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 });
},
};
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the error
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)
the ones from the api, for making the request
im using node.js
is there a potential blacklist or something ?
Can't help if you can't be specific sorry bud.
Your code is faulty.
???
But have you helped someone to fix this problem before?
400 errors from websites? Yes.
Im saying with this api as i have problem with it
Ok. Then I guess you'd better come back when the API is fixed?
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
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
Those are the modules from node_modules, some preinstalled things, there are a bunch of files in there
I'm trying to help, but you seem set on rebuffing suggestions with your own
sorry for asking but have you worked with node.js? because that's important to know
Yes. This is a frustrating conversation though so I'm going to remove myself from it. Good luck bud.
Good luck as well i think