學習
引擎類別
TextGenerator

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
繼承成員
範例程式碼
local Workspace = game:GetService("Workspace")
local textGenerator = Instance.new("TextGenerator")
textGenerator.Parent = Workspace
textGenerator.SystemPrompt = "你是一個虛擬世界中的有幫助的 NPC。"
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("生成的文本: " .. response.GeneratedText)
print("上下文令牌: " .. response.ContextToken)
print("模型: " .. response.Model)
return response
end
else
warn("文本生成失敗: " .. tostring(response))
end
return nil
end
getResponse("告訴我一些酷的事。")

API 參考
屬性
Seed
平行讀取
功能: Basic
TextGenerator.Seed:number

SystemPrompt
平行讀取
功能: Basic
TextGenerator.SystemPrompt:string

Temperature
平行讀取
功能: Basic
TextGenerator.Temperature:number

TopP
平行讀取
功能: Basic
TextGenerator.TopP:number

方法
GenerateTextAsync
暫停
功能: Basic
TextGenerator:GenerateTextAsync(request:Dictionary):Dictionary
參數
request:Dictionary

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。