Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jitone Ai Laravel Package

jiten14/jitone-ai

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Installation

    composer require jiten14/jitone-ai
    php artisan jitone-ai:install
    
    • This publishes config files for both jitone-ai and openai-php/laravel, and sets up storage symlinks.
  2. Configure API Key Add your OpenAI API key to .env:

    OPENAI_API_KEY=your_api_key_here
    
  3. Basic Integration In a Filament form, add the AI-powered field:

    use Jitone\AI\Facades\JitoneAI;
    
    JitoneAI::text('ai_generated_content')
        ->label('AI-Generated Content')
        ->required()
        ->rules(['required', 'string']);
    
  4. Trigger AI Generation Use the generate() method in your form's save() or a custom action:

    public function save(Form $form): void
    {
        $form->fill(JitoneAI::generate('ai_generated_content'));
        parent::save($form);
    }
    

First Use Case: AI-Powered Form Fields

Replace manual input with AI-generated suggestions for:

  • Product descriptions
  • Blog post drafts
  • Customer support responses
  • Dynamic form field values

Implementation Patterns

Workflows

  1. Dynamic Field Generation Use AI to auto-fill fields based on existing form data:

    JitoneAI::text('summary')
        ->generateFrom(['title', 'content'])
        ->label('Auto-Generated Summary');
    
  2. Conditional AI Triggers Only generate content when specific conditions are met:

    if ($form->get('is_premium')) {
        JitoneAI::generate('custom_message');
    }
    
  3. Bulk Processing Process multiple records with AI in a queue job:

    foreach ($records as $record) {
        dispatch(new GenerateAiContent($record));
    }
    

Integration Tips

  • Filament Resource Integration Extend Filament\Resources\Resource to include AI fields in both create/update forms:

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                JitoneAI::text('ai_field')->generate(),
                // ... other fields
            ]);
    }
    
  • Custom Prompts Override default prompts via config:

    'prompts' => [
        'default' => 'Write a {field_name} for {context}',
    ],
    
  • Fallback Logic Handle API failures gracefully:

    try {
        $aiResponse = JitoneAI::generate('field_name');
    } catch (\Exception $e) {
        $aiResponse = 'Default fallback content';
    }
    
  • Caching Responses Cache AI-generated content to reduce API calls:

    JitoneAI::text('cached_field')->cacheFor(seconds: 3600);
    

Gotchas and Tips

Pitfalls

  1. API Rate Limits

    • Monitor OpenAI token usage to avoid hitting limits.
    • Implement retry logic with exponential backoff for failed requests.
  2. Cost Management

    • AI generation costs money; log usage to track expenses:
      JitoneAI::logUsage('field_name', $response);
      
  3. Field Validation

    • AI responses may violate form rules. Validate before saving:
      if (!JitoneAI::validate('field_name')) {
          $form->addError('field_name', 'AI-generated content failed validation');
      }
      
  4. Configuration Overrides

    • Ensure config files are published and merged correctly:
      php artisan vendor:publish --tag=jitone-ai-config
      

Debugging

  • Enable Debugging Set JITONE_AI_DEBUG=true in .env to log API requests/responses.

  • Common Errors

    • Invalid API Key: Verify .env and OpenAI account.
    • Rate Limit Exceeded: Check usage at OpenAI Dashboard.
    • Field Not Found: Ensure field names match exactly in generate() calls.

Extension Points

  1. Custom AI Providers Extend the package to support other AI services (e.g., Anthropic, Mistral):

    JitoneAI::extend('anthropic', function () {
        return new AnthropicService();
    });
    
  2. Hooks for Post-Generation Add callbacks after AI generation:

    JitoneAI::text('field_name')->afterGenerate(function ($response) {
        // Modify or log the response
    });
    
  3. Local Testing Use mock responses for local development:

    JitoneAI::mockResponses([
        'field_name' => 'Mocked AI response',
    ]);
    

Pro Tips

  • Prompt Engineering Fine-tune prompts for better results:

    JitoneAI::text('description')
        ->generateWithPrompt('Write a {field_name} for a {product_type} targeting {audience}.');
    
  • Performance Use generateInBackground() for non-critical fields to avoid blocking the UI.

  • User Feedback Allow users to edit AI-generated content and log improvements to refine prompts over time.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle