Skip to main content

Cookbooks

The jes repository's examples/ directory is a short course, read top to bottom. Each page below embeds one lesson exactly as it ships. Every lesson has two files that teach the same thing, and diffing them shows that only the models and the search tool change:

  • jev.py: hosted Jev decides; where a lesson needs them, OpenAI writes the replies and Tavily searches.
  • local.py: tev1 decides and qwen3:1.7b writes the replies, both on Ollama, and search returns a fixed page instead of calling Tavily. Nothing leaves your machine.

Lessons 01 and 11 also have openrouter.py: Jev decides through OpenRouter, and in lesson 11 an OpenRouter chat model writes the replies. One OPENROUTER_API_KEY covers both.

View examples/ on GitHub

Setup​

From a jes checkout:

uv sync --group examples
cp .env.example .env # for jev.py: TYPESAFE_API_KEY, OPENAI_API_KEY, TAVILY_API_KEY
# for openrouter.py: OPENROUTER_API_KEY (lesson 11 also needs TAVILY_API_KEY)
ollama pull tev1 && ollama pull qwen3:1.7b # for local.py

Then run a lesson as a module:

uv run --group examples python -m examples.01_first_check.jev
uv run --group examples python -m examples.01_first_check.local

Every threshold= is an application choice, not a library default: the lessons use 0.72 for Jev and 0.5 for tev1. Tune them on your own traffic, then pin the model, such as jev-1.13.0. See Thresholds.

_common.py only prints results and loads .env. _middleware.py is the LangChain middleware that lessons 13 and 15 share.

Part 1: Guard basics​

Part 2: In your agent​

Every lesson in this part runs the same three cases: a clean request, a prompt injection, and a tool that returns a poisoned page.