Skip to content

Repository files navigation

PickARestaurant Chatbot Project Report

August 4, 2025

ExecutiveSummary

This report details the development of the PickARestaurant chatbot, a web-based application designed to assist users in finding restaurants based on their preferences for location, cuisine, and budget. Built using Flask, Python, CSS, and OpenAI APIs, the chatbot leverages natural language processing to extract user requirements and recommends suitable restaurants. This document outlines the project’s objectives, design, implementation, challenges faced & the lessons learned.

2 Objectives

The primary objectives of the PickARestaurant chatbot project were: • To create an intuitive and user-friendly interface for restaurant discovery. • To utilize OpenAI’s natural language processing capabilities to interpret user inputs and extract relevant preferences (location, cuisine, budget). • To integrate the restaurant database to provide accurate and relevant recommendations. • To implement moderation to ensure appropriate user interactions. • To deliver a responsive and visually appealing web application using Flask and CSS.

Design

3.1 System Architecture

The application follows a client-server architecture with the following components:

  • Frontend: A Flask-rendered HTML template(front_end.html) styled with CSS (styles.css) to display the chat interface and restaurant recommendations.
  • Backend: Flask-based Python application(appPickARestaurant.py) handling user sessions, API interactions, and routing.
  • UserSessionManagement: A Python class (UserSession.py) to maintain chat history, LLM conversation state, and user profile data.
  • LLMIntegration: OpenAI APIs (constants_functions_llm.py) for natural language understanding and user profile extraction.
  • Database: ACSV-basedrestaurantdataset(zomato_dataset.csv)for fetching restaurant recommendations.

3.2 Key Features

• Conversational Interface: Users interact via a text input field, receiving the responses from the chatbot displayed in a scrollable conversation container. • UserProfileExtraction: The chatbot extracts location, cuisine, and budget preferences using OpenAI’s tool-calling functionality. • RestaurantRecommendations: Matches user preferences against a dataset and presents up to five restaurants in a formatted list. • Moderation: Checks user and assistant messages for inappropriate content using OpenAI’s moderation API. • Session Management: Persists user interactions and resets the conversation when requested.

3.3 Workflow

  1. The user initiates a session, receiving a welcome message.
  2. The chatbot prompts for location, cuisine, and budget through natural conversation.
  3. User inputs are processed by OpenAI’s API to extract structured preferences.
  4. Preferences are matched against the restaurant dataset, and recommendations are displayed.
  5. Users can continue the conversation or end the session, resetting the state.

4 Implementation

4.1 Technologies Used

• Python/Flask: Backend framework for routing and session management. • OpenAIAPIs: For natural language processing and moderation. • HTML/CSS: Frontend interface with responsive design. • Pandas: For handling the restaurant dataset.

4.2 Code Structure

• appPickARestaurant.py: Flask application handling routes (/, /chat, /end_conv) and session initialization. • UserSession.py: Manages chat history, LLM conversation, and user profile; includes methods for state updates and restaurant fetching. • constants_functions_llm.py: Definessystemprompts,APIcalls(llm_chat, llm_chat2), and restaurant fetching logic. • front_end.html: Renders the chat interface and restaurant cards. • styles.css: Styles the frontend for a clean and responsive user experience.

4.3 Key Implementation Details

• User Input Processing: The update_state method in UserSession.py processes user messages, appending them to the chat history and LLM conversation. Itusesllm_chattoextractpreferencesviaOpenAI’stool-calling. • RestaurantFetching: The fetch_restaurants function filters the dataset based on user profile attributes and sorts results by budget. • Moderation: The moderation_flagged function checks messages for appropriateness, redirecting to session end if flagged. • Frontend Rendering: Jinja2 templating in front_end.html dynamically displays chat history and restaurant lists using CSS grid layouts.

5 Challenges

• UserProfileExtraction: Ensuring accurate extraction of location, cuisine, and budget from varied user inputs required careful prompt engineering in constants_functions_llm.py. • Moderation Handling: IntegratingOpenAI’smoderationAPIandhandling flagged content without disrupting the user experience was complex. • Dataset Limitations: The CSV dataset may lack comprehensive or up-to-date restaurant data, affecting recommendation quality. • SessionPersistence: Managing global session state in Flask required careful handling to avoid data leaks or session conflicts. • Responsive Design: Ensuring the chat interface and restaurant cards were visually appealing and functional across devices demanded extensive CSS tuning.

LessonsLearned

• PromptEngineering: Crafting precise system prompts for OpenAI APIs is critical for reliable user profile extraction. • Error Handling: Robust error handling for API failures and invalid user inputs is essential for a smooth user experience. • Data Quality: The accuracy of recommendations depends heavily on the quality and completeness of the dataset. • User Experience: Clear visual cues (e.g., distinct bot and user message styling) enhance usability. • Testing: Extensivetestingofconversationflowsandedgecases(e.g.,empty inputs, inappropriate messages) is necessary to ensure reliability.

7 Conclusion

The PickARestaurant chatbot successfully achieves its objective of providing a user-friendly platform for restaurant discovery. By integrating Flask, OpenAI APIs, and a responsive frontend, it delivers a functional and engaging experience. Future improvements could include a more robust database, advanced NLP for handling ambiguous inputs, and enhanced session management for multiuser scenarios.

About

A small chatbot using openAI APIs and Flask suggest restaurants on user's choice(based on a kaggle dataset)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages