Download the PHP package iamgerwin/nova-ai-context-aware-input without Composer
On this page you can find all versions of the php package iamgerwin/nova-ai-context-aware-input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iamgerwin/nova-ai-context-aware-input
More information about iamgerwin/nova-ai-context-aware-input
Files in iamgerwin/nova-ai-context-aware-input
Package nova-ai-context-aware-input
Short Description AI-assisted Nova field that seamlessly improves text with context, while respecting typical Nova workflows
License MIT
Homepage https://github.com/iamgerwin/nova-ai-context-aware-input
Informations about the package nova-ai-context-aware-input
Nova AI Context-Aware Input
A Laravel Nova field that brings the power of AI to your admin panel, enhancing text input with intelligent, context-aware suggestions. Seamlessly integrates with Nova's workflow while providing real-time text improvements powered by leading AI providers.
Think of it as having a professional editor looking over your shoulder, understanding the context of your entire form, and offering thoughtful improvements—without disrupting your natural writing flow.
Features
Core Capabilities
- Multiple AI Providers: OpenAI, Anthropic Claude, DeepSeek, and Azure OpenAI support
- Context-Aware Intelligence: Leverages form data, user information, and resource context for relevant suggestions
- Real-Time Suggestions: Choose from blur, idle, or manual trigger modes
- Visual Diff Mode: See exactly what changed with highlighted additions and deletions
- Suggestion History: Navigate through previous AI suggestions with undo/redo support
- Flexible Styling: Six built-in writing styles (professional, formal, friendly, succinct, marketing, technical)
Performance & Security
- Intelligent Caching: Reduces API costs by caching similar improvements
- Rate Limiting: Configurable per-user or global rate limits
- PII Detection: Built-in detection to prevent sensitive data from being sent to AI providers
- Input Validation: Maximum length enforcement and content filtering
- Fallback Support: Automatic failover to backup providers
Developer Experience
- Zero Configuration: Works out of the box with sensible defaults
- Highly Customizable: Fine-tune every aspect through configuration or field methods
- Event System: Hook into
TextImprovedandSuggestionDiscardedevents - Comprehensive Logging: Track usage, errors, and performance metrics
- Type-Safe: Full PHP 8.2+ type declarations
Requirements
- PHP 8.2+ or 8.3+
- Laravel 10.x, 11.x, or 12.x
- Laravel Nova 4.x or 5.x
- At least one AI provider API key (OpenAI, Anthropic, DeepSeek, or Azure OpenAI)
Installation
Install the package via Composer:
Publish the configuration file:
Build the Nova assets:
Or if you prefer using the root directory:
Quick Start
1. Configure Your AI Provider
Add your API key to your .env file:
2. Use the Field in Your Nova Resource
Replace the standard Textarea field with TextImprove:
That's it! Your field now has AI-powered text improvement capabilities.
Configuration
The package comes with extensive configuration options. Here are the key settings:
Default Provider
Field Defaults
Rate Limiting
Format: scope:max_attempts,decay_minutes
user:10,1- 10 attempts per user per minuteglobal:100,60- 100 attempts globally per hour
Caching
Security
Usage Examples
Basic Usage
Advanced Configuration
Custom Styling
Available styles:
professional- Professional and clear business writingformal- Formal and academic tonefriendly- Warm and approachable tonesuccinct- Brief and to the pointmarketing- Persuasive marketing copytechnical- Technical and precise language
Context-Aware Improvements
Leverage contextual information for smarter suggestions:
Available Providers
OpenAI
Environment variables:
Anthropic Claude
Environment variables:
DeepSeek
Environment variables:
Azure OpenAI
Environment variables:
Context Providers
Context providers enrich AI suggestions by providing relevant information about the form, user, and resource being edited.
Sibling Fields Provider
Includes data from other fields in the form:
This helps the AI understand the broader context. For example, when improving a product description, it knows the product's title and category.
User Persona Provider
Includes information about the authenticated user:
Helps tailor suggestions to the user's context and language.
Resource Snapshot Provider
Provides context about the resource being edited:
Policy Hints Provider
Enforces content policies and guidelines:
You can also add custom hints per field:
Disabling Context Providers
Security Features
PII Detection
The package automatically detects and warns about potential PII (Personally Identifiable Information) before sending data to AI providers:
- Email addresses
- Phone numbers
- Credit card numbers
- Custom patterns (configurable)
When PII is detected, the request is blocked and an error is returned.
Input Validation
- Maximum input length enforcement (default: 5000 characters)
- Content sanitization
- API key validation
Rate Limiting
Prevent abuse with configurable rate limits:
Caching
Reduce costs and improve performance by caching improvements:
Events
The package dispatches events you can listen to:
TextImproved Event
Fired when text is successfully improved:
SuggestionDiscarded Event
Fired when a user discards an AI suggestion:
Customizing Prompts
You can customize the system and user prompts sent to AI providers:
Available placeholders:
{{ user_input }}- The text to improve{{ context }}- Contextual information from providers{{ style }}- The selected writing style{{ language }}- User's language/locale
Testing
Run the test suite:
Run tests with coverage:
Run static analysis:
Format code (PSR-12):
Performance Tips
- Enable caching to reduce API calls for similar content
- Use rate limiting to control costs
- Choose appropriate models: Smaller models (gpt-4o-mini, claude-3-haiku) for simple improvements, larger models for complex content
- Set reasonable
minLengthto avoid processing very short inputs - Use
trigger='manual'for fields where AI assistance is optional
Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development Setup
- Clone the repository
- Install dependencies:
composer install && npm install - Copy
.env.exampleto.envand add your API keys - Run tests:
composer test
Changelog
Please see CHANGELOG.md for recent changes.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see LICENSE.md for more information.
Credits
- Gerwin - Creator and maintainer
- Built with Laravel Nova
- Powered by leading AI providers: OpenAI, Anthropic, DeepSeek
Acknowledgments
Special thanks to the Laravel and Nova communities for their excellent frameworks and tools that made this package possible.
Made with care for the Laravel community.
All versions of nova-ai-context-aware-input with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0|^11.0|^12.0
guzzlehttp/guzzle Version ^7.8
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0
laravel/nova Version ^4.0|^5.0