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
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
// Slide 15: Async + configurable -- ainvoke/astream + chain.config
|
|
// Code slide: how to use chains from async code and override params at call site.
|
|
|
|
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: 'async + config -- полный контроль',
|
|
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_async.py',
|
|
code: [
|
|
'import asyncio',
|
|
'from langchain_core.runnables import ConfigurableField',
|
|
'',
|
|
'# Любой Runnable имеет ainvoke / astream / abatch',
|
|
'async def main():',
|
|
' # Один async-вызов',
|
|
' result = await chain.ainvoke({"language": "French", "text": "Hi"})',
|
|
'',
|
|
' # Async stream',
|
|
' async for chunk in chain.astream({"language": "French", "text": "Hi"}):',
|
|
' print(chunk, end="", flush=True)',
|
|
'',
|
|
'asyncio.run(main())',
|
|
'',
|
|
'# configurable_fields -- параметры, которые можно переопределять',
|
|
'# на лету через config={"configurable": {...}}',
|
|
'configurable_chain = init_chat_model("openai:gpt-4.1-mini",',
|
|
' temperature=0.7).configurable_fields(',
|
|
' temperature=ConfigurableField(id="temperature"),',
|
|
')',
|
|
'# configurable_chain.invoke(messages, config={"configurable": {"temperature": 0.0}})',
|
|
].join('\n'),
|
|
});
|
|
|
|
ds.helpers.addCallout(slide, pres, theme, {
|
|
x: 0.5, y: 4.85, w: 9.0, h: 0.3,
|
|
kind: 'success',
|
|
text: 'configurable_fields + config={"configurable": {...}} -- паттерн для multi-tenant LLM-приложений.',
|
|
});
|
|
|
|
ds.helpers.addSourceLine(slide, pres, theme, {
|
|
source: 'python.langchain.com/docs/how_to/configurable/',
|
|
});
|
|
ds.helpers.addPageNumber(slide, pres, theme, 15);
|
|
}
|
|
|
|
module.exports = { createSlide }; |