Enforces precise prompt generation count

Trims generated prompts to requested count

Ensures consistent user experience by slicing array if model over-generates
Prevents potential cache key mismatches due to inconsistent prompt counts
This commit is contained in:
AlexKucera committed 2025-10-24 13:41:44 +02:00
1 parent b76f085137
commit 61788b39ad
1 file changed
+7 -1
+7 -1
View File
@@ -155,7 +155,13 @@ export class PromptGeneratorService {
try {
new Notice('Generating prompts...');
const prompts = await this.client.generatePrompts(count, model, systemPrompt, examplePrompt, type);
let prompts = await this.client.generatePrompts(count, model, systemPrompt, examplePrompt, type);
// Enforce requested count - models can occasionally over-generate
// This ensures deterministic UX and correct cache key matching
if (prompts.length > count) {
prompts = prompts.slice(0, count);
}
const generatedPrompts: GeneratedPrompt[] = prompts.map(text => ({
text,