#Anyone here getting a Error Cannot read
27 messages · Page 1 of 1 (latest)
This is the section of the code:
export const getAnswerfromAI = async (prompt) => {
const url = "https://api.openai.com/v1/completions"
const apiKey = await getSecret(REMOVED FOR CHAT);
const body = {
"model": "text-davinci-003",
"prompt": prompt,
"max_tokens": 4000,
"temperature": 0.7,
}
const options = {
method: "POST",
headers: {
'Content-Type': "application/json",
'Authorization': Bearer ${apiKey}
},
body: JSON.stringify(body),
}
const response = await fetch(url, options);
const data = await response.json();
return data.choices[0].text;
}
You can format your code by adding at the start of your message
I can't see anything obviously wrong with your code, but try console.log(data) and see what you're getting @final cradle
but what's the output?
Nada. And what's even more weird, is that it worked well last night, I was sporadically getting that error, but not consistently. Woke up this morning, made no changes and started to get the error every time
First thing I'd do is check your https://beta.openai.com/account/usage
Was just looking at that. I have a paid account with plenty of tokens, so I am assuming it's not that
I'd try it in the playground too just in case
just type anything and see if it completes
Good idea. I will check that now
I just typed, "Hi" into the playground and it gave me this:
Thank you for your question. Generally, the process for obtaining a visa to visit the United States involves completing an online application form and providing supporting documents such as a valid passport and proof of financial support. You may also need to attend an interview at the US embassy or consulate. The processing time for a visa application can vary from a few days to several weeks, depending on the country you are from.
For more detailed information, please visit the website of the US Department of State.
Thanks.
How odd is that
@final cradle okay, next thing I'd do is console.log(response) instead of data and see what happens
await response.json() will be null if there's no json
so let's see what the response is giving you
Yeah hit me. I am new to discord, no idea how to do that
I'll DM you