Author Aide API Methods
generate()
Programmatically triggers the generation functionality, performing the same validation and logic as clicking the generate button in the UI.
You would want to use this method so that you can trigger question generation from your own custom interface or automation scripts, for example.
Important Before calling this method, ensure the Author Aide application is properly initialized, required form fields are filled, and the user has sufficient credits for generation.
Examples
// Basic usage - trigger generation
const success = authorAideApp.generate();
if (success) {
console.log('Generation started successfully');
} else {
console.log('Generation failed - check form validation or credits');
}
// Example: Generate question after setting up form data
function generateQuestion(questionType) {
// Navigate to the appropriate page first
authorAideApp.navigate(`/${questionType}`); // e.g., '/mcq', '/true-false'
// Set up form data first (fill required fields in the UI)
// You might need to wait for navigation and form to be ready
// Trigger generation
const result = authorAideApp.generate();
if (result) {
console.log('Question generation started for type:', questionType);
return true;
} else {
console.error('Failed to generate question - check validation and credits');
return false;
}
}
// Debugging failed generation
const result = authorAideApp.generate();
if (!result) {
console.log('Generation failed - check:');
console.log('1. Are you on a generation page? (/mcq, /true-false, etc.)');
console.log('2. Have you filled the required topic/question field?');
console.log('3. Do you have sufficient credits?');
}
Arguments
None.
Return value
Type boolean
Returns true if generation was successfully initiated.
Returns false if generation failed due to validation errors, insufficient credits, network errors, or invalid application state.
Note The method is synchronous and returns immediately. No events are emitted - just a clean boolean result.
Caveats
The method will return false if form validation fails, the user has insufficient credits, network errors occur, or the application is not in a valid state for generation.
It's safe to call multiple times, but subsequent calls will be ignored if generation is already in progress.