Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 60 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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:

```
Expand Down Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions app/Neuron/Agents/ResearchAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 7 additions & 2 deletions app/Neuron/Nodes/Receptionist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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 */
Expand Down
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified public/images/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.