Skip to content

Instantly share code, notes, and snippets.

View eric-burel's full-sized avatar
Writing agentic AI professional trainings

Eric Burel eric-burel

Writing agentic AI professional trainings
View GitHub Profile
@eric-burel
eric-burel / langgraph-colab-sqlite-checkpoint
Last active June 27, 2025 12:39
LangGraph checkpointer using Google Colab + Google Drive + SQLite
# Commented out IPython magic to ensure Python compatibility.
# %pip install -q langgraph
# %pip install -q langgraph-checkpoint-sqlite
# Demo notebook: https://colab.research.google.com/drive/16V9TpOsLMOuU655ryerni7Hc7mni6hcU?usp=sharing
import os
from google.colab import drive
DRIVE_MOUNT_POINT = "/content/drive"
drive.mount(DRIVE_MOUNT_POINT)
@eric-burel
eric-burel / google-colab-anthropic-batch-api-langgraph.py
Created June 27, 2025 17:12
Use LangGraph, SQLite, Google Colab and Google Drive to handle long running Anthropic batch API calls elegantly
# -*- coding: utf-8 -*-
"""LBKE Anthropic batch runner.ipynb
## Demo of calling Anthropic Batch API from a LangGraph graph
Improvements:
- an interrupt should be prefered to ending the chart when the work is pending => currently each new run to check if the batch is there will send a new message to the thread since we re-invoke the chart
- better processing responses, maybe using a MessageState/add reducer to treat the response as an assistant message added to a conversation
- as a bonus, polling the chart on a predefined frequence (useful for a quick run)
- test if it still works after the notebook is closed thanks to gdrive checkpointing
// npm install turndown cheerio
import TurndownService from "turndown"
import { load } from "cheerio"
async function downloadUrlAsMarkdown(url: string, selector?: string) {
try {
const res = await fetch(url)
if (!res.ok) {
throw new Error(`${url} ${res.status} ${res.statusText}`)