postare/filament-model-ai
Composer 安装命令:
composer require postare/filament-model-ai
包简介
Integrate artificial intelligence into FilamentPHP, leveraging your Eloquent Model data as knowledge.
README 文档
README
ModelAI is a plugin designed for FilamentPHP that interfaces with OpenAI APIs. Its primary function is to use existing model data as context to formulate requests to OpenAI APIs. In practice, it allows users to select specific records from a data model, such as a list of real estate properties or e-commerce products, and use this information as a basis for generating intelligent content or responses through OpenAI's AI capabilities.
Examples of Use
Example 1: Real Estate Portal
In a real estate portal, ModelAI can utilize data from a 'Properties' model to create tailored marketing content. For instance, by selecting a specific property, the plugin can generate optimized social media posts or identify key property-related points, all based on the specific property's data.
Example 2: Wine E-commerce
In a wine e-commerce platform, the plugin could be configured to work with a 'Wine' model, containing details like variety, vintage, and tasting notes. Using this data, 'ModelAI' could generate engaging product descriptions, gastronomic pairing recommendations, or even educational content about wine culture, all while harnessing OpenAI's artificial intelligence to ensure high-quality and relevant content.
Installation
You can easily install the package via Composer:
composer require postare/filament-model-ai
Once the package is installed, you need to add your OpenAI API Key to your .env file:
OPENAI_API_KEY=sk-...
To publish the configuration file, use the following command:
php artisan vendor:publish --tag="filament-model-ai-config"
Optionally, you can also publish the views:
php artisan vendor:publish --tag="filament-model-ai-views"
The published configuration file contains the following settings:
// Configuration for Postare/ModelAi return [ // OpenAI API Key 'openai_api_key' => env('OPENAI_API_KEY', ''), // Default OpenAI Model (refer to https://platform.openai.com/docs/models) 'default_openai_model' => 'gpt-3.5-turbo-1106', // Disable selecting OpenAI Model 'disable_openai_model_selection' => false, // Slug for the Model AI page 'slug' => 'model-ai', // Filament Navigation Group (refer to translation file for label or disable it) 'use_navigation_group' => true, // Model Settings 'eloquent_model' => \App\Models\User::class, // Laravel model to use 'selected_columns' => [ // Selected columns from the model 'name', 'email', ], 'field_label' => 'name', // Field to use as a label 'field_id' => 'id', // Field to use as an ID // System Prompt 'system_prompt' => 'You are a helpful assistant. Consider the data at the end of this message as context and answer the questions I will ask you later.', // Predefined Prompts (feel free to add, remove, or modify them) 'predefined_prompts' => [ [ 'name' => 'SEO', // Prompt name 'prompt' => 'Generate a title and an SEO-oriented meta description based on the provided data.', // Prompt instruction ], [ 'name' => 'Facebook Post', // Prompt name 'prompt' => 'Create a Facebook post, avoiding lists.', // Prompt instruction ], ], ];
Feel free to customize these settings to fit your specific use case. Enjoy using ModelAI with FilamentPHP!
Usage
In addition to a page in your Panel where you can select the desired element, the Model, and the Prompt, you can also use ModelAI elsewhere in your project.
$response = ModelAi::chat() // Optional: Override the default OpenAI model specified in the configuration file ->openai_model('gpt-4-1106-preview') // Optional ->system('your name is GeePeeTee, and you speak in a very 16th-century, very polished way.') // Optional, model to use: // params: model, id, selected_columns ->model(\App\Models\User::class, 1, ['name', 'email', 'email_verified_at']) // Mandatory, prompt to use: ->prompt("tell me about this user") // Mandatory, send the request ->send(); // Pray tell, thou hath sought to gain insight into the individual known by the appellation "Francesco". This gentle soul didst establish an entity of digital correspondence through "inerba@******.com", yet verily, the verification of such an electronic missive remains a quest unfulfilled. $response = ModelAi::chat() ->prompt("make up your own dad joke") ->send(); // Why don't skeletons fight each other? They don't have the guts.
Features
- OpenAI API Integration
- Customizable Models
- Customizable Prompts
- FilamentPHP Page
postare/filament-model-ai 适用场景与选型建议
postare/filament-model-ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 619 次下载、GitHub Stars 达 20, 最近一次更新时间为 2023 年 11 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「laravel」 「openai」 「filamentphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 postare/filament-model-ai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 postare/filament-model-ai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 postare/filament-model-ai 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
PHP 8.0+ OpenAI API client with fully typed/documented requests+responses models, guzzle and symfony/http-client support and async/parallel requests.
Estimate AI API costs before making expensive calls
A powerful package that seamlessly integrates OpenAI's advanced AI capabilities into your Laravel applications. This package offers quick setup and intuitive configuration to leverage AI models for chat, embeddings, and more.
Plugin for YOURLS. Default tools to use in some laemmi plugins
AI discussion summaries for Flarum with real-time streaming.
统计信息
- 总下载量: 619
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-25