then when I press a number on the game (1 for example), it sends a request to the calculator to type 1, then I choose an operation (still in the game), then it sends it also to the calculator site, so I already have 1+ and I need one more number so I type 4 (in the game) then it sends it to the calculator again, then I press equal, so it sends it to the website again, then ofcourse it would output 5, then the game receives 5. But the problem is, I don’t know how to interact with websites (click buttons) as I am new to HTTPService. So how can I interact with websites and then get the output from it? Thank you in advance.
It looks like the Google calculator has no API, so you can’t interact with it with code. Also, this is not how HTTP requests work, you do not tell the website to click on a button, you tell the website what buttons you clicked and wait for the website to give a response.
I need it to take the input from the player, then type it in the text bar (the one with “Once upon a time,” in it) then, run the compute button, and get the json output
Using Chrome’s DevTools, I inspected the network request made when you press “Compute”. The URL is https://api-inference.huggingface.co/models/EleutherAI/gpt-neo-1.3B and the POST body is {"inputs": "Once upon a time,"}, with “Once upon a time” being your input for the AI.
Then, use HttpService:PostAsync to POST to the endpoint.
(Make sure you’re doing this on the server)
local HttpService = game:GetService("HttpService")
local data = { ["inputs"] = "Once upon a time," }
local json = HttpService:JSONEncode(data)
local response = HttpService:PostAsync("https://api-inference.huggingface.co/models/EleutherAI/gpt-neo-1.3B", json)
local decoded = HttpService:JSONDecode(response)
print(decoded[1].generated_text)