PHP code example of iazaran / ai-insights

1. Go to this page and download the library: Download iazaran/ai-insights library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iazaran / ai-insights example snippets


$businessType = 'Retail';
$goal = 'Increase sales';
$tables = ['orders', 'products'];
$limit = 3;
$insights = AIInsightsProcessor::analyze($businessType, $goal, $tables, $limit);

[
    'insights' => [
        [
            'index' => 0,
            'message' => [
                'role' => 'assistant',
                'content' => "Based on the provided data from the 'orders' and 'products' tables, here are some insights to improve your Retail business and increase sales:\n\n1. Focus on promoting high-margin products: The data shows that Product A has a higher profit margin compared to other products. Consider running targeted marketing campaigns for this item.\n2. Implement a loyalty program: Analyzing customer purchase history reveals repeat buyers. Introduce a loyalty program to incentivize these customers and encourage more frequent purchases.\n3. Optimize inventory management: The product data indicates some items have low stock levels. Ensure popular products are always available to avoid missing sales opportunities.\n4. Personalize marketing efforts: Use customer order history to create personalized product recommendations, potentially increasing cross-selling and upselling."
            ],
            'finish_reason' => 'stop',
        ],
    ],
    'charts' => [
        [
            'url' => 'https://oaidalleapiprodscus.blob.core.windows.net/private/org-123456/user-123456/img-abcdef.png'
        ],
    ]
]
bash
php artisan vendor:publish --provider="AIInsights\Providers\AIInsightsServiceProvider"