From e09c93edfb1b4d3c6fa9a078cc9b74ba12cc5564 Mon Sep 17 00:00:00 2001 From: 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 <237299420+workfromhome130@users.noreply.github.com> Date: Mon, 27 Oct 2025 07:28:36 +0000 Subject: [PATCH] fix error in env vars init logic, fix lint error in Receptionist.php --- README.md | 73 +++++++++++++++++++++++----- app/Neuron/Agents/ResearchAgent.php | 9 ++-- app/Neuron/Nodes/Receptionist.php | 9 +++- package-lock.json | 8 ++- public/images/screen.png | Bin 57437 -> 931236 bytes 5 files changed, 79 insertions(+), 20 deletions(-) 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 ad5dafcffc25ba7a60e740fc9994cd06a42eeb4e..c2938474268c8b1631fe0ebca3d6b7c7c30460a7 100644 GIT binary patch literal 931236 zcma%DXFyX+)4rnEu!0onUKErnBE5Po*Z>vjB?#x7IpE-Tv(qDgV ziTdlWoyg4_f&aMO@~i#puU&tgIdSZ=@4C_6ElJ7KRVoZ@=;2p-GsdOIE?qhySrmSt z%Es~U&FO9-II!cn>_?JWMJLZ*mdx8)Q3n3Odm@>a^zg?{Xznp{mCU7m;d{poajGG#Os8yabhl68p-blUcR2%eEr<7 z+b+@9JiuNKj1vd4{p)*%(>OM7ez2B_Wx4<{HOB(ubX_t8t$gAtktXq-1Vwd31J~_d zLwd6#@Qqqz-|G$KDK|s5tjO=%L+}jyiPQf}>)WFn_D4NMM5QnD%4)0w-7*yS3&Mc6 zynF7ew6XJAy=T$Z+{#{K@W1^o%WGK%uWr^Lo(0z7GtJfz{7u(CYI0QwLptk1ZG}Qy z53aI(hb`~7e5GAx-yan-QWwv=j&0!Jm8KQxEk3LwZ1u%Q-XYH2X9bCz_0p$T2Lj$- zw|vd@-9Nq)I0}$;*vXzHs13-8vi-X4;$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