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
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
// Slide 13: LCEL -- the pipe operator and the Runnable protocol
|
|
// Code slide: every component is a Runnable, | composes them.
|
|
|
|
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: 'LCEL',
|
|
title: '| -- декларативная композиция',
|
|
sectionNumber: 1,
|
|
});
|
|
|
|
ds.helpers.addCodeBlock(slide, pres, theme, {
|
|
x: 0.5, y: 1.5, w: 9.0, h: 3.25,
|
|
language: 'python',
|
|
filePath: 'examples/lcel_intro.py',
|
|
code: [
|
|
'from langchain_core.prompts import ChatPromptTemplate',
|
|
'from langchain_core.output_parsers import StrOutputParser',
|
|
'from langchain.chat_models import init_chat_model',
|
|
'',
|
|
'prompt = ChatPromptTemplate.from_messages([',
|
|
' ("system", "You are a {style} assistant."),',
|
|
' ("human", "{question}"),',
|
|
'])',
|
|
'model = init_chat_model("openai:gpt-4.1-mini")',
|
|
'',
|
|
'# prompt, model, parser -- все три реализуют Runnable',
|
|
'# Оператор | склеивает их в один chain',
|
|
'chain = prompt | model | StrOutputParser()',
|
|
'',
|
|
'# type(chain) -> RunnableSequence',
|
|
'print(type(chain).__name__)',
|
|
'',
|
|
'# invoke -> dict на вход, str на выход',
|
|
'print(chain.invoke({"style": "concise", "question": "What is LCEL?"}))',
|
|
].join('\n'),
|
|
});
|
|
|
|
ds.helpers.addCallout(slide, pres, theme, {
|
|
x: 0.5, y: 4.85, w: 9.0, h: 0.3,
|
|
kind: 'success',
|
|
text: 'Runnable -- единый контракт: invoke / batch / stream / ainvoke / abatch / astream / async stream.',
|
|
});
|
|
|
|
ds.helpers.addSourceLine(slide, pres, theme, {
|
|
source: 'python.langchain.com/docs/concepts/lcel/',
|
|
});
|
|
ds.helpers.addPageNumber(slide, pres, theme, 13);
|
|
}
|
|
|
|
module.exports = { createSlide }; |