Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string gChatGptApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxx";
- default
- {
- state_entry()
- {
- llListen(0, "", llGetOwner(), "");
- }
- listen(integer channel, string name, key id, string message)
- {
- string json = llList2Json(JSON_OBJECT, [
- "model", "text-davinci-003",
- "prompt", message,
- "temperature", 0.9,
- "max_tokens", 150,
- "top_p", 1,
- "frequency_penalty", 0.0,
- "presence_penalty", 0.6
- ]);
- llHTTPRequest("https://api.openai.com/v1/completions", [
- HTTP_MIMETYPE, "application/json",
- HTTP_METHOD, "POST",
- HTTP_BODY_MAXLENGTH, 16384,
- HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + gChatGptApiKey
- ], json);
- }
- http_response(key request_id, integer status, list metadata, string body)
- {
- llSay(0, llStringTrim(llJsonGetValue(llJsonGetValue(body, ["choices", 0]), ["text"]), STRING_TRIM));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement