Add 122 Python example scripts + .env.example

Each of the 122 code slides now has a standalone .py script in
examples/slide-NNN/script.py with the LLM provider pattern from
bro-js/agents/teacher/assistant/src/angry_teacher/llm.py:
  - load_dotenv() + ChatOpenAI with base_url=https://llm.brojs.ru/v1
  - OPENAI_API_KEY from .env (with safe (or '' or None) pattern)
  - Same comment block with alternative model/base_url choices

Layout:
  - sec1/sec5: code extracted from slide-NN.js (addCodeBlock)
  - sec2/sec3/sec4: code extracted from sectionN.pptx via python-pptx
    (JetBrains Mono font shapes)

100 scripts contain runnable code, 22 are visual-only (dividers,
intro, recap) and just print the slide title.

Setup:
  cp .env.example .env       # fill OPENAI_API_KEY (or symlink to your
                              # teacher/assistant/.env)
  pip install -r requirements.txt
  python examples/slide-005/script.py
This commit is contained in:
2026-06-22 12:02:47 +03:00
parent 75601988c2
commit 1fd7486a85
125 changed files with 6564 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
"""
Slide 84: Slide 24
Section 3: Deep Agents
Source: slides/section3-deepagents/section3.pptx
Сгенерировано автоматически из slide-NN.js / sectionN.pptx.
Паттерн провайдера скопирован из
bro-js/agents/teacher/assistant/src/angry_teacher/llm.py.
Запуск:
cd langchain-evolution-deck
cp .env.example .env # заполни OPENAI_API_KEY
python examples/slide-084/script.py
"""
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
load_dotenv()
llm = ChatOpenAI(
# model="openrouter/free",
# model="qwen/qwen3.5-35b-a3b",
model="openai/gpt-oss-20b",
# model="nvidia/nemotron-3-nano",
# model="qwen/qwen3.5-9b",
base_url="https://llm.brojs.ru/v1",
# base_url="https://api.minimax.io/v1",
# base_url="http://0.0.0.0:8090/v1",
# base_url="https://openrouter.ai/api/v1",
# api_key=os.getenv("MINIMAX_API_KEY"),
api_key=(os.getenv("OPENAI_API_KEY") or "").strip() or None,
temperature=0.7,
stream_usage=True,
)
# === Code from slide 84 ===
// examples/coding_agent.py:1-17
from deepagents import create_deep_agent
from deepagents.backends import SandboxBackend
> agent = create_deep_agent(
> model="anthropic:claude-sonnet-4-5",
> backend=SandboxBackend(
> provider="daytona", # or modal / runloop
> api_key=os.environ["DAYTONA_API_KEY"],
> image="python:3.12-slim",
> ),
> system_prompt=("You are a coding agent. Always run tests after edits. Stop and ask if requirements are ambiguous."),
)
agent.invoke({"messages": "Add a /healthz endpoint to the FastAPI app, with tests."})
# Daytona/Modal/Runloop execute code in an isolated container;
# the local process never sees a stray rm -rf.
// note: snippet has 17 lines, card fits ~16