Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function requestRoast(prompt)
- -- Define the payload
- local payload = {
- userMessage = {
- role = "user",
- content = prompt
- },
- history = {
- {
- role = "assistant",
- content = "Hello there. I'm here to roast you."
- }
- },
- style = "default"
- }
- -- Convert the payload to JSON
- local json = game:GetService("HttpService"):JSONEncode(payload)
- -- Perform the API request
- local response = http_request({
- Url = "https://www.roastedby.ai/api/generate",
- Method = "POST",
- Headers = {
- ["Accept"] = "*/*",
- ["Accept-Language"] = "en-US,en;q=0.9",
- ["Content-Type"] = "application/json"
- },
- Body = json
- })
- -- Check response and parse it
- if response and response.StatusCode == 200 then
- local data = game:GetService("HttpService"):JSONDecode(response.Body)
- return data.content or "No response from the API."
- else
- return "Request failed: " .. (response and response.StatusMessage or "Unknown error")
- end
- end
- -- Example usage
- local roast = requestRoast("Why do programmers prefer dark mode?")
- print(roast)
Advertisement
Add Comment
Please, Sign In to add comment