@tpmjs/tools-recipe-generate-from-grammar
Generate recipes following a grammar/template with rules. Useful for creating structured workflows or recipes from a formal grammar definition. Supports optional seeding for deterministic generation.
Grammar must have a "start" rule name
Last checked: 1/1/2026, 8:18:51 AM
Test @tpmjs/tools-recipe-generate-from-grammar (recipeGenerateFromGrammarTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-recipe-generate-from-grammarpnpm add @tpmjs/tools-recipe-generate-from-grammaryarn add @tpmjs/tools-recipe-generate-from-grammarbun add @tpmjs/tools-recipe-generate-from-grammardeno add npm:@tpmjs/tools-recipe-generate-from-grammarimport { recipeGenerateFromGrammarTool } from '@tpmjs/tools-recipe-generate-from-grammar';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { recipeGenerateFromGrammarTool } from '@tpmjs/tools-recipe-generate-from-grammar';
const result = await generateText({
model: openai('gpt-4o'),
tools: { recipeGenerateFromGrammarTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
grammarobjectGrammar definition with "start" rule name and "rules" object mapping rule names to values (strings, arrays of alternatives, or nested objects)
seedstringOptional seed string for deterministic generation
Schema extracted: 1/1/2026, 8:18:51 AM
Generate recipes following a grammar/template system with rules and optional seeding for deterministic generation.
npm install @tpmjs/tools-recipe-generate-from-grammar
import { recipeGenerateFromGrammarTool } from '@tpmjs/tools-recipe-generate-from-grammar'; const result = await recipeGenerateFromGrammarTool.execute({ grammar: { start: 'workflow', rules: { workflow: { steps: ['analyze', 'process', 'output'] }, analyze: ['parse data', 'validate input'], process: ['transform data', 'apply rules'], output: ['generate report', 'save results'] } }, seed: 'deterministic-seed' // Optional }); console.log(result.recipe); // { // name: 'workflow', // steps: [ // { action: 'analyze', details: 'parse data', order: 0 }, // { action: 'process', details: 'transform data', order: 1 }, // { action: 'output', details: 'generate report', order: 2 } // ], // metadata: { generatedAt: '2025-01-01T00:00:00.000Z', grammarHash: 'abc123...' } // }
The grammar is a structured object with:
start: Name of the starting rulerules: Object mapping rule names to definitionsRule definitions can be:
const result = await recipeGenerateFromGrammarTool.execute({ grammar: { start: 'recipe', rules: { recipe: { steps: [ { action: 'prepare', details: 'gather ingredients' }, { action: 'cook', details: 'apply heat' }, { action: 'serve', details: 'plate and garnish' } ] } } } });
const result = await recipeGenerateFromGrammarTool.execute({ grammar: { start: 'deployment', rules: { deployment: { steps: ['build', 'test', 'deploy'] }, build: ['npm build', 'docker build'], test: ['unit tests', 'integration tests', 'e2e tests'], deploy: ['deploy to staging', 'deploy to production'] } }, seed: 'build-123' // Same seed = same output });
MIT
Downloads/month
0
Quality Score