概要
方法
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