A powerful laravel framework for connecting to AI APIs such as OpenAI, Gemini, and Ollama, send prompts, collect responses, create agents and agent networks, and put them to work using easy to setup and highly customizable state machines.
laravel-neuro/core is a Laravel package for a powerful laravel framework for connecting to ai apis such as openai, gemini, and ollama, send prompts, collect responses, create agents and agent networks, and put them to work using easy to setup and highly customizable state machines..
It currently has 12 GitHub stars and 24 downloads on Packagist (latest version v1.1.0).
Install it with composer require laravel-neuro/core.
Discover more Laravel packages by laravel-neuro
or browse all Laravel packages to compare alternatives.
Last updated
Join the conversation on the LaravelNeuro Discord Server!
LaravelNeuro is a Laravel package that brings two major features to your application:
See LaravelNeuro in action on the Anomalous Blog, a 100% automated bi-lingual blog with images and voice-over, turning real news articles into supernatural stories, which are then evaluated and classified by the fictional SCP-Foundation.
Install via Composer:
composer require laravel-neuro/core
Publish the configuration file if you want to override defaults:
php artisan vendor:publish --tag=laravelneuro-config
LaravelNeuro comes with a set of prebuilt Pipelines that let you quickly integrate AI models into your Laravel application.
Each Pipeline provides a fluent interface for configuring:
By leveraging builder-pattern methods, you can chain configurations and call methods on the driver without directly modifying the Pipeline’s internal state.
LaravelNeuro\Pipelines\ElevenLabs\AudioTTSLaravelNeuro\Prompts\IVFSpromptChatCompletion:
LaravelNeuro\Pipelines\OpenAI\ChatCompletionLaravelNeuro\Prompts\SUApromptDallE (Image Generation):
LaravelNeuro\Pipelines\OpenAI\DallELaravelNeuro\Prompts\PNSQFpromptAudioTTS:
LaravelNeuro\Pipelines\OpenAI\AudioTTSLaravelNeuro\Prompts\IVFSpromptLaravelNeuro\Pipelines\Google\MultimodalEnvironment Variables:
Add your API keys to your .env file:
OPENAI_API_KEY="your_openai_api_key"
ELEVENLABS_API_KEY="your_elevenlabs_api_key"
GOOGLE_API_KEY="your_google_api_key"
Configuration:
Customize default models and API endpoints by editing the published configuration file (config/laravelneuro.php).
Usage Example:
Here's how to use the ChatCompletion pipeline:
use LaravelNeuro\Pipelines\OpenAI\ChatCompletion;
use LaravelNeuro\Prompts\SUAprompt;
$prompt = new SUAprompt();
$prompt->pushSystem("You are a seasoned dungeonmaster for Dungeons and Dragons 3.5 Edition.");
$prompt->pushUser("I want to create a new character.");
$prompt->pushAgent("How can I help you?");
$prompt->pushUser("My character is a shadow kenku...");
$pipeline = new ChatCompletion();
$pipeline->setModel('gpt-3.5-turbo'); // Change model if needed
$pipeline->setPrompt($prompt);
// For streaming responses:
foreach ($pipeline->streamText() as $chunk) {
echo $chunk;
}
// For non-stream output:
echo $pipeline->output();
Each Pipeline also supports various output methods such as text(), json(), array(), and their streaming counterparts.
Corporations in LaravelNeuro are state machines that orchestrate the execution of complex tasks by networking multiple AI agents. With Corporations, you can create sophisticated workflows that handle everything from data ingestion and processing to automated content generation.
A Corporation is established via the Incorporate process:
lneuro:prebuild Artisan command to scaffold a new Corporation. This command creates a namespace, folder structure, and a setup file (JSON or PHP) that outlines the corporation's units, agents, and transitions.lneuro:install to read the setup file and create all necessary database records, migrations, and files for your Corporation.Units:
Represent functional groupings within a Corporation. Each Unit can have multiple Agents and dataset templates that define how data is processed.
Agents:
An Agent is a single AI component within a Unit. It includes configuration details such as the model, API endpoint, prompt, pipeline class, and role. Agents are responsible for performing specific tasks in the state machine.
Transitions:
Transitions represent the individual steps in the Corporation's state machine. They are generated from stubs during the installation process and guide the flow of execution across different units.
Prebuild the Corporation:
php artisan lneuro:prebuild VoiceAssistant
This command creates the necessary folder structure and a setup.json file in your new Corporation folder.
Edit the Setup File:
Customize setup.json to define:
Install the Corporation:
php artisan lneuro:install VoiceAssistant
This command reads your setup file and creates the corresponding database records and files.
Run the Corporation:
The lneuro:run [CORPORATION NAMESPACE] [Optional:TASK] command executes the state machine, processing transitions and generating a final output based on your defined workflow. You can view the output in the console enabling the --debug flag and log run history by enabling the --history flag.
php artisan lneuro:run VoiceAssistant "path/to/input.wav" --debug --history
To manage database clutter from multiple installations and Corporation runs, LaravelNeuro includes a cleanup command (lneuro:cleanup), which removes history entries and can consolidate old Corporation installations with their most current counterparts.
Contributions, improvements, and bug fixes are welcome!
Please review our CONTRIBUTING.md file for details on our code of conduct and the process for submitting pull requests.
LaravelNeuro is open-sourced software licensed under the MIT license.
This README now provides a structured and detailed overview of both Pipelines and Corporations, showcasing how users can integrate AI models and set up complex state machines in their Laravel applications. Feel free to adjust further based on your project's evolving features and documentation style preferences.