naturalgroove/laravel-filament-image-generator-field 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

naturalgroove/laravel-filament-image-generator-field

Composer 安装命令:

composer require naturalgroove/laravel-filament-image-generator-field

包简介

A Laravel Filament plugin that generates images using AI directly in Admin Panel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This custom field allows you to generate images with different sizes and formats using AI models like OpenAI DALL-E. It extends the FileUpload field and adds a button to open the image generator modal where you can set the sizes and formats of the generated images.

filament image generator ai

Installation

Before you begin, you must have the Laravel Filament package installed and configured. If you haven't done this yet, you can find the installation instructions here.

Prerequisites

Default Image Generator is set to OpenAI DALL-E (version 3). You should have an API key to use it. You can get it here. After You get the API key, you should set it in your .env file:

OPEN_AI_DALL_E_API_KEY=your-api-key

Install the package via composer

Run the following command in your terminal to install the package:

composer require naturalGroove/laravel-filament-image-generator-field

You can publish the config file with:

php artisan vendor:publish --tag="filament-image-generator-field-config"

Configuration file lets you set the default image generator and the available image generators for the field.

Optionally, you can publish the views to customize the field:

php artisan vendor:publish --tag="filament-image-generator-field-views"

Usage

screenshot

Just add new Field or replace your FileUpload field with ImageGenerator field in your form schema definition:

use \NaturalGroove\Filament\ImageGeneratorField\Forms\Components\ImageGenerator;

[...]
public static function form(Form $form): Form
{
    return $form
        ->schema([
            ImageGenerator::make('photo'),
        ]);

If You are replacing the FileUpload field:

use \NaturalGroove\Filament\ImageGeneratorField\Forms\Components\ImageGenerator;

    [...]
-   FileUpload::make('photo'),
+   ImageGenerator::make('photo'),

You could use all the same options as FileUpload field, for example:

use \NaturalGroove\Filament\ImageGeneratorField\Forms\Components\ImageGenerator;

ImageGenerator::make('photo')
    ->imageEditor()
    ->disk('private'),

This plugin comes with a default image generator set to OpenAI DALL-E. You can select which version of the model you want to use when defining the field:

ImageGenerator::make('photo'
    ->imageGenerator('openai-dall-e-3'),

There are predefined shortcuts for the image generators:

ImageGenerator::make('photo')
    ->openaiDallE2(); // equivalent to ->imageGenerator('openai-dall-e-2')

ImageGenerator::make('photo')
    ->openaiDallE3(); // equivalent to ->imageGenerator('openai-dall-e-3')

Depending on the image generator you choose, there are different options you can set. For example Dall-E 2 allows to set the number of images generated.

After you add the field to your form, you should see a button next to the file input. When you click the button, the image generator modal will open.

screenshot

Adding custom image generators

You can add custom image generators by impolemeting the NaturalGroove\Filament\ImageGeneratorField\Contracts\AIImageGenerator interface. Your class should have the all the methods from the interface and should be registered in the config file. Format of returned array should be the same as in the example below:

use NaturalGroove\Filament\ImageGeneratorField\Contracts\AIImageGenerator;

class MyCustomImageGenerator implements AIImageGenerator
{
    public function generate(string $prompt, int $n = 1, array $params = []): array
    {
        // your implementation
        
        return [
            [
                'url' => 'https://example.com/image.jpg'
            ]
            [...]
        ];
    }

}

screenshot

Upcoming features

  • Add more image generators
  • Add functionality to edit your uploaded image with AI models (img2img)
  • Add more options to the field

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

naturalgroove/laravel-filament-image-generator-field 适用场景与选型建议

naturalgroove/laravel-filament-image-generator-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.48k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2024 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「laravel-filament」 「laravel-filament-cms」 「naturalGroove」 「laravel-filament-plugin」 「laravel-filament-image-generator-field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 naturalgroove/laravel-filament-image-generator-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 naturalgroove/laravel-filament-image-generator-field 我们能提供哪些服务?
定制开发 / 二次开发

基于 naturalgroove/laravel-filament-image-generator-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-03