update 添加保存

This commit is contained in:
2026-01-07 17:34:10 +08:00
commit 7cca41b457
15 changed files with 6411 additions and 0 deletions

14
prompts/src/index.ts Normal file
View File

@@ -0,0 +1,14 @@
import { PromptGenerator, type PromptGeneratorOptions } from "./prompt-geneator.ts";
import { writeFile } from "node:fs/promises";
import { Prompt } from "./prompt-perfect.ts";
import { customAlphabet } from "nanoid";
const letter = 'abcdefghijklmnopqrstuvwxyz'
const randomString = customAlphabet(letter, 16);
async function saveToFile(data: Map<string, string>, outputPath: string): Promise<void> {
const arrayData = Array.from(data.entries()).map(([key, value]) => ({ key, value, id: randomString() }));
await writeFile(outputPath, JSON.stringify(arrayData, null, 2), "utf-8");
console.log(`Generated ${arrayData.length} prompts and saved to ${outputPath}`);
}
export { PromptGenerator, PromptGeneratorOptions, saveToFile, Prompt };