#Anyone here getting a Error Cannot read

27 messages · Page 1 of 1 (latest)

final cradle
#

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;

}

rigid fjord
#

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

final cradle
#

Ok - let me try that. One sec

#

Dang...same issue

#

*error

rigid fjord
#

but what's the output?

final cradle
#

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

final cradle
#

Was just looking at that. I have a paid account with plenty of tokens, so I am assuming it's not that

rigid fjord
#

I'd try it in the playground too just in case

#

just type anything and see if it completes

final cradle
#

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

rigid fjord
#

@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

final cradle
#

Ok give me a tick

#

Same error message and not giving a response...so odd

rigid fjord
#

that shouldn't be possible

#

you wanna Discord screenshare with me?

final cradle
#

Yeah hit me. I am new to discord, no idea how to do that

rigid fjord
#

I'll DM you