AI Suggestion Rules Configuration

The AI Suggestion extension must be configured with a list of rules to help the LLM analyze the editor's content and generate suggestions.

AiSuggestion.configure({
  rules: [
    {
      id: '1',
      prompt: 'Identify and correct any spelling mistakes',
    },
  ],
})

Each suggestion is associated with a rule. If no rules are provided, the AI Suggestion extension will not generate any suggestions.

Persistent Rules

If you want rules to persist across sessions, you should store them in your own database.

Changing Rules After Editor Load

You can change the rules at any time without having to reload the editor. Use the setAiSuggestionRules command to update the rules.

const newRules = [
  {
    id: '2',
    prompt: 'Identify and correct any grammar mistakes',
  },
]

editor.commands.setAiSuggestionRules(newRules)

Warning: the setAiSuggestionRules command will not automatically reload the suggestions. You need to call the loadAiSuggestions command to update the suggestions based on the new rules. A common pattern is to chain the two commands together.

editor.chain().setAiSuggestionRules(newRules).loadAiSuggestions().run()