kaviyarasu/ai-agent
Composer 安装命令:
composer require kaviyarasu/ai-agent
包简介
A Laravel package for AI agent with multi-provider support
README 文档
README
A flexible, modular AI service architecture for Laravel that supports multiple AI providers with easy switching via configuration. Built with SOLID principles and designed for enterprise-grade applications.
Core Features
- 🤖 Multi-Provider Support: Claude, OpenAI, Ideogram, and more
- 🔄 Runtime Provider Switching: Switch providers dynamically based on requirements
- 📝 Text Generation: Support for multiple text models with customizable parameters
- 🎨 Image Generation: Create images with DALL-E, Ideogram, or other providers
- 🎬 Video Generation: Future-ready video generation support
- 🏗️ SOLID Architecture: Clean, maintainable code following SOLID principles
- 🔧 Modular Design: Easy to extend with new providers or capabilities
- 🛠️ Artisan Commands: Scaffolding commands for rapid development
📋 Requirements
- PHP 8.1 or higher
- Laravel 10.0 or Higher
- Composer
Installation
composer require kaviyarasu/ai-agent
2. Publish and Run Migrations
# Quick install (publishes config and runs migrations) php artisan ai-agent:install # Or manually php artisan vendor:publish --tag="ai-agent-migrations" php artisan migrate php artisan vendor:publish --tag="ai-agent-config"
Configuration
1. Set Up Environment Variables
Add your API keys to your .env file:
CLAUDE_API_KEY=your-claude-api-key OPENAI_API_KEY=your-openai-api-key IDEOGRAM_API_KEY=your-ideogram-api-key
Artisan Commands
Basic Agent Creation
# Create a agent with text or image or video capability
php artisan ai-agent
📚 Detailed Usage Guide
Provider Management
Available Providers
| Provider | Text | Image | Video | Status |
|---|---|---|---|---|
| Claude | ✅ | ❌ | ❌ | Stable |
| OpenAI | ✅ | ✅ | ❌ | Stable |
| Gemini | ✅ | ✅ | ❌ | Stable |
| Ideogram | ❌ | ✅ | ❌ | Stable |
| Runware | ❌ | ✅ | ❌ | Stable |
Basic Usage
use Kaviyarasu\AIAgent\Facades\AIAgent; // Text generation $response = AIAgent::text()->generateText('Write a story about a robot'); // Stream text generation foreach (AIAgent::text()->streamText('Explain the theory of relativity') as $chunk) { echo $chunk; } // Image generation $response = AIAgent::image()->generateImage('A futuristic city at sunset'); // Switch provider at runtime $response = AIAgent::provider('openai')->text()->generateText('Hello world');
Advanced Usage
use Kaviyarasu\AIAgent\Facades\AIAgent; // Use specific model with custom parameters $response = AIAgent::provider('claude') ->text() ->switchModel('claude-3-opus-20240229') ->generateText('Explain quantum computing', [ 'max_tokens' => 1000, 'temperature' => 0.7, 'top_p' => 0.9 ]); // Generate image with specific dimensions $response = AIAgent::provider('openai') ->image() ->switchModel('dall-e-3') ->generateImage('A serene landscape with mountains', [ 'size' => '1024x1024', 'quality' => 'hd', 'style' => 'vivid' ]); // Generate multiple images $response = AIAgent::provider('openai') ->image() ->generateMultipleImages('A serene landscape with mountains', 3);
Quick Start
use Kaviyarasu\Agent\Facades\Agent; // Generate text $response = Agent::generateText('Write a haiku about Laravel'); // Create an image $response = Agent::provider('openai')->generateImage('A coding workspace'); // Switch providers dynamically $result = Agent::provider('claude')->generateText('Explain quantum computing');
📚 Documentation
🆘 Support
- Issues: GitHub Issues
📄 License
This package is licensed under the MIT License. See the LICENSE file for details.
Built with ❤️ for the Laravel community
kaviyarasu/ai-agent 适用场景与选型建议
kaviyarasu/ai-agent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 07 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Agent」 「ai」 「openai」 「claude」 「ai-agent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kaviyarasu/ai-agent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kaviyarasu/ai-agent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kaviyarasu/ai-agent 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP 8.0+ OpenAI API client with fully typed/documented requests+responses models, guzzle and symfony/http-client support and async/parallel requests.
Custom laravel monolog logger for datadog logs management, both api and agent ways
Estimate AI API costs before making expensive calls
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
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.
Standalone replacement for php's native get_browser() function
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-02