llm-emulator
Version:
Enterprise-grade LLM mock server for local and CI: scenarios, faults, latency, contracts, VCR. Supports standalone server and Express middleware.
16 lines (15 loc) • 419 B
JavaScript
import fs from "node:fs";
import path from "node:path";
export function ensureDir(d) {
if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
}
export function record(cassetteDir, entry) {
try {
ensureDir(cassetteDir);
const p = path.join(
cassetteDir,
`${entry.endpoint.replace(/[\/:]/g, "_")}.jsonl`
);
fs.appendFileSync(p, JSON.stringify(entry) + "\n", "utf-8");
} catch {}
}