Ok, here’s the code. I’m a newbie guys, so please go easy on me lol
<script>
generateButton = document.getElementById("generate-button");
generateButton.addEventListener("click", function() {
// Get the value of the "idea" element
var idea = document.getElementById("idea").value;
// Make a request to the OpenAI API using the `fetch` method
fetch('https://api.openai.com/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-'
},
body: JSON.stringify({
"engine": "text-davinci-003",
"prompt": idea,
"max_tokens": 256,
"temperature": 0.5,
})
})
.then((response) => {
console.log(response);
response.json()
})
.then((data) => {
// Set the value of the "copy" element to the generated text
document.getElementById("copy").value = data.choices[0].text;
});
});
Hey guys, I too am seeing a 400 bad request error for just some of my requests. For the first few requests, it works. But once I get a long response, and I append that as part of the prompt it no longer works. Is there some sort of limit to the prompt length?