Recommendation System: Azure OpenAI & Google Search
Leveraging Generative AI to enhance supplier recommendations in procurement with Azure OpenAI and 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:
- 1Azure OpenAI (gpt-35-turbo)
- 2LangChainJS
- 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:
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:
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 Heading | Cost |
|---|---|
| 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
- 1GPT-3.5-Turbo is the model of choice here, used due to its capabilities of high input token size & faster retrievals.
- 2The required keys for this are: Azure OpenAI Credentials, Google Context Engine Key, Google API Key.
AI & ML Engineering
Deploy production machine learning models, MLOps pipelines, and low-latency inference architectures for enterprise systems.