HTTP Endpoints with Large Action Model - Complete AI Integration
Tags: java, ai, http
Published: 2024-04-02 21:08:27

## Prelude

_🚀 Perform seamless integration between your HTTP endpoints and AI prompts! 🤖_

_Imagine a scenario where a user casually mentions, "Hey, I need to see Niagara Falls." 🏞️ With Tools4AI, this simple prompt triggers a sophisticated process behind the scenes._

_🔍 Leveraging advanced natural language processing (NLP) and AI integration, Tools4AI interprets the user's request and automatically discovers and calls a corresponding HTTP endpoint—such as getAttractions(place=Niagara)—with no manual intervention required._

_It can call multiple actions in parallel or sequential with Human in Loop/Out of Loop and Explainabity configurations. It can break down complex prompts into several actions and call them to provide combined results._

_This streamlined approach can empower enterprises to respond to user needs swiftly and efficiently, revolutionizing the way workflows are executed across organizations._

## Overview

In today's fast-paced digital landscape, enterprises rely heavily on the integration of various software systems to streamline operations and drive efficiency. With the advent of artificial intelligence (AI) technologies, businesses are now exploring innovative solutions to automate repetitive tasks and enhance decision-making processes. [Tools4AI ](https://github.com/vishalmysore/Tools4AI)is an open source cutting-edge platform that seamlessly integrates HTTP endpoints with AI-driven capabilities, unlocking unparalleled efficiency and agility across organizational workflows.

> Please read about my article on Large Action Model [here](https://www.linkedin.com/pulse/action-all-you-need-moving-beyond-conversation-ai-vishal-mysore-sukfc/?trackingId=YTiaJGauRXW6Jp%2BEv3oGyg%3D%3D&lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BkNhdkPWhSy%2BRoh1OuXTYQg%3D%3D)

**The Power of HTTP Endpoints**

[HTTP endpoints](https://smartbear.com/learn/performance-monitoring/api-endpoints/) serve as the [backbone of modern enterprise applications](https://www.altexsoft.com/blog/rest-api-design/), facilitating communication between different software components and enabling the exchange of data over the web. These endpoints encapsulate key functionalities of the underlying systems, exposing them to external clients in a standardized and accessible manner. From retrieving customer information to processing financial transactions, HTTP endpoints play a crucial role in enabling seamless interactions between disparate systems within the enterprise ecosystem.

> Article on Shell actions and other types of actions mapping to Prompts is [here](https://www.linkedin.com/pulse/large-action-model-gemini-java-vishal-mysore-qki8c/?trackingId=0lgTiJqcbkwyP7FeXeeRUA%3D%3D&lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BkNhdkPWhSy%2BRoh1OuXTYQg%3D%3D)

## Tools4AI

[Tools4AI](https://github.com/vishalmysore/Tools4AI) represents a paradigm shift in how enterprises can leverage AI to automate tasks and enhance productivity. At its core, Tools4AI acts as an intelligent intermediary between users and HTTP endpoints, harnessing the power of natural language processing (NLP) and AI to interpret user queries and execute corresponding actions seamlessly. By integrating with the enterprise's existing HTTP endpoints, Tools4AI empowers users to perform complex tasks and retrieve valuable insights with simple, conversational interactions.

**Leveraging Swagger JSON for Seamless Integration**

Central to Tools4AI's functionality is its ability to leverage Swagger JSON, a widely adopted standard for describing RESTful APIs, to automate the integration of HTTP endpoints. By analyzing the Swagger documentation provided by enterprise applications, Tools4AI dynamically generates actions and maps them to the appropriate HTTP endpoints in real time. This allows users to interact with enterprise systems using natural language queries, eliminating the need for manual intervention and enhancing the overall user experience.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9hh1xjqne6j5s0u8nlh.png)
Sample swagger Json looks like this

```java
{
  "openapi": "3.0.0",
  "info": {
    "title": "Library Management API",
    "description": "API for managing authors and books in a library system",
    "version": "1.0.0"
  },
  "paths": {
    "/api/v1/authors": {
      "get": {
        "summary": "Get all authors",
        "tags": ["Authors"],
        "responses": {
          "200": {
            "description": "List of authors",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Author"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a new author",
        "tags": ["Authors"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAuthor"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Author created successfully"
          }
        }
      }
    },
    "/api/v1/books": {
      "get": {
        "summary": "Get all books",
        "tags": ["Books"],
        "responses": {
          "200": {
            "description": "List of books",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Book"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a new book",
        "tags": ["Books"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewBook"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Book created successfully"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Author": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "NewAuthor": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": ["name"]
      },
      "Book": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "author": {
            "$ref": "#/components/schemas/Author"
          }
        }
      },
      "NewBook": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "authorId": {
            "type": "integer"
          }
        },
        "required": ["title", "authorId"]
      }
    }
  }
} 
```
This gets mapped to actionable prompts in real time. 

**Enhancing Enterprise Workflows with Tools4AI**
The integration of Tools4AI with HTTP endpoints offers a myriad of benefits for enterprises looking to optimize their workflows and drive operational efficiency:

**Streamlined Interactions:** Users can interact with enterprise systems using natural language queries, simplifying complex tasks such as data retrieval, transaction processing, and system configuration.
**Automated Task Execution:** Tools4AI automates the execution of tasks by mapping user queries to the corresponding HTTP endpoints, reducing the need for manual intervention and accelerating decision-making processes.
**Real-time Insights:** By leveraging AI-driven capabilities, Tools4AI provides users with real-time insights and actionable recommendations based on the analysis of enterprise data accessible through HTTP endpoints.
**Improved User Experience:** With intuitive conversational interfaces, Tools4AI enhances the user experience by eliminating the complexities associated with traditional enterprise applications, resulting in increased user adoption and satisfaction.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3gjy214r28v01j838we6.png)

**Use Cases of Tools4AI in Enterprise Environments**
Tools4AI finds application across a wide range of enterprise use cases, including:
**Customer Service Automation:** Tools4AI can automate customer service interactions by retrieving customer information, processing requests, and providing personalized recommendations based on historical data.
**Financial Operations:** Tools4AI can streamline financial operations by executing transactions, generating reports, and analyzing market trends using data accessible through HTTP endpoints.
**Inventory Management:** Tools4AI can facilitate inventory management by tracking stock levels, generating purchase orders, and optimizing supply chain processes in real-time.

## Examples

**GET Method:**
**HTTP Endpoint:** /api/v1/customers
**Description:** Retrieves a list of customers from the database.
**Prompt:** "I'm curious about our client base, can you give me some insights?"
**Action:** Tools4AI interprets the prompt and executes the GET request to retrieve customer data, presenting it in a user-friendly format.

**POST Method:**
****HTTP Endpoint:** /api/v1/orders
**Description:** Creates a new order in the system.
**Prompt:** "I'd like to place an order for a new product." or "I'm interested in trying something new, can you help me with that?"
**Action:** Tools4AI recognizes the intent to create a new order and prompts the user for relevant details such as product name, quantity, and delivery address. It then executes the POST request to create the order in the system.

**PUT Method:**
****HTTP Endpoint:** /api/v1/products/{id}
**Description:** Updates an existing product with the specified ID.
**Prompt:** "I need to update the details of product XYZ."
**Action:** Tools4AI identifies the request to update product information and prompts the user to specify the changes required. Once the details are provided, it executes the PUT request to update the product information in the database.

Tools4AI's flexibility allows it to map even vague or semantically similar prompts to relevant HTTP endpoints. Here are examples illustrating how vague prompts can still be mapped effectively:

**Vague Prompt:**
"I'm craving something delicious."

**Mapped Action:** Tools4AI recognizes the user's desire for food-related information or services.
**Action Response:** It executes a GET request to fetch a list of nearby restaurants or popular dishes, presenting the options to the user for further selection.

**Semantically Similar Prompt:**
"I want to see what's trending in fashion."
Mapped Action: Tools4AI understands the user's interest in fashion trends or new arrivals.

**Action Response:** It executes a GET request to retrieve the latest fashion collections or trending styles from an e-commerce platform, displaying the results to the user.

**Ambiguous Prompt:**
"I'm in the mood for something different today."
Mapped Action: Tools4AI interprets the user's desire for novelty or variety.

**Action Response:** It could execute various actions based on available endpoints, such as suggesting new activities, recommending unique experiences, or providing diverse dining options.

By leveraging advanced natural language processing (NLP) algorithms, Tools4AI can analyze the context and semantics of vague prompts, enabling it to generate relevant actions and responses tailored to the user's preferences and needs. This adaptability ensures a seamless and intuitive user experience, regardless of the clarity or specificity of the input provided.
Yes, Off course there is Human in Loop , Explainability and other governing modules which have been built into the Tools4AI. Please refer to the documentation to learn more about those features