import { SDK } from '@meetkai/mka1';
const mka1 = new SDK({
bearerAuth: `Bearer ${YOUR_API_KEY}`,
});
const headers = { 'X-On-Behalf-Of': 'user-123' };
// 1. Crear un prompt con la plantilla inicial
const prompt = await mka1.llm.prompts.create({
name: 'support-reply',
template: 'Hi {{customer}}, thanks for contacting us about {{issue}}.',
}, { headers });
console.log('Creado:', prompt.id, 'v1');
// 2. Publicar v2 con un tono más amigable
const v2 = await mka1.llm.prompts.createVersion({
id: prompt.id,
requestBody: {
template: 'Hey {{customer}}! We got your message about {{issue}} and are on it.',
},
}, { headers });
console.log('Creada v2:', v2.version);
// 3. Recuperar el prompt — la versión activa ahora es la v2
const current = await mka1.llm.prompts.get({
id: prompt.id,
variables: JSON.stringify({ customer: 'Alice', issue: 'billing' }),
}, { headers });
console.log('Activo:', current.renderedTemplate);
// "Hey Alice! We got your message about billing and are on it."
// 4. Revisar el historial de versiones
const history = await mka1.llm.prompts.listVersions({
id: prompt.id,
order: 'asc',
}, { headers });
for (const v of history.data) {
console.log(` v${v.version}: ${v.template}`);
}
// 5. Revertir a v1
const rolledBack = await mka1.llm.prompts.rollback({
id: prompt.id,
requestBody: {
version: 1,
},
}, { headers });
console.log('Revertido a v' + rolledBack.activeVersion);
// active_version=1, latest_version=2
// 6. Limpiar
await mka1.llm.prompts.delete({ id: prompt.id }, { headers });