Advertisement
ecco7777

testing AI generated code

Dec 10th, 2022 (edited)
1,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. if fs.exists("json") == false then
  2.     shell.run("pastebin get 4nRg9CHU json")
  3. end
  4. if fs.exists("pf") == false then
  5.     shell.run("pastebin get 2HXb06ic pf")
  6. end
  7. os.loadAPI("json")
  8. os.loadAPI("pf")
  9.  
  10. local id = pf.getID()
  11. local prompt = "What would you like to ask ChatGPT?"
  12. local message = read(prompt)
  13. local data = {
  14.     prompt = message,
  15.     id = id
  16. }
  17. local jsonData = json.encode(data)
  18.  
  19. local response = http.post("https://api.openai.com/v1/engines/davinci-codex/completions", jsonData, {
  20.     ["Content-Type"] = "application/json",
  21.     ["Authorization"] = "Bearer ".."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"
  22. })
  23. local responseJson = json.decode(response.readAll())
  24. local answer = responseJson.choices[1].text
  25. print(answer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement