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:
- On the first execution, a JSON file is generated inside the
tests/cassettesdirectory containing the request payload hash, provider metadata, and response content. - Icho automatically updates
metadata.jsonin the cassette directory. - On subsequent executions, Icho intercepts the API call, evaluates the input parameter hash, finds the match, and immediately yields the response in ~12ms.
