initial commit: slides ready + upgraded

This commit is contained in:
2026-05-24 10:37:53 +02:00
commit f6f46972c3
173 changed files with 16756 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
---
layout: default
---
# Structured Output
<div class="text-sm mt-6">
<v-click>
<div class="mb-4">
**Problema:** Las respuestas de LLMs son texto plano, difíciles de procesar
**Solución:** Forzar al modelo a responder con JSON estructurado
</div>
</v-click>
<v-click>
```typescript
import { ChatOpenAI } from "@langchain/openai";
import { z } from "zod";
// Definir el esquema con Zod
const schema = z.object({
sentiment: z.enum(["positive", "negative", "neutral"]),
score: z.number().min(0).max(1),
keywords: z.array(z.string()),
});
const model = new ChatOpenAI({ model: "gpt-4.1-mini" })
.withStructuredOutput(schema);
const result = await model.invoke("Me encanta LangChain!");
// { sentiment: "positive", score: 0.95, keywords: ["encanta", "langchain"] }
```
</v-click>
</div>