A conversational chatbot that provides shopping recommendations to users based on their preferences
In today's digital age, online shopping has become the go-to option for many consumers. However, the overwhelming number of choices and the lack of personalized assistance can make the shopping experience daunting. To address this, we have developed ShopAssist AI, a chatbot that combines the power of large language models and rule-based functions to ensure accurate and reliable information delivery.
Given a dataset containing information about laptops (product names, specifications, descriptions, etc.), build a chatbot that parses the dataset and provides accurate laptop recommendations based on user requirements.
We have a dataset laptop_data.csv
where each row describes the features of a single laptop and also has a small description at the end. The chatbot will leverage large language models to parse this Description
column and provide recommendations.
ShopAssistAI follows a client-server architecture. Users interact with the web interface hosted on a server running the Flask application. The application interacts with OpenAI's API for conversation generation and moderation and retrieves and compares laptop data from an external database.
The Flask application utilizes various functionalities:
Routing: Maps user requests to appropriate functions based on URLs.
Conversation Management: Handles conversation initiation, response generation through OpenAI's chat model, and conversation history maintenance.
User Input Processing: Captures user input, performs moderation checks, and extracts user profiles from conversation history (converting user input string to JSON using OpenAI Function calling).
Recommendation Logic: Compares user profiles with laptop data, validates recommendations, and generates recommendation text.
initialize_conversation()
: Initializes the variable conversation with the system message.
get_chat_completions()
: Takes the ongoing conversation as the input and returns the response by the assistant.
moderation_check()
: Checks if the user's or the assistant's message is inappropriate. If any of these is inappropriate, it ends the conversation.
intent_confirmation_layer()
: Evaluates if the chatbot has captured the user's profile clearly.
dictionary_present()
: Checks if the final understanding of the user's profile is returned by the chatbot as a Python dictionary.
compare_laptops_with_user()
: Compares the user's profile with the different laptops and comes back with the top 3 recommendations.
initialize_conv_reco()
: Initializes the recommendations conversation.
To get started with ShopAssist AI, follow these steps:
git clone https://github.com/dynamicanupam/ShopAssist-AI.git
cd ShopAssist-AI
File
> Open Folder...
and select the ShopassistAI
folder.Ctrl+`
or go to Terminal
> New Terminal
).pip install -r requirements.txt
python app.py
User output example screenshot: