diff --git a/README.md b/README.md index c2f4cba..f4d2240 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,68 @@ -# Travel Planner Agent in Laravel +# Travel Planner Agent in Laravel ![Neuron Travel Planner Agent](public/images/screen.png) +## Prerequisites + +```yaml +node.js: 20.19.4 + +php: 8.2 +composer: 2.8.9 + +laravel: 12.0 +neuron-ai: 2.0 +``` + +Need to get SerpApi key from https://serpapi.com/dashboard + +```dotenv +SERPAPI_KEY= +``` + +## Getting Started + +```bash +npm i +composer install +``` + +```bash +# migrate SQLite database +php artisan migrate + +# generate APP_KEY in .env +php artisan key:generate + +###################################### +# Or, All-in-One command +composer setup + +php artisan serve +``` + +Visit http://localhost:8000/dashboard + +- http://localhost:8000/register + +- http://localhost:8000/login + ## About This Project -This project demonstrates how to integrate multi-agent workflows in a Laravel application +This project demonstrates how to integrate multi-agent workflows in a Laravel application using [Neuron](https://docs.neuron-ai.dev) PHP AI framework. Stack Used: -- [Laravel](https://laravel.com) and [Livewire](https://livewire.laravel.com/) for the application. -- [Neuron Workflow](https://docs.neuron-ai.dev/workflow/getting-started) for multi-agent orchestration. -- [SerpAPI](https://serpapi.com) for finding hotels, flights and places to visit comprehensive research reports on any topic using large language models, - with a focus on modularity, extensibility, and real-time results. +- [Laravel](https://laravel.com) and [Livewire](https://livewire.laravel.com/) for the application. +- [Neuron Workflow](https://docs.neuron-ai.dev/workflow/getting-started) for multi-agent orchestration. +- [SerpAPI](https://serpapi.com) for finding hotels, flights and places to visit comprehensive research reports on any topic using large language models, + with a focus on modularity, extensibility, and real-time results. ![](public/images/chart.jpeg) ## Neuron PHP framework + Neuron is an agentic framework that allows you to create full-featured AI Agents in PHP. It definitively fills the gap for AI Agents development between PHP and other ecosystems like Python or Javascript. @@ -30,6 +76,7 @@ to move your idea from experiments to reliable production implementations. Check out the documentation: https://docs.neuron-ai.dev ## How to use this project + Download the project on your machine and open your terminal in the project directory and run the command below: ``` @@ -57,16 +104,16 @@ Open the project in your browser, register an account, and start planning your t ## Workflow architecture and Nodes -- **TravelPlannerAgent**: Orchestrates the overall itinerary generation process +- **TravelPlannerAgent**: Orchestrates the overall itinerary generation process ### Nodes -- **Receptionist**: Collect all the information from the user -- **Delegator**: Generates single reports for flights, hotels, and places to visit - - *Flights* - - *Hotels* - - *Places* -- **GenerateItinerary**: Generates the final report +- **Receptionist**: Collect all the information from the user +- **Delegator**: Generates single reports for flights, hotels, and places to visit + - _Flights_ + - _Hotels_ + - _Places_ +- **GenerateItinerary**: Generates the final report ## Monitoring & Debugging diff --git a/app/Neuron/Agents/ResearchAgent.php b/app/Neuron/Agents/ResearchAgent.php index 8b887b3..fb4a4d5 100644 --- a/app/Neuron/Agents/ResearchAgent.php +++ b/app/Neuron/Agents/ResearchAgent.php @@ -17,21 +17,22 @@ class ResearchAgent extends Agent { protected function provider(): AIProviderInterface { - if (isset($_ENV['ANTHROPIC_API_KEY'])) { + if (!empty($_ENV['ANTHROPIC_API_KEY'])) { return new Anthropic( $_ENV['ANTHROPIC_API_KEY'], 'claude-3-7-sonnet-latest' ); } - if (isset($_ENV['OPENAI_API_KEY'])) { + if (!empty($_ENV['OPENAI_API_KEY'])) { return new OpenAI( $_ENV['OPENAI_API_KEY'], - 'gpt-3.5-turbo' + // 'gpt-3.5-turbo' + 'gpt-4o' ); } - if (isset($_ENV['GEMINI_API_KEY'])) { + if (!empty($_ENV['GEMINI_API_KEY'])) { return new Gemini( $_ENV['GEMINI_API_KEY'], 'gemini-2.0-flash' diff --git a/app/Neuron/Nodes/Receptionist.php b/app/Neuron/Nodes/Receptionist.php index 36c10d4..98de18e 100644 --- a/app/Neuron/Nodes/Receptionist.php +++ b/app/Neuron/Nodes/Receptionist.php @@ -16,11 +16,15 @@ use NeuronAI\Workflow\StartEvent; use NeuronAI\Workflow\WorkflowInterrupt; use NeuronAI\Workflow\WorkflowState; +use Illuminate\Support\Facades\Auth; class Receptionist extends Node { - public function __construct(protected ChatHistoryInterface $history) + protected ChatHistoryInterface $history; + + public function __construct(ChatHistoryInterface $history) { + $this->history = $history; } /** @@ -38,7 +42,8 @@ public function __invoke(StartEvent $event, WorkflowState $state): Retrieve if ($query === null) { $query = \str_replace('{query}', $state->get('query'), Prompts::TOUR_PLANNER); - $query = \str_replace('{name}', auth()->user()->name, $query); + // $query = \str_replace('{name}', auth()->user()->name, $query); + $query = \str_replace('{name}', Auth::user()->name, $query); } /** @var ExtractedInfo $info */ diff --git a/package-lock.json b/package-lock.json index 36d7d7b..55e7337 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "laravel-travel-planner", + "name": "lara-travel-agent", "lockfileVersion": 3, "requires": true, "packages": { @@ -1400,6 +1400,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001737", "electron-to-chromium": "^1.5.211", @@ -2920,6 +2921,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -3453,6 +3455,7 @@ "integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -3605,6 +3608,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -3693,6 +3697,7 @@ "integrity": "sha512-X5QFK4SGynAeeIt+A7ZWnApdUyHYm+pzv/8/A57LqSGcI88U6R6ipOs3uCesdc6yl7nl+zNO0t8LmqAdXcQihw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -3797,6 +3802,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, diff --git a/public/images/screen.png b/public/images/screen.png index ad5dafc..c293847 100644 Binary files a/public/images/screen.png and b/public/images/screen.png differ