
# 使用示例
```ts
// 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();
```