-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPT.Lua
More file actions
25 lines (20 loc) · 847 Bytes
/
GPT.Lua
File metadata and controls
25 lines (20 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local HttpService = game:GetService("HttpService")
local API_KEY = _G.Apikey
local API_URL = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"
local function chatWithAI(question)
local requestBody = HttpService:JSONEncode({ inputs = question })
local success, response = pcall(function()
return HttpService:PostAsync(API_URL, requestBody, Enum.HttpContentType.ApplicationJson, false, {
["Authorization"] = "Bearer " .. API_KEY
})
end)
if success then
local jsonResponse = HttpService:JSONDecode(response)
return jsonResponse.generated_text or "AI Error: No response"
else
return "AI Error: HTTP blocked on this executor"
end
end
-- Example Usage
_G.chatWithAI = chatWithAI
print("ChatGPT AI Loaded! Use `_G.chatWithAI('your message')`")