Lớp công cụ
TextGenerator
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Mẫu mã
Tạo Văn Bản
local Workspace = game:GetService("Workspace")
local textGenerator = Instance.new("TextGenerator")
textGenerator.Parent = Workspace
textGenerator.SystemPrompt = "Bạn là một NPC hữu ích trong một thế giới ảo."
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("Văn bản được tạo ra: " .. response.GeneratedText)
print("Token ngữ cảnh: " .. response.ContextToken)
print("Mô hình: " .. response.Model)
return response
end
else
warn("Tạo văn bản thất bại: " .. tostring(response))
end
return nil
end
getResponse("Kể cho tôi điều gì đó thú vị.")Tài Liệu Tham Khảo API
Thuộc Tính
Phương Pháp
GenerateTextAsync
Tham Số
Lợi Nhuận