Advertisement
Guest User

Untitled

a guest
Mar 1st, 2023
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string gChatGptApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxx";
  2.  
  3. default
  4. {
  5.     state_entry()
  6.     {
  7.         llListen(0, "", llGetOwner(), "");
  8.     }
  9.  
  10.     listen(integer channel, string name, key id, string message)
  11.     {
  12.         string json = llList2Json(JSON_OBJECT, [
  13.             "model", "text-davinci-003",
  14.             "prompt", message,
  15.             "temperature", 0.9,
  16.             "max_tokens", 150,
  17.             "top_p", 1,
  18.             "frequency_penalty", 0.0,
  19.             "presence_penalty", 0.6
  20.         ]);
  21.         llHTTPRequest("https://api.openai.com/v1/completions", [
  22.             HTTP_MIMETYPE, "application/json",
  23.             HTTP_METHOD, "POST",
  24.             HTTP_BODY_MAXLENGTH, 16384,
  25.             HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + gChatGptApiKey
  26.         ], json);
  27.     }
  28.  
  29.     http_response(key request_id, integer status, list metadata, string body)
  30.     {
  31.         llSay(0, llStringTrim(llJsonGetValue(llJsonGetValue(body, ["choices", 0]), ["text"]), STRING_TRIM));
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement