Engine Class
TextGenerator
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
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
พารามิเตอร์
ส่งค่ากลับ