Skip to content
5th Anniversary
Celebrating five years of engineering-led delivery and client success.Our story
Celebrating five years of engineering-led delivery and client success.Our story
Generative AI & LLMAI Architecture

Recommendation System: Azure OpenAI & Google Search

Leveraging Generative AI to enhance supplier recommendations in procurement with Azure OpenAI and Google Search.

Azure OpenAI
×
LangChain
Recommendation System: Azure OpenAI & Google Search

Introduction

Generative AI is now a practical capability in modern software engineering. This blog demonstrates how we used it to provide relevant supplier recommendations for our procurement platform, Smart Spend Operations.

Problem Statement

Smart Spend Operations is a procurement platform developed by RefactorQ to enable fully managed procurement and spend management for SMBs.

The Smart Spend Operations team receives requests from customers for different goods. To fulfill these requests, the procurement team works to provide the required items at the best price and in a shorter turnaround time. This entire process is manual and requires more effort if existing suppliers cannot fulfill the required items. In such cases, the procurement team has to identify the right suppliers on the internet or other platforms, such as IndiaMart.

We developed a recommendation system that considers supplier context and provides a list of relevant suppliers. The system also searches for suppliers on IndiaMart and other relevant portals and extracts details for display in a list view.

Solution

The solution uses a large language model to generate relevant results from structured context. The technologies used are:

  1. 1Azure OpenAI (gpt-35-turbo)
  2. 2LangChainJS
  3. 3Google JSON Retrieval API

Recommendation Engine for Database Suppliers

The first part of this workflow prioritizes suppliers already available in the internal database because they are vetted and typically faster to engage. The engine follows this flow:

Fetch Suppliers From Database
Convert the data into Textual Format for AI
Submit structured supplier context and prompts to the AI model
Parse the Retrieved Data into JSON

The supplier data is retrieved from the database and then processed into text using a parser. This is necessary because the AI cannot directly interpret JSON data. The AI relies on the processed text as its knowledge base to respond to user queries. Each user query contains a summary of the request and a category, ensuring that only relevant results are provided.

The response from the AI is in a textual format as well, but due to the use of a Zod Schema, the AI returns data in a JSON-like format which is converted to proper JSON by the parser.

The JSON data is refined and ranked by the AI itself, so there is no need for post-processing; the data is returned to the frontend client.

Recommendation Engine for IndiaMart Suppliers

The recommendation system includes extracting results from external sources, currently limited to IndiaMart. The process is as follows:

Retrieve Summary from POST API
Search using Google JSON Retriever with custom Context
The Retrieved Results contain an "items" array
Access the link property by mapping over items array
Create a GET Request to the link which retrieves the HTML
Load the HTML with JSDOM to create a DOM object
Retrieve necessary data with Query Selectors
Repeats from step 4 until the items array is fully traversed
Convert the data into Textual Format
Same process as the database recommendation workflow

The search is performed with the use of the Google JSON Retriever, but the API requires a context engine to work. In simpler terms, the context engine limits the Google Search to specific endpoints, which in this case is set to IndiaMart only. More on how to create & operate the API can be found here.

The API results contain an array with the key "items" and each object in that field contains a "link" for scraping. Each link is accessed using an Axios GET request to retrieve the HTML of the page. The HTML is then processed using the JSDOM class to extract the necessary data. This data is transformed into text and sent to AI for further processing. Once the API is done fetching, the frontend displays the results.

Recommendations from Indiamart

Supplier HeadingCost
BIGFALCON Medical Xray Dry Film for Inkjet Size 8"X10" 100 Sheets For X-ray, CR, DR and OPG Images -
X Ray Lead Sheet -
Cold Rolled 2.5 mm X Ray Lead Sheet -
1.5 mm X Ray Lead Sheet -
GMP Medical X-Ray Inkjet Film BLUE COLOR - 100 SHEET -
X Ray Lead Sheet, Thickness: 2 mm -
Hot Rolled Lead Sheet For C T Scan, Thickness: 2 mm -

Notes

  1. 1GPT-3.5-Turbo is the model of choice here, used due to its capabilities of high input token size & faster retrievals.
  2. 2The required keys for this are: Azure OpenAI Credentials, Google Context Engine Key, Google API Key.
Related Engineering Practice

AI & ML Engineering

Deploy production machine learning models, MLOps pipelines, and low-latency inference architectures for enterprise systems.

Explore AI & ML Engineering Services
Start a conversation

Have a production bottleneck or modernization initiative?

Tell us where your software architecture or cloud environment is experiencing friction. A senior engineer will review your challenge and outline an actionable technical roadmap.

Book a call (opens Microsoft Bookings in a new tab)30 minutes with a senior engineer

A senior engineer reads every enquiry and replies within one business day