概要
方法
GenerateTextAsync(request: Dictionary):Dictionary |
代码示例
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 参考
属性
方法
GenerateTextAsync