- How do I integrate broqit/fields-ai into an existing Laravel project with Nova?
- Install via Composer (`composer require broqit/fields-ai`), then register the service provider in `config/app.php`. For Nova, extend your resources with the AI-powered fields using the package’s field definitions. The package provides configurable prompts for Nova fields, so you can customize AI behavior per resource.
- Which Laravel versions are supported, and will it work with Laravel 11?
- The package targets modern Laravel versions (likely 9.x–11.x), but verify compatibility with your version. Since the last release date is unclear, check the package’s changelog or contact the maintainer for Laravel 11 support. Always test in a staging environment before upgrading.
- Can I use broqit/fields-ai for non-Nova forms (e.g., Blade templates or API requests)?
- Yes, the package is designed for broader use. For Blade, use the provided directives (e.g., `@fieldsAi`) to generate or enrich form fields dynamically. For APIs, leverage the service container to inject AI utilities into controllers or request handlers, ensuring consistent behavior across your application.
- What AI providers does broqit/fields-ai support, and how do I switch between them?
- The package likely defaults to a popular provider (e.g., OpenAI) but should allow configuration via environment variables or a config file. Check the documentation for `AI_PROVIDER` or similar settings. You may need to implement adapters for custom LLMs if the default provider doesn’t meet your needs.
- How does broqit/fields-ai handle API rate limits or AI response failures?
- The package should include fallback mechanisms, such as retry logic or cached responses for repeated requests. Configure timeouts and retry attempts in the AI service settings. For critical paths, consider implementing manual overrides or default values when AI generation fails.
- Are there security risks when using AI to generate database fields or schema definitions?
- Yes, dynamically generated fields could expose SQL injection risks if not sanitized. The package should validate and escape outputs, but always review generated queries or schema changes. Use transactions for database modifications and avoid passing raw user input to AI prompts.
- Can I customize AI prompts for specific models or fields (e.g., User vs. Product)?
- The package supports extensible field definitions, allowing you to tailor prompts per model or field type. Override defaults in your config or via service provider bindings. For example, define a `ProductDescription` field with a specialized prompt template for better context.
- How do I test broqit/fields-ai in my CI pipeline, especially for AI-dependent logic?
- Mock the AI service in your tests using Laravel’s mocking tools (e.g., `Mockery` or PHPUnit). Stub responses for predictable outputs and test edge cases like malformed AI replies. For integration tests, use a local or sandboxed AI endpoint to avoid rate limits or cost issues.
- What alternatives exist for AI-powered form fields in Laravel if this package lacks features?
- Consider Laravel Nova’s built-in AI tools (if available), third-party packages like `spatie/laravel-ai`, or custom solutions using OpenAI’s API directly. For Filament, explore plugins like `filament-spatie/laravel-filament-ai`. Evaluate alternatives based on your need for Nova integration, cost, and maintenance.
- How do I handle production costs for high-volume AI field generation?
- Monitor API usage and implement caching for repeated generations (e.g., store generated fields in Redis). Use batch processing for bulk operations and set budget alerts. The package may offer config options to limit generation frequency or prioritize critical fields to reduce costs.