#Getting no response for my essay generator

6 messages · Page 1 of 1 (latest)

spark zenith
#

I am not getting any response in my essay gen app
this is my source code ``<!DOCTYPE html>
<html>
<head>
<title>Essay Generator</title>
</head>
<body style="background-color: crimson;">
<h1 style="text-align: center;">Essay Generator</h1>
<form style="background-color: aqua; text-align: center; border-color: rgb(16, 30, 221); border-radius: 10cm;">
<label for="topic">Topic:</label><br>
<input type="text" id="topic" name="topic"><br>
<label for="wordCount">Word Count:</label><br>
<input type="number" id="wordCount" name="wordCount"><br><br>
<button type="button" onclick="sendTopicAndWordCount()">Generate Essay</button>
</form>
<div id="response" style="text-align: center;"></div>

<script>
function sendTopicAndWordCount() {
// Get the topic and word count from the form
var topic = document.getElementById("topic").value;
var wordCount = document.getElementById("wordCount").value;

  // Make the API request using a CORS proxy
  fetch("https://api.openai.com/v1/completions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer myapi"
    },
    body: JSON.stringify({
      "model": "text-davinci-003",
      "prompt": "essay on " + topic ,
     "max_tokens": parseInt(wordCount),
      "temperature": 0.1
    })
  })
  .then(response => response.json())

.then(response => {
// Display the API's response in the div
document.getElementById("response").innerHTML = response.text;
});
// https://cors-anywhere.herokuapp.com/https://api.openai.com/v1/completions
//https://api.openai.com/v1/text-davinci/questions
}
</script>
</body>
</html>``

#

When i go to my acccount its saying that i made request

#

5:25 PM
Local time: Jan 1, 2023, 10:55 PM
text-davinci, 1 request
8 prompt + 50 completion = 58 tokens
5:30 PM
Local time: Jan 1, 2023, 11:00 PM
text-davinci, 1 request
7 prompt + 40 completion = 47 tokens

burnt rampart
spark zenith
real coral
#

Where do you call your response? I just see a definition.