iazaran/ai-insights
最新稳定版本:v1.2.0
Composer 安装命令:
composer require iazaran/ai-insights
包简介
Using AI to analyze data and receive insights to improve specific areas of your business
README 文档
README
Using AI LLMs to analyze data and receive insights and charts to improve specific areas of your business. The default LLM is OpenAI, but you can use any other LLMs.
Requirements
- PHP >=8.1
- Laravel >= 10
Get Started
Install iazaran/ai-insights via the Composer package manager:
composer require iazaran/ai-insights
Optionally, publish the configuration file
php artisan vendor:publish --provider="AIInsights\Providers\AIInsightsServiceProvider"
Set .env configuration. You can get your OpenAI API key here. Others are optional.
AI_BASE_URL="" AI_CHAT_PATH="" AI_IMAGE_PATH="" AI_API_KEY="" AI_ORGANIZATION="" AI_PROJECT="" AI_MODEL="" AI_IMAGE_MODEL="" AI_MAX_TOKENS="" AI_TEMPERATURE="" AI_INSIGHTS_DEFAULT_GOAL="" AI_IMAGE_SIZE=""
Use the AIInsightsProcessor class to analyze your data. As default, it will use your last rows in DB
$businessType = 'Retail'; $goal = 'Increase sales'; $tables = ['orders', 'products']; $limit = 5; $insights = AIInsightsProcessor::analyze($businessType, $goal, $tables, $limit);
And sample response can be like this, if you are using OpenAI:
[
'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'
],
]
]
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-28