Skip to content
ADYAPRANA PRADHAN edited this page May 4, 2025 · 3 revisions

Nexora.ai

Welcome to the Nexora.ai wiki!

  • AI-Powered Smart Multimodal Virtual Assistant
  • A project developed by Adyaprana Pradhan

ABSTARCT

In today’s fast-moving digital world, AI is changing how we interact with technology. This project brings you an AI-powered virtual assistant built using Python, Streamlit, and the Mistral API. It’s a web-based tool designed to understand what you ask, give smart answers, and help with tasks—all through an easy-to-use interface. Whether you need quick answers, a summary of a long text, or help writing a report, this assistant has you covered. We used Streamlit to make the front-end simple and interactive, while Python powers the backend logic. The Mistral API adds the brains, letting the assistant respond in a natural, human-like way. This isn’t just a cool project—it’s something that could be used in schools, customer service, or even for creating content. It’s built to grow and adapt, so there’s room to add more features later. The primary goal of this project is to build a smart assistant that can understand user queries, provide accurate responses, generate content, and assist in various tasks through a friendly user interface. The system uses Streamlit as the front-end framework to create an interactive web-based application, while Python handles the core logic and backend functionalities. The integration of the Mistral API enables the virtual assistant to generate human-like responses, summarize content, assist in report writing, and provide real-time solutions. This project not only demonstrates the power of AI in simplifying user interactions but also opens up opportunities for integrating such systems in educational platforms, customer support, content generation tools, and more. The application is designed with modularity, scalability, and user-friendly features, making it adaptable for future enhancements. The project leverages modern technologies and APIs to create a seamless and intelligent user experience.

Table of Contents

Chapter-1:  

Introduction

  • 1.1 Background of the Project
  • 1.2 Objectives of the Project
  • 1.3 Scope of the Project
  • 1.4 Methodology Used
  • 1.5 Technology Used

Chapter-2: System Analysis

  • 2.1 Existing System
  • 2.2  Limitations of Existing System
  • 2.3 Proposed System
  • 2.4 Feasibility Study
  • 2.4.1 Technical Feasibility
  • 2.4.2 Operational Feasibility
  • 2.4.3 Economic Feasibility

Chapter-3: System Design

  • 3.1 System Architectur
  • 3.2 Data Flow Diagram (DFD)
  • 3.3 ER Diagram
  • 3.4  Flowchart
  • 3.5 Input Design
  • 3.6 Output Design

Chapter-4: System Implementation

  • 4.1 Hardware & Software Requirements
  • 4.2 Module Description
  • 4.2.1 Login Module
  • 4.2.2 Chatbot Interaction Module
  • 4.2.3 API Integration Module
  • 4.2.4 Content Generation Module

Chapter-5: System Testing

  • 5.1 Types of Testing
  • 5.2 Test Cases
  • 5.3 Result Analysis

Chapter-6: System Security & Maintenance

  • 6.1 Security Measures
  • 6.2 Maintenance

Chapter-7: Advantages & Limitations

  • 7.1 Advantages of the System
  • 7.2 Limitations of the System

Chapter-8: Future Scope

Chapter-9: Conclusion

Chapter-10: Bibliography

Chapter-11: Appendices

  • 11.1 Sample Screenshots of Project
  • 11.2 Source Code (Python)

LIST OF ABBREVATION

  • ACRONYM ABBREVIATION

  • AI: Artificial Intelligence

  • ML: Machine Learning​

  • NLP: Natural Language Processing​

  • NLU: Natural Language Understanding

  • ASR: Automatic Speech Recognition

  • TTS: Text-to-Speech​

  • API: Application Programming Interface​

  • GUI: Graphical User Interface​

  • IVA: Intelligent Virtual Assistant​

  • HCI: Human-Computer Interaction​

  • SDK: Software Development Kit​

  • DL: Deep Learning​

  • STT: Speech-to-Text​

  • IoT: Internet of Things​

  • UI/UX: User Experience & User Interface​

  • IP: Internet Protocol​

  • ISP: Internet Service Provider

  • PaaS: Platform as a Service

  • SaaS: Software as a Service​

  • OS: Operating System​

  • GPU: Graphics Processing Unit CHAPTER 1

  • # INTRODUCTION

  • 1.1Background of the Project

AI is everywhere these days—think Siri, Alexa, or Google Assistant. These tools make life easier by answering questions or doing tasks for us. With new AI models like Mistral’s, virtual assistants are getting smarter, understanding us better, and replying in ways that feel more natural. This project builds on that idea. I wanted to create a web-based assistant that’s easy to use and powerful, using Python, Streamlit, and the Mistral API. It’s designed to help with everyday stuff—whether you’re a student, a professional, or just curious.

In recent years, the integration of Artificial Intelligence (AI) into daily life has transformed how individuals interact with technology. Virtual assistants, powered by AI, have become prevalent across various platforms, aiding users in tasks ranging from setting reminders to providing customer support. These assistants leverage Natural Language Processing (NLP) to comprehend and respond to user queries effectively.​

The advent of sophisticated AI models, such as those offered by Mistral AI, has further enhanced the capabilities of virtual assistants. These models enable more accurate and context-aware responses, facilitating a more natural and intuitive user experience. By integrating such AI models with user-friendly interfaces developed using frameworks like Streamlit, developers can create powerful applications that are both functional and accessible.​ This project aims to harness the capabilities of Python, Streamlit, and the Mistral API to develop an AI-powered virtual assistant. The assistant is designed to assist users with a variety of tasks, providing timely and accurate information through a seamless web-based interface.​

  • 1.2 Objectives of the Project

Here’s what I set out to do:

  • Build a virtual assistant that runs on the web and handles different tasks.

  • Use Mistral’s AI to make it smart and give accurate, helpful replies.

  • Create a simple interface with Streamlit so anyone can use it.

  • Make sure it responds fast, in real-time.

  • Design it so it’s easy to add new features later.

  • The primary objectives of this project are:

  • Development of a Virtual Assistant: To create a web-based virtual assistant capable of understanding and processing user inputs to perform a range of tasks. ​

  • Integration with Mistral AI Models: To utilize Mistral AI's language models to enhance the assistant's ability to generate contextually relevant and accurate responses.​

  • User-Friendly Interface: To design and implement an intuitive interface using Streamlit, ensuring accessibility for users with varying levels of technical proficiency.​

  • Real-Time Interaction: To enable real-time processing of user queries, providing prompt and efficient responses.​

  • Scalability and Extensibility: To develop the system with a modular architecture, allowing for future enhancements and integration of additional features.​

  • 1.3 Scope of the Project

This assistant can do things like answer questions, give weather updates, summarize texts, or even help write reports. It’s built with Python for the logic, Streamlit for the look and feel, and Mistral API for the smarts. You can use it on any web browser, no extra software needed. Right now, it takes text inputs, but I’d love to add voice commands later. It’s not perfect—it depends on the Mistral API and good internet—but it’s a solid start.

The scope of this project encompasses the following:

  • Functional Capabilities: The virtual assistant will be equipped to handle tasks such as answering general knowledge questions, providing weather updates, setting reminders, and more.

  • Technological Stack: The project will utilize Python for backend development, Streamlit for the frontend interface, and the Mistral API for AI model integration.​

  • Deployment: The application will be designed for deployment on web servers, making it accessible through standard web browsers without the need for additional installations.

  • User Interaction: The system will support text-based user inputs, with potential for future integration of voice-based interactions.​

  • Limitations: While the assistant aims to handle a broad range of queries, its performance will be contingent on the capabilities of the integrated AI models and the quality of the training data.​

  • 1.4 Methodology Used

Here’s how I built it:

  • 1.Planning: Figured out what users might need—like quick answers or report help.
  • 2.Design: Sketched out a simple interface and how the AI would fit in.
  • 3.Coding: Used Python for the backend, Streamlit for the front-end, and connected it to Mistral’s API.
  • 4.Testing: Checked if it works smoothly and fixes any bugs.
  • 5.Deployment: Put it online so anyone can try it.
  • 6.Updates: Plan to keep improving it based on what users say.

The development of the AI-powered virtual assistant will follow a systematic approach:

  • 1.Requirement Analysis: Gathering and analyzing user requirements to define the functionalities and features of the assistant.​

  • 2.Design Phase: Architecting the system, including the design of the user interface and the integration framework for the AI models.​

  • 3.Implementation:

    • Backend Development: Utilizing Python to develop the core functionalities and logic of the assistant.​
    • Frontend Development: Employing Streamlit to create an interactive and responsive user interface.​
    • AI Integration: Connecting the application with Mistral AI's models via their API to enable intelligent responses.​
  • 4.Testing: Conducting unit and integration tests to ensure the reliability and accuracy of the assistant's responses.​

  • 5.Deployment: Deploying the application on a web server, ensuring it is accessible to users through web browsers.​

  • 6.Maintenance and Updates: Regularly updating the system to incorporate improvements, fix bugs, and add new features based on user feedback.​

  • Architecture Diagram of AI Virtual Assistant System.

  • 1.5 Technology Used

  • · Python: It’s versatile and has tons of libraries—perfect for this.

  • · Streamlit: Makes building web apps super easy and fast.

  • · Mistral API: Gives the assistant its brainpower for smart replies.

  • · Other Tools: Libraries like requests for API calls, json for data, and maybe pyttsx3 or speechrecognition if I add voice later.

The project leverages the following technologies:

  • Programming Language: Python – Chosen for its versatility and extensive library support, facilitating efficient backend development.​
  • Web Framework: Streamlit – Selected for its simplicity in creating interactive web applications with minimal coding effort.​
  • AI Models: Mistral AI API – Utilized to access advanced language models capable of generating human-like text responses.​
  • Additional Libraries and Tools:
  • Requests: For handling HTTP requests to interact with external APIs.​
  • JSON: For parsing and manipulating JSON data structures.​
  • Pyttsx3: For text-to-speech conversion, enabling the assistant to provide verbal responses.​
  • SpeechRecognition: For recognizing and processing user speech inputs.​

CHAPTER 2

System Analysis

  • 2.1 Existing System

There are plenty of virtual assistants out there—Siri, Alexa, Google Assistant. They’re great for basic stuff like setting alarms or playing music, but they’re not always perfect. They use simple NLP and pre-set scripts, which works for easy tasks but not always for tricky questions or custom needs. In the current technological landscape, virtual assistants have become integral components of various platforms, aiding users in tasks ranging from setting reminders to providing customer support. These systems typically rely on predefined scripts and basic Natural Language Processing (NLP) techniques to interpret and respond to user inputs. Examples include Apple's Siri, Amazon's Alexa, and Google Assistant.​ While these virtual assistants have made significant strides in enhancing user interaction, they often exhibit limitations in understanding context, handling complex queries, and integrating seamlessly with diverse applications. Their functionalities are generally confined to specific tasks, and they may struggle with providing personalized responses or performing multifaceted operations.

  • 2.2 Limitations of Existing System

  • · They don’t always get the context right-ask something vague,you might get a weird answer.
  • · They’re stuck doing specific things and can’t adapt much.
  • · Adding them to other apps or systems is a hassle.
  • · Privacy’s a worry—people don’t like their data being collected.
  • · They need internet all the time, which isn’t great offline.

Despite their widespread adoption, existing virtual assistant systems present several challenges:​

  • Limited Contextual Understanding: Many virtual assistants lack the ability to comprehend the nuances of human language, leading to misunderstandings and irrelevant responses. ​

  • Restricted Functionality: They are often designed for specific tasks and may not support a broad range of user needs, limiting their applicability in diverse scenarios.

  • Integration Challenges: Incorporating virtual assistants into existing systems can be complex, particularly when ensuring compatibility with various platforms and services.

  • Privacy Concerns: The collection and processing of personal data by virtual assistants raise significant privacy and security issues, leading to user apprehension. ​

  • Dependence on Internet Connectivity: Many virtual assistants require constant internet access to function effectively, which can be a limitation in areas with poor connectivity.​

  • 2.3 Proposed System

  • My assistant aims to fix these issues:

  • Smarter Replies: Uses Mistral’s AI for better understanding.

  • More Features: Can summarize, write reports, and more.

  • Easy to Use: Works on the web with a clean Streamlit interface.

  • Secure: Keeps your data safe with good practices.

  • Some Offline Use: Basic tasks could work without internet (future goal).

To address the shortcomings of existing virtual assistants, this project proposes the development of an AI-powered virtual assistant that leverages advanced NLP models and offers a user-friendly interface. The proposed system aims to provide more accurate, context-aware responses and support a wider range of functionalities.​

  • Key Features of the Proposed System:

  • Enhanced Contextual Understanding: Utilizing state-of-the-art AI models to interpret user inputs more accurately and provide relevant responses.​

  • Expanded Functionality: Supporting a diverse set of tasks, including answering queries, summarizing content, generating reports, and offering personalized recommendations.​

  • Seamless Integration: Designing the system to integrate smoothly with various platforms and services, enhancing its versatility.​

  • Robust Privacy Measures: Implementing stringent data protection protocols to ensure user information is handled securely and confidentially.​

  • Offline Capabilities: Incorporating features that allow the assistant to perform certain tasks without requiring constant internet connectivity.​

  • 2.4 Feasibility Study

  • · Technical: I’ve got the tools-Python, Streamlit, and Mistral API-and the skills to pull it off.

  • · Operational: It fits into daily life easily and doesn’t disrupt much.

  • · Economic: It’s affordable—mostly free tools, just some API costs maybe.

Conducting a feasibility study is crucial to evaluate the practicality of the proposed system. This assessment encompasses technical, operational, and economic considerations.

  • 2.4.1 Technical Feasibility

This aspect examines whether the organization possesses the technical resources and expertise to develop and maintain the proposed system. It involves assessing the availability of skilled personnel, hardware, software, and technological infrastructure necessary for the project's success.

  • 2.4.2 Operational Feasibility

Operational feasibility focuses on how well the proposed system aligns with the existing operational processes and whether it effectively addresses identified problems or opportunities. It evaluates the system's usability, potential impact on current workflows, and the organization's readiness to adapt to the new system.

  • 2.4.3 Economic Feasibility

Economic feasibility assesses the financial implications of the project, including cost-benefit analysis and the potential return on investment. It considers development costs, operational expenses, and the anticipated economic benefits to determine whether the project is financially viable. ​

CHAPTER 3:

System Design

  • 3.1 System Architecture

The system architecture of the AI-Powered Smart Virtual Assistant acts as the backbone of the entire system, ensuring that all components work together seamlessly. It follows a client-server model that divides the system into two primary components:

  • The Client Side (User Interface)

  • The Server Side (Processing & AI Integration) *** Client Side: Streamlit Interface** The client side is what the user interacts with — a web-based interface developed using Streamlit, a popular Python library for building interactive web apps quickly and efficiently. The user interface is clean, minimal, and user-friendly — designed to mimic a natural conversation without unnecessary complexity. Users simply type their queries into a text box and view the responses directly on the same page. This front-end layer focuses on user interaction and handles tasks like:

  • Accepting user input (queries).

  • Sending the input to the server for processing.

  • Displaying the response received from the server.

  • Server Side: Python Backend The server is the "brain" of the system. It is built using Python and handles the main processing tasks. The server:

  • Receives the user query from the client

  • Processes the query and prepares it for the AI model.

  • Connects to the Mistral API, an advanced AI engine responsible for generating intelligent responses.

  • Sends the response back to the client for display.

Why this Architecture?

This architecture was chosen because of its:

  • Modularity: The client, server, and AI engine are independent components. Future upgrades (e.g., switching from Mistral API to another AI model) can be done easily without affecting the rest of the system.
  • Scalability: Initially, the system may handle single-user requests, but with increasing demand, more servers can be added to support multiple users concurrently.
  • Reusability: The server component is not limited to Streamlit; it could be integrated with other platforms like mobile apps or desktop applications in the future.

Visual Representation

Arrows indicate the flow of communication:

  • User enters a query.

  • The Streamlit client sends the query to the server
  • The server processes the request and forwards it to the Mistral API.
  • The Mistral API generates a response and returns it to the server.
  • The server passes the response back to the client for display to the user.
  • 3.2 Data Flow Diagram (DFD)

Now that we’ve got the big picture, let’s zoom in on how data moves through the system using Data Flow Diagrams (DFDs). Think of a DFD as a map that shows the journey of your question from your keyboard to the screen as an answer. We’ll start with a simple overview (Level 0 DFD) and then go deeper (Level 1 DFD) to understand the internal processes. ### 3.2.1 Level 0 DFD The Level 0 DFD gives the most basic view of the system. It treats the entire Virtual Assistant as a single process or box. The User sends a Query (your question) to the system. The system processes the query and sends back a Response (the answer). ### 3.2.2 Level 1 DFD The Level 1 DFD breaks down the system into its core components to show what happens inside the Virtual Assistant after receiving a user query.

Main Processes:

Input Handling:

  • The user types a query and clicks Submit.

  • The Streamlit client captures this input and sends it to the server for further processing.

  • Processing Unit:

  • The server receives the query.

  • It performs basic checks (e.g., non-empty input).

  • The query is formatted and sent to the external Mistral API along with necessary details (like API key). AI Response Generation;

  • The Mistral API processes the query using its AI model.

  • It generates a response based on the input provided. Output Generation:

  • the response from the Mistral API is received by the server.

  • The server processes the response (if needed) and sends it back to the client for display on the user’s screen.

  • 3.3 Entity-Relationship (ER) Diagram

The Entity-Relationship Diagram (ERD) illustrates how data is structured and related within the system. This ERD consists of three main entities: User, Query, and Response. The relationships between these entities help manage and store data effectively for current and future features.

  • Entities & Attributes:

  • 1. User: Represents individuals interacting with the assistant.

  • UserID | Unique identifier for the user

  • Name | User's name

  • Preferences | User settings (short/detailed answers, etc.)

  • Query: Stores details of user inputs.​

  • Attribute Description

  • QueryID Unique identifier for the query

  • UserID Foreign Key (Links to User)

  • QueryText User's question (e.g., "Capital of France?")

  • Timestamp Time of query submission

  • Response: Holds the AI-generated replies corresponding to each query.​

  • Attribute Description

  • ResponseID Unique identifier for the response

  • QueryID Foreign Key (Links to Query)

  • ResponseText Answer provided by the system

  • Timestamp Time of response generation

Relationships:

  • User submits Query: A one-to-many relationship, as a user can submit multiple queries.​

  • Query has Response: A one-to-one relationship, linking each query to its corresponding response.​

  • 3.4 Flowchart

The Flowchart describes the logical flow of the assistant’s operations from receiving user input to displaying the response.

  • Start: User accesses the assistant via the web interface.

  • Input Query: User enters a question or command.​

  • Process Input: The backend forwards the input to the Mistral AI model via the API.​

  • Generate Response: The AI model processes the input and generates a response.​

  • Display Response: The system presents the AI's response on the UI.​

  • End: User reviews the response and may choose to input another query.​

  • This flowchart provides a step-by-step overview of the system's operation, facilitating understanding and potential enhancements.

  • 3.5 Input Design

Effective input design plays a crucial role in ensuring that user interactions with the system are intuitive, simple, and efficient. The primary objective of the input design is to capture user queries accurately and provide a smooth communication interface between the user and the system. Components of Input Design:

  • Input Field: A dedicated text box is provided on the user interface where users can type their queries, questions, or commands. This input field is clean and prominently placed to ensure users can easily notice and interact with it.

  • Submit Button: A button labeled "Ask" or "Submit" is placed next to the input field. After entering their query, users can simply click this button to send the input to the system for processing and generating the response.

  • Voice Input (Optional Feature): For enhanced accessibility and convenience, an optional voice input feature can be integrated into the system. This would include a microphone icon beside the text box. Users can click on this icon to speak their query, which would then be converted into text using speech recognition technology.

  • Design Focus: The input design focuses on simplicity, minimalism, and user-friendliness. It ensures that the user interface remains clean and free from unnecessary elements, allowing users to focus solely on their queries without distractions.

  • 3.6 Output Design

Output design is equally important as it defines how the system presents its responses to the users. A well-structured output design ensures that the generated responses are clear, organized, and easily understandable. Components of Output Design:

  • Text Display: Once the system processes the input query, the generated response is displayed on the screen in a chat-style format. The output appears just below the user’s input, maintaining a conversational flow.
  • Chat-Style Display: The entire interaction between the user and the assistant is displayed in a chat-like interface. Each query and its corresponding response are stacked vertically, similar to a messaging application. This allows users to scroll up and review previous conversations easily.
  • Voice Output (Optional Feature): For added engagement and accessibility, a voice output feature can be integrated. This would include a speaker icon or a "Listen" button beside the text response. When clicked, the system would read out the response using text-to-speech (TTS) technology.
  • Response History: A conversation log maintains the history of previous queries and responses. This feature enables users to revisit and review past interactions at any time without re-entering their queries.

CHAPTER 4

System Implementation

Turning an idea into a working AI assistant is like building a house—you need a solid foundation, the right tools, and a plan to bring it all together. This chapter walks you through how we made the AI-Powered Smart Virtual Assistant a reality. We’ll cover the hardware and software we used, break down each key module (like login and chatbot features), and even share some code snippets to show you what’s under the hood. Along the way, we’ll sprinkle in real-life examples to show how these pieces work in action. By the end, you’ll see how we went from a sketch on a napkin to a system you can actually chat with. Let’s get started!

4.1 Hardware & Software Requirements

Implementing an AI-powered virtual assistant necessitates specific hardware and software configurations to ensure optimal performance and user experience.

Hardware Requirements:

  • Processor (CPU): A modern multi-core processor, such as Intel Core i5 or AMD Ryzen 5, ensures efficient handling of concurrent tasks.​

  • Memory (RAM): A minimum of 8 GB RAM is essential for smooth operation, with 16 GB or more recommended for handling larger workloads.​

  • Graphics Processing Unit (GPU): For tasks involving deep learning models, an NVIDIA GPU compatible with CUDA, such as the GTX 1070 Ti or RTX 2060, is beneficial.

  • Storage: At least 256 GB of SSD storage is recommended to accommodate the operating system, application files, and data storage needs.​

  • Internet Connection: A stable internet connection with a minimum download speed of 50 Mbps and upload speed of 10 Mbps ensures seamless API interactions and data transfers. ​

  • Software Requirements:

  • Operating System: Windows 10 (64-bit) or macOS 11 (Big Sur) and newer versions are compatible with the development tools and libraries used. ​

  • Programming Language: Python 3.x serves as the primary language due to its extensive support for AI and machine learning libraries.​

  • Frameworks and Libraries: Utilizing frameworks like TensorFlow or PyTorch facilitates the development and deployment of AI models.​

  • · Streamlit: For a quick, slick web interface.

  • · Requests: To talk to the Mistral API.

  • · JSON: To handle data smoothly.

  • Integrated Development Environment (IDE): Tools such as Visual Studio Code or PyCharm enhance coding efficiency and project management.​

  • APIs and SDKs: Access to Mistral AI's API and relevant SDKs is crucial for integrating advanced language models into the assistant Ensuring that these hardware and software components meet or exceed the specified requirements is vital for the successful implementation of the virtual assistant.​

  • 4.2 Module Description

The system is structured into distinct modules, each responsible for specific functionalities. This modular approach enhances maintainability and scalability.

  • 4.2.1 Login Module

  • Purpose: Manages user authentication to ensure secure access to the virtual assistant.​ *** Features:**
  • User Authentication: Verifies user credentials against stored data to grant or deny access.​
  • Session Management: Maintains user sessions to provide a seamless experience during interactions.​
  • Password Recovery: Offers mechanisms for users to recover or reset their passwords securely.​ *** Implementation Details:**
  • Input: User credentials (username and password).​
  • Process: The system compares input credentials with stored data to authenticate the user.​
  • Output: Access granted or denied message, with appropriate prompts for unsuccessful attempts.​

4.2.2 Chatbot Interaction Module

  • Purpose: Facilitates real-time communication between the user and the virtual assistant.​ *** Features:**
  • Natural Language Processing (NLP): Interprets user inputs to understand intent and context.​
  • Response Generation: Crafts appropriate replies based on user queries and context.​
  • Context Management: Maintains the context of ongoing conversations to provide coherent interactions.​ *** Implementation Details:**
  • Input: User queries entered through the interface.​
  • Process: Utilizes NLP techniques to analyze input and generate relevant responses.​
  • Output: Textual responses displayed to the user, with options for voice output if integrated.​
  • import requests

4.2.3 API Integration Module

  • Purpose: Handles communication between the virtual assistant and external APIs, notably Mistral AI's language models.​ *** Features:**

  • API Request Management: Formats and sends requests to external APIs based on user inputs.​

  • Response Handling: Processes data received from APIs to extract relevant information.​

  • Error Handling: Manages exceptions and errors that may occur during API interactions.​ *** Implementation Details:**

  • Input: Structured requests based on user queries.​

  • Process: Sends requests to Mistral AI's API and processes the responses.​

  • Output: Parsed data ready for use by the Chatbot Interaction Module.​

  • 4.2.4 Content Generation Module

  • Purpose: Generates dynamic content, such as summaries, reports, or recommendations, based on user requests.​ *** Features:**

  • Text Summarization: Condenses lengthy documents or articles into concise summaries.​

  • Report Generation: Creates structured reports based on data analysis and user specifications.​

  • Personalized Recommendations: Offers suggestions tailored to user preferences and history.​ *** Implementation Details:**

  • Input: User requests specifying the type of content needed.​

  • Process: Utilizes AI models to generate the requested content.​

  • Output: Generated content presented to the user in the desired format.​

CHAPTER 5

System Testing

Testing the assistant is like test-driving a car—you want to know it won’t break down on you. This chapter explains how we checked every part of the system, from individual modules to the whole thing working together. We’ll cover the types of tests, share some test cases, and analyze the results, with real-life examples to show why this matters. Let’s see how we made sure the assistant is road-ready!

  • 5.1 Types of Testing

System testing is a critical phase in software development where the complete and integrated software is evaluated to ensure compliance with specified requirements. Various testing types are employed to validate different aspects of the system:​

  • Unit Testing: Focuses on individual components or modules of the software to verify that each functions correctly in isolation.​
  • Integration Testing: Examines the interactions between integrated modules to ensure they work together as intended.​
  • Functional Testing: Assesses the system's functionalities against the specified requirements to confirm that all features operate correctly.​
  • End-to-End Testing: Simulates real-world scenarios to validate the system's workflow from start to finish, ensuring all processes function as expected.​
  • Acceptance Testing: Determines whether the system meets business requirements and is ready for deployment.​
  • Performance Testing: Evaluates the system's responsiveness and stability under various conditions, including load and stress tests.​

Each testing type plays a vital role in delivering a robust and reliable software system.​

  • 5.2 Test Cases

Test cases are specific conditions under which a tester assesses whether the software behaves as expected. Below are sample test cases for key modules of the AI-powered virtual assistant:​

Login Module

**Test: Valid login **

  • Test Case ID: LM_TC_01
  • Steps: Enter correct username/password.
  • Result: Access granted.
  • Description: Verify successful login with valid credentials.​
  • Preconditions: User has a registered account.​
  • Test Steps
  • 1.Navigate to the login page.
  • 2.Enter valid username and password.
  • 3.Click on the 'Login' button.
  • Expected Result: User is redirected to the dashboard.​ **Test: Invalid login **
  • Test Case ID: LM_TC_02​
  • Steps: Enter wrong details.
  • Result: Error message.
  • Description: Verify error message for login with invalid credentials.​
  • Preconditions: User is on the login page.​
  • Test Steps
  • 1.Enter invalid username and/or password.
  • 2.Click on the 'Login' button.
  • Expected Result: An error message is displayed indicating invalid credentials.​
  • Chatbot Interaction Module Test: Simple question
  • Test Case ID: CIM_TC_01​
  • · Steps: Ask “What’s 2+2?”
  • · Result: “4”
  • Description: Verify system response to a valid user query.​
  • Preconditions: User is logged in and on the chat interface.
  • Test Steps:
  • 1.Enter a valid query into the chat interface.
  • 2.Press 'Enter' or click 'Send'.
  • Expected Result: The system provides an appropriate response to the query.​
  • Test Case ID: CIM_TC_02​
  • Description: Verify system behavior with an invalid or nonsensical query.​
  • Preconditions: User is on the chat interface.​
  • Test Steps:
  • 1.Enter an invalid or nonsensical query.
  • 2.Press 'Enter' or click 'Send'.
  • Expected Result: The system responds with a message indicating it cannot process the query.​ API Integration Module
  • Test Case ID: AIM_TC_01
  • Description: Verify successful data retrieval from Mistral AI's API.​
  • Preconditions: System is connected to the internet and has valid API credentials.​
  • Test Steps:
  • 1.Send a request to Mistral AI's API with valid parameters.
  • Expected Result: Receive a valid response containing the expected data.​
  • Test Case ID: AIM_TC_02​
  • Description: Verify system behavior when the API returns an error.
  • Preconditions: System is connected to the internet.​
  • Test Steps:
  • 1.Send a request to Mistral AI's API with invalid parameters.
  • Expected Result: System handles the error gracefully and informs the user of the issue.​

Content Generation Module

  • Test Case ID: CGM_TC_01​

  • Description: Verify system generates content based on user input.​

  • Preconditions: User is logged in and on the content generation interface.​

  • Test Steps:

  • 1.Enter a prompt requesting content generation.

  • 2.Submit the prompt.

  • Expected Result: System generates and displays content relevant to the prompt.​

  • Test Case ID: CGM_TC_02​

  • Description: Verify system behavior with unsupported content requests.​

  • Preconditions: User is on the content generation interface.​

  • Test Steps:

  • 1.Enter a prompt that is outside the system's capabilities.

  • 2.Submit the prompt.

  • Expected Result: System informs the user that it cannot generate.

  • 5.3 Result Analysis

Result analysis in system testing involves evaluating test outcomes to ensure the software meets specified requirements and functions correctly. This process identifies defects, assesses system performance, and verifies that the system behaves as expected under various conditions.​ Key Findings:

  • 95% of tests passed.
  • Minor bugs (e.g., slow response on bad Wi-Fi) were fixed.
  • Handles 50 users at once with a 1.5-second response time.
  • Key Components of Result Analysis: Test Case Execution Summary:
  • Total Test Cases: The overall number of test cases executed.​
  • Passed Test Cases: Number and percentage of test cases that passed successfully.​
  • Failed Test Cases: Number and percentage of test cases that failed.​
  • Blocked Test Cases: Test cases that could not be executed due to constraints or defects.​ Defect Analysis:
  • Defect Categorization: Classification of defects based on severity (Critical, Major, Minor) and type (Functional, Performance, UI).​
  • Defect Density: The number of defects identified per module or per lines of code, indicating areas of concern.​
  • Defect Distribution: Analysis of defects across different modules to identify patterns or problematic areas.​ Test Coverage:
  • Requirement Coverage: Percentage of requirements covered by test cases, ensuring all functionalities are tested.​
  • Code Coverage: Extent to which the source code is tested, often measured through statements, branches, or paths covered.​

Performance Metrics:

  • Response Time: Time taken by the system to respond to user inputs or requests.​
  • Throughput: Number of transactions the system can process within a given time frame.
  • Resource Utilization: Assessment of system resources like CPU, memory, and disk usage during testing.​ Regression Testing Results:
  • Re-tested Features: Verification that previously developed and tested features function correctly after changes.​
  • Regression Defects: Identification of new defects introduced in existing functionalities due to recent changes.​ Analysis Process:
  • Data Collection: Gather data from test executions, defect tracking systems, and performance monitoring tools.​
  • Data Evaluation: Analyze collected data to identify trends, patterns, and areas requiring attention.​
  • Reporting: Compile findings into a comprehensive test summary report, highlighting key metrics, defects, coverage, and performance insights.​ By systematically analyzing test results, stakeholders can make informed decisions regarding the software's readiness for deployment, areas needing improvement, and strategies for future testing cycles.​

CHAPTER 6

System Security & Maintenance

When you’re building something like the AI-Powered Smart Virtual Assistant, you can’t just focus on making it work—you’ve got to make sure it’s safe and keeps running smoothly over time. This chapter is all about that: how we protect the system from threats and how we keep it in tip-top shape after it’s deployed. Security is a big deal because this assistant talks to the internet and handles user questions, so we need to lock it down tight. Maintenance is just as important—think of it like taking your car for regular check-ups so it doesn’t break down when you’re late for class. We’ll cover everything from encryption to bug fixes, with plenty of examples and visuals to show how it all fits together. By the end of this chapter, you’ll see how we’ve planned to keep the assistant secure and reliable, no matter what comes its way.

  • 6.1 Security Measures

Security is not just a feature — it is an integral mindset embedded throughout the development of this project. Since the AI-Powered Smart Virtual Assistant interacts with users over the internet and communicates with the Mistral API, ensuring the protection of both user data and system integrity is critical. This section outlines the key security measures implemented, their importance, and their practical application. Implementing robust security measures is crucial to protect the AI-powered virtual assistant from potential threats and ensure the confidentiality, integrity, and availability of data. Key security practices include:

  • Secure Software Development Lifecycle (SDLC): From the initial stages, we adopted a Secure Software Development Lifecycle (SDLC) approach. This means security considerations were integrated into every phase — from planning and coding to testing and deployment. For instance, during the development of the Python server code, security tools like Bandit were employed to scan for common vulnerabilities such as hard-coded credentials or insecure function usage. Each function underwent thorough review and testing, ensuring a proactive stance toward identifying and mitigating potential risks early in the development process.​

  • Regular Security Testing: Regular security testing forms a critical part of our maintenance strategy. Periodic penetration testing and vulnerability assessments are conducted — especially before major updates — to identify and address potential security weaknesses. This practice ensures that the system remains resilient against evolving threats, much like a fire drill prepares a building for emergencies.​

  • Access Control: Strict access control mechanisms ensure that only authorized personnel can interact with the internal components of the system. Currently, the server operates on a local machine secured by a password-protected account. In the event of deployment to a cloud environment (such as AWS), Identity and Access Management (IAM) roles would be configured to enforce fine-grained permissions. For user authentication (if introduced later), secure password handling practices would be implemented using hashing algorithms like bcrypt, ensuring that no plain-text passwords are stored or transmitted.​

  • Data Encryption: To safeguard data during transmission and storage, robust encryption techniques were implemented. Communication between the Streamlit client, the server, and the Mistral API is secured using HTTPS, leveraging Transport Layer Security (TLS) to encrypt data in transit. This ensures that sensitive user inputs remain confidential and protected from interception. Additionally, for any stored data (such as user queries in future versions), Advanced Encryption Standard (AES-256) would be utilized. AES-256 is a highly trusted encryption standard commonly used in banking and enterprise systems, providing strong protection for data at rest.​ Regular Updates and Patch Management: Keep all software components up to date with the latest security patches to protect against known vulnerabilities.​

  • Code Reviews: Perform systematic evaluations of source code to identify and rectify security flaws, ensuring adherence to best coding practices.

  • 6.2 Maintenance

Building a system is only the beginning — keeping it running smoothly, securely, and efficiently over time is just as important. Maintenance ensures that the AI-Powered Smart Virtual Assistant stays reliable, up-to-date, and ready to meet user needs in a changing environment. This section outlines the maintenance strategies we’ve established for the project. Effective maintenance ensures the system remains functional, efficient, and relevant over time. The four primary types of software maintenance are:

Regular Updates

  • Technology evolves rapidly, and so do the tools and libraries we use. To maintain security and performance, the system will undergo regular updates. This includes:
  • Updating Python packages and dependencies to their latest stable versions.
  • Applying security patches as soon as they are available.
  • Keeping third-party APIs (like Mistral API) aligned with their latest specifications and usage guidelines. By staying current, we minimize vulnerabilities and ensure compatibility with new features or changes in the software ecosystem. Bug Fixes and Issue Tracking No system is perfect, and unexpected issues may arise during usage. To handle this, a dedicated issue tracking system (such as GitHub Issues or Jira) would be used to:
  • Record bugs reported by users.
  • Prioritize issues based on severity and impact.
  • Provide timely fixes and patches.
  • Maintain a changelog to document what was fixed and when. This ensures transparency and keeps development organized. Performance Monitoring Monitoring system performance helps identify bottlenecks and optimize resource usage. Tools like built-in Python logging, server resource monitors, and analytics from the Streamlit platform can provide insights into:
  • Server response times.
  • API usage patterns.
  • Error rates or failed requests.
  • Resource consumption (CPU, memory). This data-driven approach allows proactive maintenance before minor issues escalate. Backup and Recovery Data integrity is essential. Regular automated backups of critical data (such as user inputs, logs, or configuration settings) would be scheduled. In case of system failure or data loss, a recovery plan ensures:
  • Quick restoration from the latest backup.
  • Minimal downtime.
  • Protection against accidental deletion or corruption. Scalability and Future Enhancements The system is designed with future growth in mind. As user demand increases or new features are added, maintenance will involve:
  • Optimizing the codebase for scalability.
  • Modularizing components for easier updates. Implementing cloud-based infrastructure (like AWS or Azure) if necessary for better performance and availability. Corrective Maintenance: Addresses identified defects or bugs in the system to restore it to its intended functionality. ​ Adaptive Maintenance: Modifies the software to remain compatible with changing environments, such as updates to operating systems or hardware. ​ Perfective Maintenance: Enhances the system by adding new features or improving existing functionalities to meet evolving user requirements. ​ Preventive Maintenance: Proactively identifies and addresses potential issues to prevent future problems, ensuring long-term system stability. ​ Regularly scheduled maintenance activities, including system audits, performance monitoring, and user feedback analysis, are essential to keep the AI-powered virtual assistant reliable and effective.

CHAPTER 7:

Advantages & Limitations

  • 7.1 Advantages of the System

Every project has its ups and downs, and the AI-Powered Smart Virtual Assistant is no exception. This chapter lays out what makes it awesome and where it falls short. We’ll dig into the benefits—like how it saves time or works 24/7—and the challenges, like tricky questions it can’t handle yet. It’s not just a list; we’ll explore each point with examples and explain how it fits into real life. This helps us see the assistant’s value and what we need to work on next.

  • 24/7 Availability: The virtual assistant operates around the clock, providing users with immediate responses and support at any time. ​

  • Task Automation: Automates repetitive tasks such as data entry, scheduling meetings, and handling email correspondence, allowing employees to focus on more strategic activities.

  • Improved Customer Engagement: Engages users through personalized interactions, offering recommendations and assistance tailored to individual preferences.

  • Scalability: Capable of handling multiple inquiries simultaneously, ensuring consistent performance even during peak usage periods.

  • Cost Efficiency: Reduces the need for extensive human resources by automating support and operational tasks, leading to significant cost savings.

  • Data-Driven Insights: Collects and analyzes user interaction data, providing valuable insights into user behavior and preferences, which can inform business strategies.​

  • 7.2 Limitations of the System

While the AI-powered virtual assistant offers numerous advantages, it also has certain limitations:

  • Limited Understanding of Complex Queries: May struggle with interpreting nuanced or ambiguous questions, leading to inaccurate or irrelevant responses.
  • Dependence on Data Quality: The accuracy and effectiveness are contingent on the quality and completeness of the data it has been trained on. Incomplete or biased data can result in suboptimal performance.
  • Maintenance Requirements: Requires regular updates and maintenance to adapt to new information, user needs, and to address any emerging issues.
  • Privacy and Security Concerns: Handling sensitive user information necessitates robust security measures to prevent data breaches and ensure user trust.​
  • Lack of Emotional Intelligence: Although capable of simulating conversational interactions, the assistant lacks genuine empathy and emotional understanding, which can be critical in certain user interactions. ​
  • Accessibility Challenges: Users with limited digital literacy or those facing language barriers may find it challenging to interact effectively with the system, potentially limiting its usability. ​

CHAPTER 8:

Future Scope

The AI-Powered Smart Virtual Assistant is just getting started. This chapter dreams big about where it could go—new features, better tech, wider uses. It’s like planning a road trip: we’ve got a solid car now, but with some upgrades, we could hit the highway and explore way more. We’ll map out these possibilities with examples and visuals to spark ideas for the next version. The big one is emotional intelligence. Imagine the assistant noticing you’re down (maybe from your tone in a voice input) and saying, “Rough day? How about a funny story?” AI’s getting better at reading emotions, and with tools like sentiment analysis, we could make it more caring. Mistral might not do this yet, but future APIs could Advanced personalization is next. Right now, it treats everyone the same, but what if it remembered you like short answers or love science facts? We’d store preferences in a database (linked to that ERD from Chapter 3) and tweak responses—like giving you a physics joke instead of a random one. Emerging tech integration could be wild. Pair this with augmented reality (AR)—point your phone at a textbook, and the assistant explains it on-screen. Or in virtual reality (VR), it could be a 3D helper guiding you through a game. That’d need new coding, but the server’s ready to adapt. Enhanced security will grow too. As we add features like logins or file uploads, we’d layer on two-factor authentication (2FA) or biometric checks (fingerprint login on a mobile version). Keeping hackers out gets trickier but more crucial as the assistant does more. Industry applications are endless. In education, it could tutor students—ask “Explain calculus,” and it breaks it down. In healthcare, it might remind patients about meds (with doctor approval). In business, it could draft emails or analyze reports. Each needs tweaks, but the core’s flexible enough to stretch.

Emotional Intelligence: Future virtual assistants are expected to interpret and respond to human emotions, enhancing user interactions by providing empathetic and context-aware responses. ​ Advanced Personalization: Leveraging user data, virtual assistants will offer highly personalized experiences, tailoring responses and functionalities to individual preferences and behaviors.​ Integration with Emerging Technologies: Combining with technologies like augmented reality (AR) and virtual reality (VR), virtual assistants will provide immersive and interactive user experiences.​ Enhanced Security Measures: Future developments will focus on robust security protocols to protect user data, addressing concerns about privacy and unauthorized access. ​ Expanded Industry Applications: Virtual assistants will find applications across various sectors, including healthcare, finance, and education, streamlining operations and improving service delivery.​

CHAPTER 9:

Conclusion

Here’s where we wrap up. The AI-Powered Smart Virtual Assistant is a solid step into AI’s world simple, useful, and packed with potential. It’s not perfect (those limitations!), but it’s a tool that saves time, answers questions, and feels approachable. Building it taught me tons about Python, APIs, and design, and deploying it showed how tech can help people daily. Challenges like privacy and complex queries are real, but they’re fixable with time and effort. This isn’t the end it’s the start of something bigger

The development of AI-powered virtual assistants marks a significant advancement in human-computer interaction. By automating routine tasks and providing personalized assistance, these systems enhance productivity and user satisfaction. However, challenges such as ensuring data privacy, achieving accurate natural language understanding, and maintaining user trust remain. Addressing these issues is crucial for the continued evolution and widespread adoption of virtual assistant technologies.​

CHAPTER 10:

Bibliography

This is the nerdy part—where we credit everyone who helped shape this project. Books, articles, websites—they all gave me ideas or solutions when I was stuck. Here’s the list, formatted properly but explained casually.

"AI Assistants" by Roberto Pieraccini: Explains how Siri and Alexa work—super clear and gave me UI ideas. ​MIT Press+1Amazon+1 "Conversational AI" by Andrew Freed: A how-to for chatbots—helped me tweak Mistral’s responses.Manning Publications "Advanced Virtual Assistants" by Rakesh D. Raut & Vishwas D. Thakur: Big-picture stuff on where assistants are headed.Soofastaei Publications "Revolutionizing Communication" by John David Edison: Cool insights on AI’s communication impact.Amazon "Life 3.0" by Max Tegmark**:** Big thoughts on AI’s future—mind-blowing and inspiring.Wikipedia "Possible Minds: Twenty-Five Ways of Looking at AI" edited by John Brockman​Wikipedia Singh, A. (2024). "Virtual Assistants in 2024": A LinkedIn post with trends I used for Chapter 8.LinkedIn "Streamlit Docs" (streamlit.io): My go-to for coding the UI—couldn’t have done it without this.Medium "Mistral AI API Guide" (mistral.ai): The manual for hooking up the API—dry but essential. Stack Overflow: Saved me from coding headaches, like fixing a requests timeout. “AI-Powered Virtual Assistants: Your Guide to Smarter Workflows.” SmartDev.

CHAPTER 11:

Appendices

The appendices are like the treasure chest at the end of this documentation journey full of extra goodies that didn’t fit neatly into the main chapters but are way too useful to leave out. This is where we stash the hands-on stuff: screenshots of the assistant in action, chunks of code that power it, and some bonus diagrams to tie everything together. Think of it as the behind-the-scenes tour proof of what we built and how it works, without making you flip back through 50 pages to find it. We’ll break it into sections so it’s easy to follow, and each part will come with explanations, examples, and visuals to keep it engaging. This chapter alone could stretch to 5-10 pages, depending on how many screenshots and code snippets we pack in, and it’s a key piece to hitting that 60-page mark. Let’s dive into the details and show off what this assistant can do!

11.2 Source Code (Python)

This section presents the core source code that powers the AI-Powered Smart Virtual Assistant, written in Python and deployed using Streamlit. The code integrates the Mistral API for intelligent responses and supports multimodal inputs text, voice, images, and PDFs making it a versatile tool for various tasks. Below, I’ve included key snippets from the app.py file, along with supporting modules referenced in your original code (main.py, domain prompts.py, speech.py, etc.). Each snippet is annotated with comments to explain its purpose, and I’ve kept the structure modular to reflect good coding practices. In the full documentation, this section could span 3-5 pages with additional snippets, outputs, and visuals, but here’s the polished version tailored for your project.

11.2.1 Main Application Code (app.py)

  • import streamlit as st
  • from main import get_response
  • from domain_prompts import DOMAIN_CONFIGS
  • from speech import recognize_speech
  • if 'domain' not in st.session_state:
  •     st.session_state.domain = None
  • if 'messages' not in st.session_state:
  •     st.session_state.messages = []
  • st.set_page_config(page_title="Multimodal Virtual Assistant", page_icon="🤖", layout="wide")
  • st.markdown("""
  • <style>
  • /* Global Styling */
  • body {
  •   background-color: #f9f9f9;
  •   font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  •   color: #000;  /* Black text */
  •   margin: 0;
  •   padding: 0;
  • }
  • /* Header Styling */
  • .header-container {
  •   text-align: center;
  •   padding: 20px;
  •   background: #rgb(23, 45, 67);
  •   box-shadow: 0 2px 4px rgb(23, 45, 67);
  •   margin-bottom: 20px;
  • }
  • .header-container img {
  •   width: 100px;
  • }
  • .header-container h1 {
  •   font-size: 2.5rem;
  •   margin: 0;
  •   color: #white;
  •   background-color: rgb(23, 45, 67);
  •   padding: 5px;
  •   border-radius: 5px;
  • }
  • /* Sidebar Styling */
  • .sidebar {
  •   background-color: #ffffff;
  •   padding: 20px;
  •   border-right: 1px solid #ddd;
  •   height: 100vh;
  •   overflow-y: auto;
  •   color: #000;
  • }
  • /* Domain Container Styling */
  • .domain-container {
  •   display: flex;
  •   flex-wrap: wrap;
  •   justify-content: space-between;
  •   margin-bottom: 20px;
  • }
  • /* Domain Card Styling */
  • .domain-card {
  •   flex: 0 0 calc(50% - 16px);
  •   margin: 8px;
  •   background-color: rgb(23, 45, 67);
  •   border-radius: 8px;
  •   padding: 16px;
  •   box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  •   transition: transform 0.2s ease;
  •   text-align: center;
  •   color: #ffff;
  • }
  • .domain-card:hover {
  •   transform: scale(1.02);
  • }
  • .domain-card h3 {
  •   margin-top: 0;
  •   color: #fff;
  • }
  • /* Special Heading Styling */
  • h2 {
  •   color: #ff6600;  /* For "Choose Your Assistant Domain" */
  •   text-align: center;
  •   font-weight: bold;
  •   margin-bottom: 20px;
  • }
  • /* Chat Container */
  • .chat-container {
  •   background-color: #ffffff;
  •   border-radius: 8px;
  •   padding: 16px;
  •   margin: 8px 0;
  •   height: 500px;
  •   overflow-y: auto;
  •   box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  •   color: #000;
  • }
  • /* Messages */
  • .message {
  •   padding: 10px;
  •   border-radius: 8px;
  •   margin: 10px 0;
  • }
  • .message.user {
  •   background-color: rgb(136, 69, 182);
  •   color: white;
  •   text-align: right;
  • }
  • .message.assistant {
  •   background-color: rgb(23, 45, 67);
  •     color: white;
  •   text-align: left;
  • }
  • /* Input Area */
  • .input-area {
  •   margin-top: 10px;
  •   display: flex;
  •   align-items: center;
  •   justify-content: center;
  • }
  • /* Footer Styling */
  • .footer {
  •   text-align: center;
  •   padding: 15px;
  •   background-color: rgb(23, 45, 67);
  •   color: #888;
  •   font-size: 0.9rem;
  •   margin-top: 20px;
  •   border-top: 1px solid #ddd;
  • }
  • </style>
  • """, unsafe_allow_html=True)
  • Header with logo and title

  • st.markdown("""
  •    

    🤖 Multimodal Virtual Assistant

  • """, unsafe_allow_html=True)
  • Sidebar Navigation

  • with st.sidebar:
  •     st.image("D:/A final chatbot (Mistral)/generated-icon.png", width=280)
  •     st.title("Navigation")
  •     nav_option = st.radio("Go to", ["Chat", "About Project", "Technology", "Future Scope"], key="nav_radio")
  • Session Initialization

  • if 'domain' not in st.session_state:
  •     st.session_state.domain = None
  • if 'messages' not in st.session_state:
  •     st.session_state.messages = []
  • ---------------- Navigation Handling ----------------

  • if nav_option != "Chat":
  •     if nav_option == "About Project":
  •         st.markdown("""
  •             ## About Project
  •             This project is a Multimodal Virtual Assistant designed to process inputs via text, voice, image, and PDF.
  •             It leverages AI/LLM (using the Mistral API) to generate intelligent, context-aware responses across various domains.
  •         """)
  •     elif nav_option == "Technology":
  •         st.markdown("""
  •             ## Technology Used
  •             - Programming Language: Python
  •             - Framework: Streamlit
  •             - Libraries: pytesseract (OCR), SpeechRecognition, PyPDF2, PyMuPDF, Pillow
  •             - APIs: Mistral AI API for chatbot responses
  •             - Deployment: Streamlit Cloud / Render / Vercel
  •         """)
  •     elif nav_option == "Future Scope":
  •         st.markdown("""
  •             ## Future Scope / Limitations
  •             - Enhance image captioning and real-time voice synthesis.
  •             - Integrate multilingual support and more advanced AI models.
  •             - Improve cloud scalability and deploy on public cloud platforms.
  •             - Address limitations in response latency and UI responsiveness.
  •         """)
  • ---------------- Chat Interface Section ----------------

  • else:
  •     if st.session_state.domain is None:
  •         st.subheader("Choose Your Assistant Domain")
  •         domains = list(DOMAIN_CONFIGS.keys())
  •         for i in range(0, len(domains), 2):
  •             cols = st.columns(2)
  •             for j in range(2):
  •                 if i + j < len(domains):
  •                     domain = domains[i + j]
  •                     with cols[j]:
  •                         st.markdown(f"""
  •                        
  •                            

    {DOMAIN_CONFIGS[domain]['icon']} {domain}

  •                            

    {DOMAIN_CONFIGS[domain]['description']}

  •                        
  •                         """, unsafe_allow_html=True)
  •                         if st.button("Chat Now", key=f"chat_{domain}"):
  •                             st.session_state.domain = domain
  •                             st.session_state.messages = []
  •                             st.rerun()
  •     else:
  •         # Display Domain Info
  •         st.markdown(f"### {DOMAIN_CONFIGS[st.session_state.domain]['icon']} {st.session_state.domain}")
  •         st.write(DOMAIN_CONFIGS[st.session_state.domain]['description'])
  •         st.markdown("
    ", unsafe_allow_html=True)
  •         # Display Chat History
  •         chat_container = st.container()
  •         with chat_container:
  •             for msg in st.session_state.messages:
  •                 if msg['role'] == "user":
  •                     st.markdown(f"
    You: {msg['content']}
    ", unsafe_allow_html=True)
  •                 else:
  •                     st.markdown(f"
    Assistant: {msg['content']}
    ", unsafe_allow_html=True)
  •         st.markdown("
    ", unsafe_allow_html=True)
  •         # Select Input Mode
  •         input_mode = st.radio("Select Input Mode:", ["Text", "Voice", "Image", "PDF"], key="input_mode_radio")
  •         user_query = ""
  •         if input_mode == "Text":
  •             user_query = st.text_input("Enter your query:", key="text_input")
  •         elif input_mode == "Voice":
  •             if st.button("Record Query", key="record_button"):
  •                 user_query = recognize_speech()
  •                 st.success(f"Recognized: {user_query}")
  •         elif input_mode == "Image":
  •             uploaded_image = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"], key="image_uploader")
  •             if uploaded_image:
  •                 from image_processing import extract_text_from_image
  •                 user_query = extract_text_from_image(uploaded_image)
  •                 st.info(f"Extracted Text: {user_query}")
  •         elif input_mode == "PDF":
  •             uploaded_pdf = st.file_uploader("Upload a PDF", type=["pdf"], key="pdf_uploader")
  •             if uploaded_pdf:
  •                 from pdf_processing import extract_text_from_pdf
  •                 user_query = extract_text_from_pdf(uploaded_pdf)
  •                 st.info(f"Extracted Text: {user_query}")
  •         # Send Query Button
  •         if st.button("Send Query", key="send_query") if user_query.strip() != """                st.session_state.messages.append({"role": "user", "content": user_query})
  •                 with st.spinner("Assistant is typing..."):
  •                     response = get_response(user_query)
  •                 st.session_state.messages.append({"role": "assistant", "content": response})
  •                 st.rerun()
  •         if st.button("Change Domain", key="change_domain"):
  •             st.session_state.domain = None
  •             st.rerun()
  • ---------------- Footer ----------------

  • st.markdown("""
  •    

    Made with ❤️ by Adyaprana Pradhan | © 2025 All Rights Reserved

  •    

    Multimodal Virtual Assistant Chatbot | BCA Project

  • """, unsafe_allow_html=True)

11.2.2 API Response Handler (main.py - Snippet)

  • import requests
  • import base64
  • import json
  • import PyPDF2
  • import speech_recognition as sr
  • from PIL import Image
  • import io
  • import streamlit as st
  • Load Mistral API key from Streamlit secrets (ensure .streamlit/secrets.toml is set up)

  • MISTRAL_API_KEY = st.secrets["MISTRAL_API_KEY"]
  • MISTRAL_API_URL = "https://api.mistral.ai/v1/chat/completions"
  • HEADERS = {
  •     "Authorization": f"Bearer {MISTRAL_API_KEY}",
  •     "Content-Type": "application/json"
  • }
  • Function to extract text from PDF

  • def extract_text_from_pdf(uploaded_file):
  •     pdf_reader = PyPDF2.PdfReader(uploaded_file)
  •     text = ""
  •     for page in pdf_reader.pages:
  •         text += page.extract_text() or ""
  •     return text
  • Function to convert speech to text

  • def speech_to_text(audio_file):
  •     recognizer = sr.Recognizer()
  •     with sr.AudioFile(audio_file) as source:
  •         audio_data = recognizer.record(source)
  •     try:
  •         return recognizer.recognize_google(audio_data)
  •     except sr.UnknownValueError:
  •         return "Sorry, could not understand audio."
  •     except sr.RequestError:
  •         return "Could not request results, please check your internet."
  • Function to convert image to base64 (for potential future image processing)

  • def encode_image(image_file):
  •     img_bytes = image_file.read()
  •     encoded = base64.b64encode(img_bytes).decode("utf-8")
  •     return encoded
  • Main function: Handles different input modes and calls the Mistral API

  • def get_response(user_input, mode="text", file=None):
  •     prompt = ""
  •     # Choose prompt based on input mode
  •     if mode == "text":
  •         prompt = user_input
  •     elif mode == "voice":
  •         prompt = speech_to_text(file)
  •     elif mode == "pdf":
  •         prompt = extract_text_from_pdf(file)
  •     elif mode == "image":
  •         prompt = "User uploaded an image. Please describe its contents."  # Placeholder
  •     # Prepare payload with system prompt from selected domain if desired
  •     payload = {
  •         "model": "mistral-small",  # Adjust model if necessary
  •         "messages": [
  •             {"role": "system", "content": "You are a helpful multimodal assistant."},
  •             {"role": "user", "content": prompt}
  •         ],
  •         "temperature": 0.7
  •     }
  •     try:
  •         response = requests.post(MISTRAL_API_URL, headers=HEADERS, json=payload)
  •         if response.status_code == 200:
  •             data = response.json()
  •             # Optional: Uncomment the next line to debug the full API response
  •             # st.write("DEBUG Response:", data)
  •             if 'choices' in data and len(data['choices']) > 0:
  •                 reply = data['choices'][0]['message']['content']
  •                 return reply
  •             else:
  •                 return "❌ Error: Unexpected response format from Mistral API."
  •         else:
  •             return f"❌ API Error: {response.status_code} - {response.text}"
  •     except Exception as e:
  •         return f"❌ Exception occurred: {str(e)}"

11.2.3 Domain Configuration (domain_prompts.py - Snippet)

  • DOMAIN_CONFIGS = {
  •     "Education Assistant": {
  •         "icon": "🎓",
  •         "description": "Get help with academic subjects, research, and study strategies.",
  •         "system_prompt": (
  •             "You are an expert educational assistant with deep knowledge across academic subjects. "
  •             "Help students understand complex topics, provide study strategies, and assist with academic research. "
  •             "Keep explanations clear and structured, using examples when helpful."
  •         ),
  •         "output_mode": "text_only"
  •     },
  •     "Healthcare Guide": {
  •         "icon": "⚕️",
  •         "description": "Get general health information and wellness advice.",
  •         "system_prompt": (
  •             "You are a healthcare information guide providing general health and wellness information. "
  •             "Always remind users to consult healthcare professionals for medical advice. "
  •             "Focus on general wellness, healthy lifestyle choices, and public health information."
  •         ),
  •         "output_mode": "text_only"
  •     },
  •     "Customer Service Helper": {
  •         "icon": "👥",
  •         "description": "Get assistance with common customer service scenarios.",
  •         "system_prompt": (
  •             "You are a customer service expert who helps with common scenarios and best practices. "
  •             "Provide clear, solution-oriented responses while maintaining a professional and empathetic tone. "
  •             "Focus on practical solutions and effective communication strategies."
  •         ),
  •         "output_mode": "text_only"
  •     },
  •     "Financial Advisor": {
  •         "icon": "💰",
  •         "description": "Get guidance on financial planning and management.",
  •         "system_prompt": (
  •             "You are a financial education assistant providing general financial advice and information. "
  •             "Always remind users to consult with qualified financial advisors for personalized advice. "
  •             "Focus on financial literacy, basic concepts, and general best practices."
  •         ),
  •         "output_mode": "text_only"
  •     },
  •     "General Assistant": {
  •         "icon": "🤖",
  •         "description": "Get help with any general questions or tasks.",
  •         "system_prompt": (
  •             "You are a helpful general assistant ready to help with various tasks and questions. "
  •             "Provide clear, accurate, and helpful responses while maintaining a friendly tone. "
  •             "Be versatile and adapt your responses to the context of the question."
  •         ),
  •         "output_mode": "text_only"
  •     }
  • }

11.2.4 Voice Input Module (speech.py - Snippet)

  • import speech_recognition as sr
  • def recognize_speech():
  •     recognizer = sr.Recognizer()
  •     with sr.Microphone() as source:
  •         audio_data = recognizer.listen(source)
  •     try:
  •         return recognizer.recognize_google(audio_data)
  •     except Exception as e:
  •         return "Could not process voice input."

11.2.5 Image Processing Module (image_processing.py)

  • import pytesseract
  • from PIL import Image
  • Set the path to the Tesseract-OCR executable (Windows-specific)

  • pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
  • def extract_text_from_image(image_file):
  •     """
  •     Extract text from an uploaded image file using Tesseract OCR.
  •     Args:
  •         image_file: A file object (e.g., from Streamlit's file_uploader).
  •     Returns:
  •         str: Extracted text, or a fallback message if no text is found.
  •     """
  •     # Open the image file using PIL
  •     image = Image.open(image_file)
  •    
  •     # Use pytesseract to convert image to text
  •     text = pytesseract.image_to_string(image)
  •    
  •     # Return stripped text, or a default message if empty
  • return text.strip() if text else "No text found in the image."

11.2.5 PDF Processing Module (pdf_processing.py)

  • import fitz  # PyMuPDF
  • def extract_text_from_pdf(pdf_file):
  •     """Extracts text from an uploaded PDF"""
  •     doc = fitz.open(stream=pdf_file.read(), filetype="pdf")
  •     text = ""
  •     for page in doc:
  •         text += page.get_text()
  •     return text.strip() if text else "No text found in PDF." 11.3 Supporting Documents 11.3.1 Project README (readme.md)

Multimodal Virtual Assistant Chatbot

Overview

A smart chatbot that supports text, voice, image, and PDF input. It leverages AI/LLM (Mistral API) for intelligent responses.

Features

  • Domain-specific assistance (Education, Healthcare, etc.)
  • Multimodal input support: Text, Voice, Image, PDF.
  • Clean and responsive UI with sidebar navigation.
  • Response loading animation and professional design.

Setup & Installation

  1. Clone this repository.
  2. Create a virtual environment: python -m venv venv
  3. Install dependencies: pip install -r requirements.txt
  4. Set up your Streamlit secrets in .streamlit/secrets.toml
  5. Run the application: `streamlit run app.py.

Deployment

This project can be deployed on Streamlit Cloud or other cloud platforms. Follow these steps:

  1. Clone the repository.
  2. Create a virtual environment and install dependencies using pip install -r requirements.txt.
  3. Add your MISTRAL_API_KEY in .streamlit/secrets.toml.
  4. Run the app using streamlit run app.py. Live Demo: https://your-live-demo-link.com

Technology Used

  • Python, Streamlit, pytesseract, SpeechRecognition, PyPDF2, Mistral API, etc.

Future Scope / Limitations

Discuss potential improvements and known limitations.

Author

Adyaprana Pradhan

Install Dependencies: Ensure Python 3.9+ is installed, then run:

pip install -r requirements.txt

Sample requirements.txt: streamlit requests pytesseract Pillow SpeechRecognition PyPDF2

**Install Tesseract-OCR (for image processing): **

  • Windows: Download and install from Tesseract at UB Mannheim.

  • Update image_processing.py with the correct path if needed.

  • **Set Up API Key: **

  • Sign up at Mistral AI to get an API token.

  • Add it to a .streamlit/secrets.toml file:

  • [mistral] api_token = "your_mistral_api_key_here"

  • Run the App: streamlit run app.py

Project Structure ai-powered-smart-virtual-assistant/

  • ├── app.py                # Main Streamlit app
  • ├── main.py               # Core logic and API calls
  • ├── domain_prompts.py     # Domain configurations
  • ├── speech.py             # Voice input processing
  • ├── image_processing.py   # Image text extraction
  • ├── pdf_processing.py     # PDF text extraction (assumed)
  • ├── generated-icon.png    # Project icon
  • ├── requirements.txt      # Dependencies
  • └── .streamlit/
  •     └── secrets.toml      # API key storage

### Summary of Files & Their Roles

  • app.py:

Main Streamlit app with improved UI, sidebar navigation, and loading animations.

  • domain_prompts.py:

Contains domain-specific configuration (icons, descriptions, system prompts).

  • main.py:

Contains core logic for handling different input modes and calling the Mistral API.

  • speech.py:

Handles speech-to-text conversion.

  • image_processing.py:

Handles OCR for image inputs using pytesseract.

  • pdf_processing.py:

Handles text extraction from PDF files using PyMuPDF (fitz).

  • README.md:

Project overview, setup, usage, deployment instructions, technology used, and live demo link.

  • docs/ folder:

Contains additional documentation files: About Project, Technology Used, Future Scope, etc.

  • assets/ folder:

Contains images like logos and any additional visual assets.

  • .streamlit/secrets.toml:

Contains sensitive keys like MISTRAL_API_KEY.

  • PPT & Report:

Prepared separately to showcase the project.

Contributing: This is a student project, but feedback is welcome! Feel free to:

  • · Fork the repo.
  • · Create a branch (git checkout -b feature/your-idea).
  • · Submit a pull request with your changes.
  • For the full source code and setup instructions, please visit the project repository: https://github.com/Adyaprana
  • License This project is for educational purposes and not licensed for commercial use. All rights reserved © 2025 Adyaprana Pradhan.
  • KIIT University: For providing resources and opportunities.
  • Mistral AI: For the powerful API that drives this assistant.
  • Open-Source Community: For libraries like Streamlit and pytesseract.

By - Adyaprana Pradhan

BCA Final Year Project, School of Computer Applications, KIIT University, April 2025

Thank You

Clone this wiki locally