Lyra Gen bilan generativ interfeys
Model javoblari haqiqiy, tekshirilgan Lyra boshqaruv elementlari sifatida ko‘rsatiladi.
Lyra Gen modelning tuzilmali javobini ko‘rib chiqilgan katalog orqali foydalanish imkoniyati yaxshi Lyra komponentlariga aylantiradi. Yaratilgan kontent faqat katalogdagi rollarni ko‘rsatishi mumkin, o‘zboshimchalik bilan teg, skript yoki amalni emas; modelga so‘rov, ma’lumotlar, amallar va saqlash ilovangizda qoladi.
Misol
Ko‘rib chiqilgan katalogning bir qismini tanlang, so‘ng yaratilgan ko‘rinishni chizishdan oldin tekshiring.
import '@aceshooting/lyra-ui/theme.css';
import { initialCatalog, subsetCatalog } from '@aceshooting/lyra-gen/catalog.js';
import { validateView } from '@aceshooting/lyra-gen/runtime.js';
import { LyraGenViewElement } from '@aceshooting/lyra-gen/gen-view.js';
const selected = subsetCatalog(initialCatalog, ['stack', 'heading', 'text']);
if (!selected.ok) throw new Error('The requested catalog is unavailable.');
const catalog = selected.value;
const result = validateView({
version: '1', catalog: { id: catalog.id, version: catalog.version },
surfaceId: 'answer-1', revision: 0,
root: { id: 'summary', type: 'stack', children: [
{ id: 'title', type: 'heading', text: 'Quarterly summary' },
{ id: 'detail', type: 'text', text: 'Revenue increased this quarter.' },
] },
}, catalog);
if (!result.ok) throw new Error('The generated view was rejected.');
const view = new LyraGenViewElement();
view.catalog = catalog;
view.document = result.value;
document.body.append(view);