AB.newDiv("selectdiv");
const token = "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";
const url = "https://api.openai.com/v1/chat/completions";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token,
},
body: JSON.stringify({
'model': 'gpt-3.5-turbo',
'messages': [{"role": "user", "content": "Say 'Hello, world!'"}]
})
})
.then(response => {
return response.json(); // Return the JSON data from the response
})
.then(result => {
$("#selectdiv").html(result.choices[0].message.content);
console.log(result.choices[0].message.content); // Log the result to the console
})
.catch(error => {
console.error(error); // Handle any errors that occur during the request
});