{"id":15160009,"url":"https://github.com/dynamicanupam/GenAI_based_Shopping_Assistant","last_synced_at":"2025-09-30T10:31:01.039Z","repository":{"id":254018383,"uuid":"844727693","full_name":"dynamicanupam/GenAI_based_Shopping_Assistant","owner":"dynamicanupam","description":"A conversational chatbot that provides shopping recommendations to users based on their preferences","archived":false,"fork":false,"pushed_at":"2024-09-27T17:56:21.000Z","size":327,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-16T04:51:20.210Z","etag":null,"topics":["chatgpt","flask","gpt-4","openaiapi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynamicanupam.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T21:13:25.000Z","updated_at":"2024-09-27T18:03:39.000Z","dependencies_parsed_at":"2024-08-27T19:18:40.369Z","dependency_job_id":null,"html_url":"https://github.com/dynamicanupam/GenAI_based_Shopping_Assistant","commit_stats":null,"previous_names":["dynamicanupam/shopassist-ai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FGenAI_based_Shopping_Assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FGenAI_based_Shopping_Assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FGenAI_based_Shopping_Assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FGenAI_based_Shopping_Assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynamicanupam","download_url":"https://codeload.github.com/dynamicanupam/GenAI_based_Shopping_Assistant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234724896,"owners_count":18877279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","flask","gpt-4","openaiapi"],"created_at":"2024-09-26T22:03:38.492Z","updated_at":"2025-09-30T10:30:55.708Z","avatar_url":"https://github.com/dynamicanupam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GenAI_based_Shopping_Assistant\n\n\n## 1. Background\nIn 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.\n\n## 2. Problem Statement\nGiven 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.\n\n## 3. Approach\n1. **Conversation and Information Gathering:** The chatbot will utilize language models to understand and generate natural responses. Through a conversational flow, it will ask relevant questions to gather information about the user's requirements.\n2. **Information Extraction:** Once the essential information is collected, rule-based functions come into play, extracting the top 3 laptops that best match the user's needs.\n3. **Personalized Recommendation:** Leveraging this extracted information, the chatbot engages in further dialogue with the user, efficiently addressing their queries and aiding them in finding the perfect laptop solution.\n\n## 4. System Functionalities\n\n- **User Interface:** ShopAssistAI provides a user-friendly web interface where users can interact with the conversational AI assistant.\n- **Conversational AI:** The core of ShopAssistAI is the conversational AI powered by OpenAI's chat model. It guides the user through the process by asking relevant questions and understanding their needs.\n- **User Input Moderation:** User input is moderated using OpenAI's moderation API to ensure a safe and secure conversation.\n- **User Profile Extraction:** The AI assistant extracts key information from the conversation to build a user profile that reflects their laptop preferences (budget, screen size, processing power, etc.) using OpenAI's function calling mechanism to convert a user requirement string into a JSON object.\n\nWe 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.\n\n## 5. System Architecture\n\nShopAssistAI 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.\n\n![stages](https://github.com/user-attachments/assets/e6e690f5-8bb2-4cf6-9b13-08b7eaee14f9)\n\n![systemdesign](https://github.com/user-attachments/assets/001e9fff-763e-4a54-9cc0-6633021f7ea0)\n\n## 6. Implementation Details\n\nThe Flask application utilizes various functionalities:\n\n- **Routing:** Maps user requests to appropriate functions based on URLs.\n- **Conversation Management:** Handles conversation initiation, response generation through OpenAI's chat model, and conversation history maintenance.\n- **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).\n- **Recommendation Logic:** Compares user profiles with laptop data, validates recommendations, and generates recommendation text.\n\n  ### Major Functions\n- `initialize_conversation()`: Initializes the variable conversation with the system message.\n- `get_chat_completions()`: Takes the ongoing conversation as the input and returns the response by the assistant.\n- `moderation_check()`: Checks if the user's or the assistant's message is inappropriate. If any of these is inappropriate, it ends the conversation.\n- `intent_confirmation_layer()`: Evaluates if the chatbot has captured the user's profile clearly.\n- `dictionary_present()`: Checks if the final understanding of the user's profile is returned by the chatbot as a Python dictionary.\n- `compare_laptops_with_user()`: Compares the user's profile with the different laptops and comes back with the top 3 recommendations.\n- `initialize_conv_reco()`: Initializes the recommendations conversation.\n\n\n### Prerequisites\n- Python 3.7+\n- OpenAI API Key(you have to add openai api key in the empty txt file (OpenAI_API_Key))\n\n### Getting Started\n\nTo get started with ShopAssist AI, follow these steps:\n\n1. **Clone the repository:**\n   ```\n   git clone https://github.com/dynamicanupam/ShopAssist-AI.git\n   cd ShopAssist-AI\n   ```\n2. **Lunch VS Code from Anaconda**\n   - In VS Code go to `File` \u003e `Open Folder...` and select the `ShopassistAI` folder.\n   - Open a terminal in VS Code (``Ctrl+` `` or go to `Terminal` \u003e `New Terminal`).\n2. **Install dependencies:**\n```   \npip install -r requirements.txt\n```\n3. **Initialize the conversation:**  \n```\npython app.py\n```\n#### Note: This version includes steps to create and activate the Conda environment with Python 3.11.9 0r above, ensuring users set up python environment correctly before installing dependencies and running the application.\n\n\n## 7. Appendix - B\n\nUser output example screenshot:\n\n![Screenshot1](Images/1_ShopAssistChat.png)\n\n\n![Screenshot2](Images/2_ShopAssistChat.png)\n\n\n![Screenshot3](Images/3_ShopAssistChat.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicanupam%2FGenAI_based_Shopping_Assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynamicanupam%2FGenAI_based_Shopping_Assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicanupam%2FGenAI_based_Shopping_Assistant/lists"}