My AI chatbot script linked to GPT-2 API isnt working. Any help?
local HttpService = game:GetService("HttpService")
local API_KEY = "blanked out for privacy"
local API_URL = "https://api.openai.com/v1/engines/davinci/completions"
function generateText(prompt, length)
local requestBody = HttpService:JSONEncode({
prompt = prompt,
length = length,
temperature = 0.7,
})
local headers = {
["Content-Type"] = "application/json",
["Authorization"] = "Bearer " .. API_KEY,
}
local response = HttpService:PostAsync(API_URL, requestBody, headers)
local responseData = HttpService:JSONDecode(response)
return responseData.choices[1].text
end
local generatedText = generateText("Once upon a time,", 50)
print(generatedText)