Skip to content

This is a "prompt-based agent simulation" or "single-LLM multi-persona system" that demonstrates multi-agent patterns within a monolithic Spring Boot application.

Notifications You must be signed in to change notification settings

pradi0809/demo-travel-agents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Multi-Agent Travel Assistant Demo

A Spring Boot application demonstrating a multi-agent system architecture using Spring AI and Ollama for intelligent travel, shopping, and dining assistance.

🌟 Features

Specialized Agents

  • Travel Agent: Flight bookings, hotel recommendations, itinerary planning
  • Shopping Agent: Product recommendations and shopping advice
  • Restaurant Agent: Dining recommendations and reservation assistance

Orchestration Capabilities

  • Smart Routing: AI-powered query analysis to route requests to appropriate agents
  • Multi-Agent Coordination: Combine responses from multiple agents for complex queries
  • Sequential Processing: Process queries through agents in optimal order
  • Parallel Processing: Get responses from all agents simultaneously

πŸ—οΈ Architecture

The application follows a microservices-inspired architecture with:

  • Agent Handler: REST API endpoints for agent interactions
  • Orchestrator Service: Intelligent query routing and multi-agent coordination
  • Individual Agent Services: Specialized services for travel, shopping, and restaurant domains
  • Spring AI Integration: Leverages Ollama for LLM capabilities

πŸš€ Quick Start

Prerequisites

  • Java 17+
  • Maven 3.6+
  • Ollama installed and running
  • Llama3 model pulled in Ollama

Setup Ollama

# Install Ollama (macOS)
brew install ollama

# Start Ollama service
ollama serve

# Pull the Llama3 model
ollama pull llama3

Run the Application

# Clone the repository
git clone <repository-url>
cd demo-travel-agents

# Run the application
./mvnw spring-boot:run

The application will start on http://localhost:8080

πŸ“š API Documentation

Individual Agent Endpoints

Travel Agent

POST /api/agents/travel
Content-Type: application/json

"Plan a 3-day trip to Paris"

Shopping Agent

POST /api/agents/shopping
Content-Type: application/json

"Find the best laptop under $1000"

Restaurant Agent

POST /api/agents/restaurant
Content-Type: application/json

"Recommend Italian restaurants in downtown"

Orchestration Endpoints

Smart Orchestration

POST /api/agents/smart-orchestrate
Content-Type: application/json

"I need to plan a trip to Tokyo and buy travel gear"

Sequential Processing

POST /api/agents/sequential
Content-Type: application/json

"Plan a business trip with shopping and dining"

Get All Agent Responses

POST /api/agents/all
Content-Type: application/json

"Help me with vacation planning"

Utility Endpoints

Health Check

GET /api/agents/health

List Available Agents

GET /api/agents

πŸ”§ Configuration

Application Properties

# Server configuration
server.port=8080

# Ollama configuration
spring.ai.ollama.base-url=http://localhost:11434
spring.ai.ollama.chat.model=llama3
spring.ai.ollama.chat.options.temperature=0.7

# Actuator endpoints
management.endpoints.web.exposure.include=health,info,metrics

πŸ“– API Documentation (Swagger)

Once the application is running, access the interactive API documentation at:

  • Swagger UI: http://localhost:8080/swagger-ui.html
  • OpenAPI Spec: http://localhost:8080/v3/api-docs

πŸ§ͺ Example Usage

Simple Travel Query

curl -X POST http://localhost:8080/api/agents/travel \
  -H "Content-Type: application/json" \
  -d "\"Book a flight from New York to London\""

Complex Multi-Agent Query

curl -X POST http://localhost:8080/api/agents/smart-orchestrate \
  -H "Content-Type: application/json" \
  -d "\"I'm planning a business trip to San Francisco. I need flight recommendations, hotel suggestions, good restaurants for client dinners, and shopping for professional attire.\""

Response Format

{
  "agentType": "Travel Agent",
  "response": "I'd be happy to help you book a flight from New York to London...",
  "modelUsed": "Travel LLM",
  "metadata": null
}

πŸ› οΈ Technology Stack

  • Framework: Spring Boot 3.5.5
  • AI Integration: Spring AI with Ollama
  • LLM: Llama3 (via Ollama)
  • Build Tool: Maven
  • Java Version: 17
  • Documentation: SpringDoc OpenAPI
  • Utilities: Lombok for boilerplate reduction

πŸƒβ€β™‚οΈ Development

Project Structure

src/main/java/com/samshodan/agents/
β”œβ”€β”€ TravelAgentApp.java          # Main application class
β”œβ”€β”€ config/
β”‚   └── AppConfig.java           # Application configuration
β”œβ”€β”€ handler/
β”‚   └── AgentHandler.java        # REST API endpoints
β”œβ”€β”€ model/
β”‚   └── AgentResponse.java       # Response model
└── service/
    β”œβ”€β”€ AgentService.java        # Base service class
    └── impl/
        β”œβ”€β”€ OrchestratorService.java    # Multi-agent orchestration
        β”œβ”€β”€ TravelAgentService.java     # Travel domain logic
        β”œβ”€β”€ ShoppingAgentService.java   # Shopping domain logic
        └── RestaurantAgentService.java # Restaurant domain logic

Building from Source

# Compile and package
./mvnw clean package

# Run tests
./mvnw test

# Run with specific profile
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

πŸ” Monitoring

The application includes Spring Boot Actuator for monitoring:

  • Health: http://localhost:8080/actuator/health
  • Metrics: http://localhost:8080/actuator/metrics
  • Info: http://localhost:8080/actuator/info

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Note: This is a demonstration project showcasing multi-agent system architecture patterns. For production use, consider implementing proper error handling, authentication, rate limiting, and monitoring.

About

This is a "prompt-based agent simulation" or "single-LLM multi-persona system" that demonstrates multi-agent patterns within a monolithic Spring Boot application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages