AI-powered predictive text input for Vue 3 - Learns writing patterns, suggests complete sentences with context-aware predictions and multi-language support
npm install @aivue/predictive-inputTransform your text inputs with intelligent, AI-powered predictions. Get smart text completions and suggestions powered by your AI provider.



---
---
``bash`
npm install @aivue/predictive-input
---
`vue
:client="aiClient"
placeholder="Start typing..."
@prediction-selected="handlePrediction"
/>
`
---
Main input component with AI-powered predictions.
#### Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| modelValue | string | '' | Input value (v-model) |placeholder
| | string | 'Start typing...' | Placeholder text |disabled
| | boolean | false | Disable input |multiline
| | boolean | false | Use textarea instead of input |rows
| | number | 3 | Rows for textarea |type
| | string | 'text' | Input type |maxPredictions
| | number | 5 | Maximum predictions to show |minConfidence
| | number | 0.1 | Minimum confidence threshold |suggestionsPosition
| | 'above' \| 'below' | 'below' | Position of suggestions |enableTraining
| | boolean | true | Auto-train on input |storageKey
| | string | 'aivue_predictive_input' | LocalStorage key |
#### Events
| Event | Payload | Description |
|-------|---------|-------------|
| update:modelValue | string | Emitted when value changes |prediction-accepted
| | Prediction | Emitted when prediction is accepted |training-complete
| | - | Emitted when training completes |
#### Keyboard Shortcuts
- ↑/↓ - Navigate predictions
- Tab/Enter - Accept selected prediction
- Esc - Close suggestions
Panel for training the AI model with custom text.
#### Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| storageKey | string | 'aivue_predictive_input' | LocalStorage key |
#### Events
| Event | Description |
|-------|-------------|
| training-complete | Emitted when training completes |data-cleared
| | Emitted when data is cleared |data-imported
| | Emitted when data is imported |
---
`typescript
import { usePredictiveInput } from '@aivue/predictive-input';
const {
predictions,
isTraining,
isTrained,
train,
getPredictions,
updatePredictions,
clearData,
exportData,
importData,
getStats
} = usePredictiveInput({
storageKey: 'my_app_predictions',
autoSave: true,
enableOffline: true,
defaultLanguage: 'en'
});
`
---
`typescript
import { usePredictiveInput } from '@aivue/predictive-input';
const { train, isTrained } = usePredictiveInput();
// Train with custom text
const trainingText =
Your writing samples here...
Emails, documents, notes, etc.;
await train(trainingText);
console.log('Training complete:', isTrained.value);
`
`typescript
const { getPredictions } = usePredictiveInput();
const context = {
previousText: 'Hello, how are',
currentWord: 'you',
cursorPosition: 15,
timestamp: Date.now()
};
const predictions = getPredictions(context);
predictions.forEach(pred => {
console.log(pred.text, pred.confidence);
});
`
`typescript
const { exportData, importData, clearData } = usePredictiveInput();
// Export training data
await exportData('my-predictions.json');
// Import from file
const file = event.target.files[0];
await importData(file);
// Clear all data
await clearData();
``
---
---
| Feature | @aivue/predictive-input | Traditional Autocomplete |
|---------|------------------------|-------------------------|
| Learning | ✅ Learns your style | ❌ Static dictionary |
| Context | ✅ Context-aware | ❌ Word-based only |
| Sentences | ✅ Full sentences | ❌ Single words |
| Privacy | ✅ 100% local | ⚠️ Often server-based |
| Offline | ✅ Works offline | ❌ Needs connection |
| Languages | ✅ 6 languages | ⚠️ Limited |
---
---
Contributions are welcome! Please feel free to submit a Pull Request.
---
Explore the complete @aivue ecosystem:
---
MIT © reachbrt
---
- GitHub Repository
- npm Package
- Demo
- Report Issues
---
Built with ❤️ using:
- Vue 3
- TypeScript
- Natural (NLP library)
- Compromise (NLP library)
---
Made with 🧠 by the @aivue team