// Slide 04: Hello world -- first chain with init_chat_model // Code slide: the simplest possible working example. 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: 'Hello world', title: 'Первый вызов модели', sectionNumber: 1, }); ds.helpers.addCodeBlock(slide, pres, theme, { x: 0.5, y: 1.5, w: 6.4, h: 3.25, language: 'python', filePath: 'examples/hello.py', code: [ '# Один универсальный инициализатор для всех провайдеров', 'from langchain.chat_models import init_chat_model', '', '# Формат: ":"', 'model = init_chat_model("openai:gpt-4.1-mini")', '', '# invoke -> BaseMessage; нам нужен .content', 'result = model.invoke("Say hello in one sentence")', 'print(result.content)', '', '# >>> "Hello! How can I help you today?"', ].join('\n'), }); // Right side: explanation card ds.helpers.addCallout(slide, pres, theme, { x: 7.1, y: 1.5, w: 2.4, h: 1.55, kind: 'info', title: 'init_chat_model', text: 'Один фабричный вызов вместо ChatOpenAI / ChatAnthropic / ChatGoogle отдельно.', }); ds.helpers.addCallout(slide, pres, theme, { x: 7.1, y: 3.2, w: 2.4, h: 1.55, kind: 'success', title: 'Что вернется', text: 'Объект AIMessage: content, response_metadata (usage, model_name), id, tool_calls.', }); ds.helpers.addSourceLine(slide, pres, theme, { source: 'python.langchain.com/docs/how_to/chat_models_universal_init/', }); ds.helpers.addPageNumber(slide, pres, theme, 4); } module.exports = { createSlide };