未来全栈 250d46b652 feat: full consult workflow 5 дней назад
..
README.md 250d46b652 feat: full consult workflow 5 дней назад
task-completion-text.ts 250d46b652 feat: full consult workflow 5 дней назад

README.md

使用示例

// 1. Initialize the task with required parameters
const textGenerator = new TaskCompletionText({
    promptTemplate: "Write a product description for {{productName}} that highlights these features: {{features}}. Target audience: {{audience}}.",
    outputProperty: "productDescription", // Where to store the result
    inputVariables: ["productName", "features", "audience"], // Explicitly declare required variables
    modelOptions: {
        temperature: 0.7,
        maxTokens: 500
    },
    strictValidation: true // Fail if variables are missing
});

// 2. Prepare input data (variables referenced in the prompt)
textGenerator.updateData('productName', 'Smart Coffee Maker');
textGenerator.updateData('features', [
    'Voice control',
    'Custom brew strength',
    'Scheduled brewing'
].join(', '));
textGenerator.updateData('audience', 'tech-savvy home users');

// 3. Execute the task
try {
    await textGenerator.handle();
    
    // 4. Get the generated text from the specified property
    const generatedText = textGenerator.getData('productDescription');
    console.log('Generated Description:', generatedText);
    
    // Example output might be:
    // "Introducing our Smart Coffee Maker, perfect for tech-savvy home users..."
} catch (error) {
    console.error('Generation failed:', error);
    const errorDetails = textGenerator.getData('error');
    // Handle error...
}

// 5. Clean up when done
textGenerator.onDestroy();