// Slide 21: Short-term memory -- thread_id + checkpointer // Code slide: persistent conversation per thread. 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: 'Memory', title: 'Краткосрочная память: thread + checkpointer', sectionNumber: 1, }); ds.helpers.addCodeBlock(slide, pres, theme, { x: 0.5, y: 1.5, w: 9.0, h: 3.25, language: 'python', filePath: 'examples/memory_short.py', code: [ 'from langchain.agents import create_agent', 'from langgraph.checkpoint.memory import InMemorySaver', '', 'checkpointer = InMemorySaver()', '', 'agent = create_agent(', ' model="openai:gpt-4.1-mini",', ' tools=[...],', ' checkpointer=checkpointer, # <-- persistent state', ')', '', 'config = {"configurable": {"thread_id": "user-42"}}', '', '# Первый turn', 'agent.invoke({"messages": [{"role": "user",', ' "content": "My name is Alice."}]}, config=config)', '', '# Второй turn -- модель помнит имя', 'result = agent.invoke({"messages": [{"role": "user",', ' "content": "What is my name?"}]}, config=config)', 'print(result["messages"][-1].content) # "Alice"', ].join('\n'), }); ds.helpers.addCallout(slide, pres, theme, { x: 0.5, y: 4.85, w: 9.0, h: 0.3, kind: 'success', text: 'InMemorySaver для dev. Для прода -- PostgresSaver / RedisSaver (те же LangGraph checkpointer-ы).', }); ds.helpers.addSourceLine(slide, pres, theme, { source: 'docs.langchain.com/oss/python/langgraph/persistence', }); ds.helpers.addPageNumber(slide, pres, theme, 21); } module.exports = { createSlide };