学习
引擎类
TextGenerator

*此内容使用人工智能(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 是我们在美国及其他国家或地区的注册与未注册商标。