Initial commit: LangChain evolution tutorial deck (132 slides)
- 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
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// Slide 16: RunnableLambda + RunnablePassthrough -- custom logic in pipeline
|
||||
// Code slide: insert arbitrary Python functions into an LCEL chain.
|
||||
|
||||
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 helpers',
|
||||
title: 'RunnableLambda + RunnablePassthrough',
|
||||
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_lambda.py',
|
||||
code: [
|
||||
'from langchain_core.runnables import RunnableLambda, RunnablePassthrough',
|
||||
'',
|
||||
'# RunnableLambda -- оборачивает произвольную функцию',
|
||||
'upper = RunnableLambda(lambda x: x.upper())',
|
||||
'word_count = RunnableLambda(lambda text: {"text": text, "words": len(text.split())})',
|
||||
'',
|
||||
'# RunnablePassthrough -- пропускает вход дальше (для branching)',
|
||||
'passthrough = RunnablePassthrough()',
|
||||
'',
|
||||
'# Пример: текст -> uppercase -> посчитать слова -> смёрджить с оригиналом',
|
||||
'chain = (',
|
||||
' word_count',
|
||||
' | RunnablePassthrough.assign(upper=upper)',
|
||||
')',
|
||||
'',
|
||||
'result = chain.invoke("hello world from langchain")',
|
||||
'print(result)',
|
||||
'# {"text": "hello world from langchain",',
|
||||
'# "words": 4, "upper": "HELLO WORLD FROM LANGCHAIN"}',
|
||||
].join('\n'),
|
||||
});
|
||||
|
||||
ds.helpers.addCallout(slide, pres, theme, {
|
||||
x: 0.5, y: 4.85, w: 9.0, h: 0.3,
|
||||
kind: 'info',
|
||||
text: 'RunnablePassthrough.assign -- добавляет новые ключи, сохраняя исходные. Идеален для RAG-style цепочек.',
|
||||
});
|
||||
|
||||
ds.helpers.addSourceLine(slide, pres, theme, {
|
||||
source: 'python.langchain.com/docs/how_to/functions/',
|
||||
});
|
||||
ds.helpers.addPageNumber(slide, pres, theme, 16);
|
||||
}
|
||||
|
||||
module.exports = { createSlide };
|
||||
Reference in New Issue
Block a user