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
53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
// Slide 14: Runnable interface -- invoke / batch / stream
|
||
// Code slide: same chain, three execution modes -- no code changes needed.
|
||
|
||
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: 'Runnable',
|
||
title: 'invoke / batch / stream -- без смены кода',
|
||
sectionNumber: 1,
|
||
});
|
||
|
||
ds.helpers.addCodeBlock(slide, pres, theme, {
|
||
x: 0.5, y: 1.5, w: 9.0, h: 3.25,
|
||
language: 'python',
|
||
filePath: 'examples/runnable_modes.py',
|
||
code: [
|
||
'chain = prompt | model | StrOutputParser()',
|
||
'',
|
||
'# 1. invoke -- один вход, один выход',
|
||
'out_one = chain.invoke({"language": "French", "text": "Good morning"})',
|
||
'',
|
||
'# 2. batch -- список входов, список выходов (параллельно)',
|
||
'out_many = chain.batch([',
|
||
' {"language": "French", "text": "Good morning"},',
|
||
' {"language": "German", "text": "Good morning"},',
|
||
' {"language": "Spanish", "text": "Good morning"},',
|
||
'])',
|
||
'print(out_many) # ["Bonjour", "Guten Morgen", "Buenos dias"]',
|
||
'',
|
||
'# 3. stream -- итератор по чанкам (стримит последний Runnable)',
|
||
'for chunk in chain.stream({"language": "French", "text": "Stream me"}):',
|
||
' print(chunk, end="", flush=True)',
|
||
].join('\n'),
|
||
});
|
||
|
||
ds.helpers.addCallout(slide, pres, theme, {
|
||
x: 0.5, y: 4.85, w: 9.0, h: 0.3,
|
||
kind: 'info',
|
||
text: 'batch полезен для embedding-style задач. stream -- для UX с typewriter-эффектом в UI.',
|
||
});
|
||
|
||
ds.helpers.addSourceLine(slide, pres, theme, {
|
||
source: 'python.langchain.com/docs/how_to/batch/',
|
||
});
|
||
ds.helpers.addPageNumber(slide, pres, theme, 14);
|
||
}
|
||
|
||
module.exports = { createSlide }; |