mappweb/laravel-neuron-ai
Composer 安装命令:
composer require mappweb/laravel-neuron-ai
包简介
Laravel wrapper for neuron-ai - AI Agent framework integration for Laravel applications
README 文档
README
A Laravel wrapper for neuron-ai that facilitates the integration of the AI agents framework into Laravel applications.
Official Documentation
Guides and Tutorials
Check out the technical guides and tutorials file to learn how to create your artificial intelligence agents with Neuron. https://docs.neuron-ai.dev/resources/guides-and-tutorials.
Features
- 🚀 Easy installation - Automatic configuration with auto-discovery
- 🎨 Artisan commands - Generate AI agent classes with
make:agentand prompt classes withmake:prompt - ⚙️ Flexible configuration - Support for multiple AI providers
- 🔧 Facade included - Simple access through
NeuronAI:: - 📝 Flexible prompts - Create custom prompt classes with any structure you need
- 🧪 Tests included - Complete test suite
- 📚 Complete documentation - Detailed examples and guides
Supported AI Providers
- OpenAI (GPT-4, GPT-3.5-turbo)
- Anthropic (Claude 3)
- Google Gemini
- Ollama (Local models)
Installation
Via Composer
composer require mappweb/laravel-neuron-ai
Publish Configuration
# Publish configuration file php artisan vendor:publish --provider="Mappweb\LaravelNeuronAi\NeuronServiceProvider" --tag="neuron-ai-config" # Publish stubs for customization php artisan vendor:publish --provider="Mappweb\LaravelNeuronAi\NeuronServiceProvider" --tag="neuron-ai-stubs" # Publish all files php artisan vendor:publish --provider="Mappweb\LaravelNeuronAi\NeuronServiceProvider" --tag="neuron-ai"
Configuration
Add the following variables to your .env file:
# General configuration NEURON_AI_DEFAULT_PROVIDER=openai # OpenAI OPENAI_API_KEY=your-openai-api-key OPENAI_MODEL=gpt-4 # Anthropic ANTHROPIC_API_KEY=your-anthropic-api-key ANTHROPIC_MODEL=claude-3-sonnet-20240229 # Gemini GEMINI_API_KEY=your-gemini-api-key # Ollama (for local models) OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=llama2
Usage
Generate Agents with Artisan
# Basic agent php artisan make:agent ChatAgent # Agent with specific provider php artisan make:agent ChatAgent --provider=openai # Agent with custom instructions php artisan make:agent ChatAgent --instructions="You are a helpful customer support agent" # Agent with tools php artisan make:agent ChatAgent --tools="WebSearch,EmailSender" # Complete agent php artisan make:agent CustomerSupportAgent \ --provider=anthropic \ --instructions="You are a customer support agent" \ --tools="WebSearch,DatabaseQuery"
Generate Prompts with Artisan
# Basic prompt php artisan make:prompt ChatPrompt # Complete prompt php artisan make:prompt GreetingPrompt --content="Hello! I'm {$this->name}, your assistant." # Prompt with custom path php artisan make:prompt CustomPrompt --path="Custom\\Prompts"
Generated Agent Example
<?php declare(strict_types=1); namespace App\Agents; use NeuronAI\Agent; use NeuronAI\Providers\AIProviderInterface; use NeuronAI\Providers\OpenAIProvider; class ChatAgent extends Agent { public function provider(): AIProviderInterface { return OpenAIProvider::make(); } public function instructions(): string { return 'You are a helpful AI assistant.'; } }
Generated Trascribe Agent Example
<?php declare(strict_types=1); namespace App\Agents; use NeuronAI\Agent; use Mappweb\LaravelNeuronAi\Providers\OpenAI\OpenAITranscribeProvider; use Mappweb\LaravelNeuronAi\Transcribe\TranscribeProviderInterface; class TranscribeAgent extends Transcribe { public function transcribe(): TranscribeProviderInterface { return new OpenAITranscribeProvider( config('neuron-ai.providers.openai.api_key'), 'whisper-1', 'es', ); } }
Usage in Controllers
<?php namespace App\Http\Controllers; use App\Agents\ChatAgent; use Illuminate\Http\Request; class ChatController extends Controller { public function chat(Request $request) { $agent = new ChatAgent(); $response = $agent->chat($request->input('message')); return response()->json([ 'response' => $response ]); } }
Usage with Facade
use Mappweb\LaravelNeuronAi\Facades\NeuronAI; // Basic usage $agent = NeuronAI::make() ->provider(OpenAIProvider::make()) ->instructions('You are a helpful assistant'); $response = $agent->chat('Hello!'); // With configuration from config $agent = NeuronAI::make() ->provider(config('neuron-ai.default_provider')) ->instructions(config('neuron-ai.agents.default_instructions'));
Advanced Configuration
The config/neuron-ai.php file allows you to configure:
return [ // Default provider 'default_provider' => env('NEURON_AI_DEFAULT_PROVIDER', 'openai'), // Providers configuration 'providers' => [ 'openai' => [ 'api_key' => env('OPENAI_API_KEY'), 'model' => env('OPENAI_MODEL', 'gpt-4'), 'max_tokens' => env('OPENAI_MAX_TOKENS', 2048), 'temperature' => env('OPENAI_TEMPERATURE', 0.7), ], // ... other providers ], // Agents configuration 'agents' => [ 'default_instructions' => env('NEURON_AI_DEFAULT_INSTRUCTIONS', 'You are a helpful AI assistant.'), 'default_namespace' => 'App\\Agents', 'timeout' => env('NEURON_AI_TIMEOUT', 30), ], // Logging and cache 'logging' => [ 'enabled' => env('NEURON_AI_LOGGING_ENABLED', true), 'channel' => env('NEURON_AI_LOG_CHANNEL', 'default'), ], 'cache' => [ 'enabled' => env('NEURON_AI_CACHE_ENABLED', false), 'ttl' => env('NEURON_AI_CACHE_TTL', 3600), ], ];
Generated Prompt Example
<?php declare(strict_types=1); namespace App\Agents\Prompts; use Mappweb\LaravelNeuronAi\Prompts\PromptInterface; class BlogPrompt implements PromptInterface { public function __construct( public string $topic = 'Technology', public int $wordCount = 500, public array $keywords = [], ) { // } public function __toString(): string { return "Write a {$this->wordCount}-word blog post about {$this->topic}. Include keywords: " . implode(', ', $this->keywords); } }
make:agent Command Options
| Option | Description | Example |
|---|---|---|
--provider |
AI provider to use | --provider=openai |
--instructions |
Custom instructions | --instructions="You are helpful" |
--tools |
Tools (comma-separated) | --tools="WebSearch,Email" |
--path |
Custom directory | --path="CustomAgents" |
--force |
Overwrite existing files | --force |
make:prompt Command Options
| Option | Description | Example |
|---|---|---|
--content (-c) |
Default content/template | --content="Hello {$this->name}!" |
--path |
Custom directory | --path="Custom\\Prompts" |
--force (-f) |
Overwrite existing files | --force |
Available Providers
openai→ OpenAIProvideranthropic→ AnthropicProvidergemini→ GeminiProviderollama→ OllamaProvider
Testing
composer test
Changelog
Please see CHANGELOG for recent changes.
Contributing
Contributions are welcome. Please review CONTRIBUTING for more details.
Security
If you discover security vulnerabilities, please send an email to diego.toscanof@gmail.com.
Credits
License
The MIT License (MIT). Please see License File for more information.
mappweb/laravel-neuron-ai 适用场景与选型建议
mappweb/laravel-neuron-ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 539 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「laravel」 「agents」 「ai」 「artificial-intelligence」 「chatbots」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mappweb/laravel-neuron-ai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mappweb/laravel-neuron-ai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mappweb/laravel-neuron-ai 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Interactive CLI that generates customized Claude Code markdown files (CLAUDE.md, commands, agents) for PHP projects with Symfony, Laravel, Rector, PHPStan, PHP-CS-Fixer, GrumPHP and more.
Simple ASCII output of array data
Alfabank REST API integration
Package for view storage in laravel
User Approval Laravel Package
统计信息
- 总下载量: 539
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-27