Why Build a ChatBot When You Can Create a LLM Agent on OpenAI or Gemini
Tags: programming, ai, devops, productivity
Published: 2024-05-01 22:47:58

In Past few months ChatBots have gained significant popularity as a means of automating customer interactions and providing instant support. However, while ChatBots excel in certain domains, they often fall short when it comes to handling complex workplace tasks and workflows. In this article, we will build an LLM Agent tailored for workflow automation—and discuss why it could offer a better solution compared to simple chatbot.

**What are LLM Agents?**

"LLM Agent" stands for "Large Language Model Agent." It refers to an advanced AI system built on large language models, such as OpenAI's GPT (Generative Pre-trained Transformer) models or similar architectures. These models are trained on vast amounts of text data and have a deep understanding of natural language. LLM Agents are capable of understanding and generating human-like text, making them highly effective for tasks such as natural language understanding, text generation, and conversation management.

In practical terms, an LLM Agent can be used for a variety of applications, including chatbots, virtual assistants, content generation, language translation, and more. They excel at processing and generating text in a way that closely mimics human language patterns, allowing for more natural and engaging interactions with users.

[Tools4AI ](https://github.com/vishalmysore/Tools4AI) is a Java-based LLM (Large Language Model) Agent platform.

**Use Case: Car Rental Company Automation**

Scenario:
Consider a bustling car rental company that manages a fleet of vehicles for customers. The company faces challenges in efficiently managing bookings, vehicle maintenance, and customer inquiries. To address these challenges, the company decides to implement a Agent to automate various aspects of its operations.

Solution:
By leveraging Tools4AI to create an Agent, the car rental company can automate processes related to booking management, vehicle maintenance, and customer support, enhancing efficiency and customer satisfaction.


```
import com.tools4ai.annotation.Action;
import com.tools4ai.annotation.Predict;

@Predict(groupName="car rental actions")
public class CarRentalActions {

    @Action(description = "Book a vehicle for a customer")
    public  String bookVehicle(String customerName, String vehicleType) {
        // Logic to book a vehicle for the customer
        return "Vehicle booked for " + customerName + ". Type: " + vehicleType;
    }

}

```
All the actions could be exposed via rest call as well 

```
{
  "openapi": "3.0.0",
  "info": {
    "title": "Rental Company API",
    "description": "API for managing rental operations",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://rental-company-api.com"
    }
  ],
  "paths": {
    "/vehicles": {
      "get": {
        "summary": "Get all available vehicles",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "example": {
                  "vehicles": [
                    {
                      "id": 1,
                      "name": "Toyota Corolla",
                      "type": "Sedan",
                      "price_per_day": 50.00,
                      "available": true
                    },
                    {
                      "id": 2,
                      "name": "Honda Civic",
                      "type": "Sedan",
                      "price_per_day": 55.00,
                      "available": false
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/vehicles/{id}": {
      "get": {
        "summary": "Get details of a specific vehicle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the vehicle",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "example": {
                  "id": 1,
                  "name": "Toyota Corolla",
                  "type": "Sedan",
                  "price_per_day": 50.00,
                  "available": true
                }
              }
            }
          },
          "404": {
            "description": "Vehicle not found"
          }
        }
      }
    },
    "/vehicles/{id}/rent": {
      "post": {
        "summary": "Rent a vehicle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the vehicle",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Vehicle rented successfully"
          },
          "404": {
            "description": "Vehicle not found"
          }
        }
      }
    },
    "/vehicles/{id}/return": {
      "post": {
        "summary": "Return a rented vehicle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the vehicle",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Vehicle returned successfully"
          },
          "404": {
            "description": "Vehicle not found"
          }
        }
      }
    }
  }
}

```

In this case all these rest calls will be added to list of actions to be predicted based on prompt


Users can make a variety of prompts to interact with the rental company's API. Here are some examples of prompts users might make:

**Get all available vehicles:**
"Show me all available cars."
"List all vehicles I can rent."
"What cars are available for rent?"
**Get details of a specific vehicle:**
"Tell me about car with ID 123."
"Get details of vehicle number 456."
"Describe vehicle with ID 789."
**Rent a vehicle:**
"I want to rent car number 123."
"Rent vehicle with ID 456 for three days."
"Book car 789 for the weekend."
**Return a rented vehicle:**
"I'm returning car 123."
"Return vehicle 456."
"I want to bring back car number 789."

These prompts are designed to interact with the endpoints defined in the Swagger JSON. Users can use natural language to communicate their requests, and the system will interpret the intent behind the prompts and execute the corresponding actions.

This solution seamlessly works with OpenAI, Anthropic, or Gemini, making it easy for everyone to automate tasks. With these powerful platforms, the system understands what users want, whether it's scheduling maintenance or managing inventory. It can adapt to different needs and integrate smoothly with other systems, like APIs defined in Swagger. This simplicity and flexibility make it a game-changer for teams looking to streamline their workflow.