Back to Icho Home Icho v0.8.0

Basic Usage

Wrap your LLM invocations using the cassette context manager:

from langchain_groq import ChatGroq
from icho import cassette

model = ChatGroq(model_name="llama-3.1-8b-instant")

# Intercept calls within this context block
with cassette("tests/cassettes"):
    response = model.invoke("Slogan for gravity")
    print(response.content)

How it acts under the hood:

  1. On the first execution, a JSON file is generated inside the tests/cassettes directory containing the request payload hash, provider metadata, and response content.
  2. Icho automatically updates metadata.json in the cassette directory.
  3. On subsequent executions, Icho intercepts the API call, evaluates the input parameter hash, finds the match, and immediately yields the response in ~12ms.