Trims chat context down to strictly relevant items before calling Gemini, Gemma, or OpenAI.
Select a query scenario to see context optimization in real time.
Integration snippet matching your current environment setup.
import { Memovable, createGeminiHandler } from "memovable";
const geminiHandler = createGeminiHandler({
apiKey: process.env.GEMINI_API_KEY,
model: "gemini-3.5-flash",
});
const memovable = Memovable({
tokensPerOptimizationCall: 2048,
modelHandler: geminiHandler,
});
const existingContext = [
{ role: "user", content: "Our Auth service crashed around 10:00 AM due to OOM kill on instance auth-prod-01." },
{ role: "assistant", content: "Understood. Auth service OOM incident logged for instance auth-prod-01 at 10:00 AM." },
{ role: "user", content: "We deployed v2.4.1 of the Payment gateway service at 10:15 AM." },
{ role: "assistant", content: "Payment gateway deployment v2.4.1 recorded." },
{ role: "user", content: "Who updated the IAM roles for the database cluster last night?" },
{ role: "assistant", content: "DevOps engineer Alex updated the DB IAM policies at 11:30 PM yesterday." },
{ role: "user", content: "The Redis caching layer went down at 11:00 AM due to connection pool exhaustion." },
{ role: "assistant", content: "Logged Redis cache incident: connection pool exhaustion at 11:00 AM." },
{ role: "user", content: "We decided to roll back the Payment gateway service to v2.4.0 due to high error rates." },
{ role: "assistant", content: "Payment gateway rollback decision logged." }
];
async function runScenario(queryText: string) {
const result = await memovable.optimise(queryText, existingContext);
console.log("Tokens:", result.tokens);
console.log("Filtered Context:", result.context);
console.log("Response:", result.response);
}
runScenario("What happened with the Redis cache instance?");
Configures the engine with token limits and handler adapter.
Direct client initialization for Gemini API endpoints.