Engine Class
TextGenerator
Code Samples
local Workspace = game:GetService("Workspace")
local textGenerator = Instance.new("TextGenerator")
textGenerator.Parent = Workspace
textGenerator.SystemPrompt = "You are a helpful NPC in a virtual world."
textGenerator.Temperature = 0.8
textGenerator.TopP = 0.6
textGenerator.Seed = 7
local function getResponse(userInput)
local request = {
UserPrompt = userInput,
MaxTokens = 50
}
local success, response = pcall(function()
return textGenerator:GenerateTextAsync(request)
end)
if success then
if response then
print("Generated Text: " .. response.GeneratedText)
print("Context Token: " .. response.ContextToken)
print("Model: " .. response.Model)
return response
end
else
warn("Text generation failed: " .. tostring(response))
end
return nil
end
getResponse("Tell me something cool.")API Reference
Properties
Methods
GenerateTextAsync
Parameters
Returns