75601988c2
- Cover, TOC, 5 dividers, 3 recap slides - 5 sections (chains, langgraph, deepagents, openswe, ecosystem) - design-system.js with theme tokens + 9 helper functions - research/: timeline + sources + per-tech notes - final-compile.js + merge.js for rebuild pipeline - output/: langchain-evolution.pptx (2.3 MB) + langchain-evolution.pdf (1.1 MB) + 7 sample previews
54 lines
2.1 KiB
JavaScript
54 lines
2.1 KiB
JavaScript
// Slide 12: with_structured_output -- the recommended v1.0 way
|
|
// Code slide: model.with_structured_output(Schema) instead of legacy parsers.
|
|
|
|
const ds = require('./design-system');
|
|
|
|
function createSlide(pres, theme) {
|
|
const slide = pres.addSlide();
|
|
ds.helpers.slideBase(slide, pres, theme);
|
|
|
|
ds.helpers.addHeader(slide, pres, theme, {
|
|
eyebrow: 'STAGE 1: CHAINS',
|
|
section: 'Output parsers',
|
|
title: 'with_structured_output -- рекомендованный путь',
|
|
sectionNumber: 1,
|
|
});
|
|
|
|
ds.helpers.addCodeBlock(slide, pres, theme, {
|
|
x: 0.5, y: 1.5, w: 9.0, h: 3.25,
|
|
language: 'python',
|
|
filePath: 'examples/structured.py',
|
|
code: [
|
|
'from pydantic import BaseModel, Field',
|
|
'from langchain.chat_models import init_chat_model',
|
|
'',
|
|
'class Weather(BaseModel):',
|
|
' city: str = Field(description="City name")',
|
|
' temperature_c: float = Field(description="Temperature in Celsius")',
|
|
' conditions: str = Field(description="Weather summary")',
|
|
'',
|
|
'# Один вызов -- и модель возвращает типизированный Pydantic-объект',
|
|
'model = init_chat_model("openai:gpt-4.1-mini")',
|
|
'structured = model.with_structured_output(Weather)',
|
|
'',
|
|
'result: Weather = structured.invoke("Weather in Paris?")',
|
|
'print(result.city, result.temperature_c, result.conditions)',
|
|
'',
|
|
'# method="json_mode" -- если провайдер не поддерживает tool calling',
|
|
'# structured_json = model.with_structured_output(Weather, method="json_mode")',
|
|
].join('\n'),
|
|
});
|
|
|
|
ds.helpers.addCallout(slide, pres, theme, {
|
|
x: 0.5, y: 4.85, w: 9.0, h: 0.3,
|
|
kind: 'info',
|
|
text: 'Под капотом: tool calling или provider-native JSON mode. Без extra LLM-вызовов, в один проход.',
|
|
});
|
|
|
|
ds.helpers.addSourceLine(slide, pres, theme, {
|
|
source: 'python.langchain.com/docs/how_to/structured_output/',
|
|
});
|
|
ds.helpers.addPageNumber(slide, pres, theme, 12);
|
|
}
|
|
|
|
module.exports = { createSlide }; |