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.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
// Slide 05: RunTree -- manual tracing when @traceable is not enough
|
|
// Code slide: explicit parent/child control with RunTree.
|
|
|
|
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 5: ECOSYSTEM',
|
|
section: 'Tracing',
|
|
title: 'RunTree -- ручной контроль над деревом',
|
|
sectionNumber: 5,
|
|
titleSize: 24,
|
|
});
|
|
|
|
ds.helpers.addCodeBlock(slide, pres, theme, {
|
|
x: 0.5, y: 1.45, w: 9.0, h: 3.1,
|
|
language: 'python',
|
|
fontSize: 10,
|
|
code: [
|
|
'from langsmith.run_trees import RunTree',
|
|
'',
|
|
'# RunTree -- explicit handle: создается руками, передается',
|
|
'# в код, потом post() отправляет в LangSmith. Нужно когда',
|
|
'# @traceable не подходит (динамич. дерево, не-Python, metadata).',
|
|
'parent = RunTree(',
|
|
' name="agent_turn",',
|
|
' run_type="chain",',
|
|
' inputs={"q": "Who invented Python?"},',
|
|
' project_name="my-agent-dev",',
|
|
')',
|
|
'try:',
|
|
' answer = my_agent(question, run_tree=parent)',
|
|
' parent.end(outputs={"answer": answer})',
|
|
'except Exception as e:',
|
|
' parent.end(error=str(e)) # ошибка логируется',
|
|
' raise',
|
|
'finally:',
|
|
' parent.post() # flush в LangSmith',
|
|
].join('\n'),
|
|
});
|
|
|
|
ds.helpers.addCallout(slide, pres, theme, {
|
|
x: 0.5, y: 4.65, w: 9.0, h: 0.4,
|
|
kind: 'warning',
|
|
text: 'Не забудьте parent.post() -- иначе trace не отправится. Дочерние через parent.create_child(...).',
|
|
});
|
|
|
|
ds.helpers.addSourceLine(slide, pres, theme, {
|
|
source: 'docs.smith.langchain.com Observability > Log traces > RunTree',
|
|
});
|
|
ds.helpers.addPageNumber(slide, pres, theme, 5);
|
|
}
|
|
|
|
module.exports = { createSlide };
|