seogeneratorserver/tests/_helpers/mockLLMManager.js
StillHammer dbf1a3de8c Add technical plan for multi-format export system
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>
2025-11-18 16:14:29 +08:00

25 lines
887 B
JavaScript

/**
* Mock LLMManager : renvoie des sorties déterministes selon l'input,
* et peut simuler des erreurs transitoires (429/500) via flags.
*/
export class MockLLMManager {
constructor({failTimes=0, failCode=429} = {}) {
this.failTimes = failTimes;
this.failCode = failCode;
this.calls = [];
}
async callModel({provider='mock', model='mock-1', input}) {
this.calls.push({provider, model, input});
if (this.failTimes > 0) {
this.failTimes--;
const err = new Error(`Mock transient ${this.failCode}`);
err.statusCode = this.failCode;
throw err;
}
// sortie déterministe simple
const text = (typeof input === 'string' ? input : JSON.stringify(input));
const completion = `MOCK[${model}]::` + text.slice(0, 60);
return { completion, usage: { prompt_tokens: 100, completion_tokens: 200 } };
}
}