Added plan.md with complete architecture for format-agnostic content generation: - Support for Markdown, HTML, Plain Text, JSON formats - New FormatExporter module with neutral data structure - Integration strategy with existing ContentAssembly and ArticleStorage - Bonus features: SEO metadata generation, readability scoring, WordPress Gutenberg format - Implementation roadmap with 4 phases (6h total estimated) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
998 B
JavaScript
27 lines
998 B
JavaScript
export class FakeLLMClient {
|
|
constructor(opts = {}) {
|
|
this.delayMs = opts.delayMs ?? 10;
|
|
this.plan = opts.plan ?? []; // suite d'événements: 'ok' | {err:{statusCode:429|500|...}} | fn
|
|
this.calls = [];
|
|
this._i = 0;
|
|
this.defaultUsage = { prompt_tokens: 100, completion_tokens: 150 };
|
|
this.prefix = opts.prefix ?? 'FAKE';
|
|
}
|
|
async invoke(input, { model='fake-1' } = {}) {
|
|
this.calls.push({ input, model, t: Date.now() });
|
|
await new Promise(r => setTimeout(r, this.delayMs));
|
|
const step = this.plan[this._i++] ?? 'ok';
|
|
if (typeof step === 'function') return step(input, {model});
|
|
if (step?.err) {
|
|
const e = new Error(`fake error ${step.err.statusCode}`);
|
|
e.statusCode = step.err.statusCode;
|
|
throw e;
|
|
}
|
|
const text = typeof input === 'string' ? input : JSON.stringify(input);
|
|
return {
|
|
completion: `${this.prefix}[${model}]::` + text.slice(0, 80),
|
|
usage: this.defaultUsage
|
|
};
|
|
}
|
|
}
|