0% found this document useful (0 votes)
6 views

Python Final

The document is a project report on an 'AI Powered ChatBot' developed by students of the Diploma in Computer Engineering at Sant Gajanan Maharaj Rural Polytechnic. It outlines the project's aim to create a real-time, interactive chatbot using Python and Tkinter, integrating the Mistral AI API for intelligent responses. The report includes sections on the project's proposal, methodology, literature review, program code, and conclusion, highlighting the educational outcomes and practical applications of the project.

Uploaded by

sbdada07
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Final

The document is a project report on an 'AI Powered ChatBot' developed by students of the Diploma in Computer Engineering at Sant Gajanan Maharaj Rural Polytechnic. It outlines the project's aim to create a real-time, interactive chatbot using Python and Tkinter, integrating the Mistral AI API for intelligent responses. The report includes sections on the project's proposal, methodology, literature review, program code, and conclusion, highlighting the educational outcomes and practical applications of the project.

Uploaded by

sbdada07
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

MAHARASHTRA STATE BOARD OF TECHINICAL EDUCATION,

MUMBAI

A Project Report
On
“AI Powered ChatBot”

DIPLOMA
In
COMPUTER ENGINEERING
Submitted by

MR.SANSKAR VISHWANATH JADHAV


MR.CHETAN CHANDRAKANT INGAVALE
MR. SARTHAK DAYANAND BHOAPLE
MR. ROHAN TUKARAM BHADVANKAR

DEPARTMENT OF COMPUTER ENGINEERING


UNDER THE GUIDANCE OF
MISS. S. M. SHIVARE

SANT GAJANAN MAHARAJ RURAL POLYTECHNIC, MAHAGAON


ACADEMIC YEAR 2024-2025
1
“SANT GAJANAN MAHARAJ RURAL POLYTECHNIC”
AP-MAHAGAON, SITE-CHINCHEWADI, TAL- GADHINGLAL, KOLHAPUR

Certificate
This is to certify that the following students of VI semester of Diploma in
COMPUTER ENGINEERING of Institute SANT GAJANAN MAHARAJ RURAL
POLYTECHNIC MAHAGAON-416503 (CODE-0965) has completed
Micro-project on “AI Powered ChatBot” satisfactory in subject Programming
with python subject code 22616 for academic year 2024 to 2025 as prescribed in
the curriculum.

ROLL
ENROLLMENT NO. SEAT NO. STUDENT NAME
NO.

22 2209650026 Mr. Sanskar Vishwanath Jadhav

43 2209650056 Mr. Chetan Chandrakant Ingavle

50 2209650065 Mr. Sarthak Dayanand Bhopale

54 2209650129 Mr. Rohan Tukaram Bhadvankar

DATE: / /2025 PLACE: MAHAGAON

Miss. S. M. Shivare Mr. G. K. Birangaddi Mrs. R. S. Patil


(Project Guide) (Head of Department) (Principal)

2
AI Powered ChatBot Using Python

INDEX

Sr.No Content Page No

1 Introduction
1

2 Part – A: Micro-Project Proposal


2-3

3 Part – B: Micro-Project Report


4-6

4 Program
7-9

5 Output
10-11

6 Conclusion, Reference
12

3
SGMRP Mahagaon
AI Powered ChatBot Using Python

Introduction

Python is a versatile programming language that allows developers to create a wide range of
applications, from simple scripts to complex software solutions. Tkinter, a built-in Python
module, provides an easy way to build graphical user interfaces (GUIs) for desktop applications.

In this tutorial, we will be using Tkinter to build an AI-powered chatbot with basic
functionalities such as sending and receiving messages. The chatbot will leverage the Mistral
API to generate intelligent responses, creating a conversational experience that feels natural and
interactive.

This chatbot project in Python is a great way to learn how to work with APIs, multi-threading,
and GUI development, while creating a practical and engaging application that you can use for
various purposes.

1
SGMRP Mahagaon
AI Powered ChatBot Using Python

Part – A: Micro-Project Proposal


Title: AI Powered Chatbot

1.0 Aim/Benefits of the Micro-project :-

The primary aim of this AI-powered chatbot is to provide a real-time, interactive conversational
interface that leverages the Mistral AI API to generate intelligent and context-aware responses.
Built with Python and Tkinter, it offers a user-friendly GUI where users can input queries and
receive streamed AI-generated replies seamlessly.

2.0 Course Outcome :-

a. Display message on screen using Python script on IDE.


b. Develop python program to demonstrate use of operators.
c. Perform operation on data structure in Python.
d. Develop function for given problem.
e. Desing classes for given problem.
f. Handle exception.

3.0 Proposed Methodology :-

3.1 User Interface (UI)

 Tkinter-based GUI with a scrollable chat window and input field.


 Event-driven interactions using a “Send” button and <Return> key.

3.2 Backend Processing

 Captures user input and sends API requests via JSON.


 Uses multi-threading to prevent UI freezing.

3.3 API Integration

 Sends user messages to Mistral AI API.


 Processes streaming responses and updates the chat dynamically.
 Implements error handling for API failures.

2
SGMRP Mahagaon
AI Powered ChatBot Using Python

4.0 Literature Review:-

The AI-powered chatbot is an essential tool for enhancing user engagement and automating
interactions across various digital platforms. By leveraging advanced and machine learning
(ML) techniques, this chatbot enables seamless communication between users and machines,
improving efficiency and accessibility.

This Python project focuses on creating an intelligent, real-time chatbot using frameworks like
Tkinter for the user interface and APIs such as Mistral AI for AI-driven responses. It ensures
dynamic and context-aware conversations while maintaining a user-friendly experience.

5.0 Software requirements :-

1. IDLE (Python 3.11 64-bit)

2. Operating System

3. Window 11

3
SGMRP Mahagaon
AI Powered ChatBot Using Python

Part – B: Micro-Project Report


Title: AI Powered Chatbot

1.0 Rationale :-

This microproject focuses on creating a basic AI-powered chatbot using Python, integrated with the
mistral-small API. The chatbot leverages the Mistral language model to generate intelligent and
context-aware responses to user queries. The goal is to explore how large language models
(LLMs) can be used to simulate human-like conversations with minimal setup. By using
Mistral’s lightweight yet powerful model, this project offers an efficient and cost-effective way
to experiment with AI-driven chat systems. It also provides hands-on experience with API
integration, prompt handling, and response processing, laying the foundation for more advanced
AI applications.

2.0 Aim/Benefits of the Micro-projects:-

The primary aim of this AI-powered chatbot is to provide a real-time, interactive conversational
interface that leverages the Mistral AI API to generate intelligent and context- aware
responses. Built with Python and Tkinter, it offers a user-friendly GUI where users can input
queries and receive streamed AI-generated replies seamlessly.

3.0 Course Outcome :-

a) Display message on screen using Python script on IDE.


b) Develop python program to demonstrate use of operators.
c) Perform operation on data structure in Python.
d) Develop function for given problem.
e) Desing classes for given problem.
f) Handle exception.

4
SGMRP Mahagaon
AI Powered ChatBot Using Python

4.0 Actual Resources Used:

Sr.
NoName of Resource/Material Specification Qyt Remarks

1.IDLE (Python) - 1 Used


2.PDF Reader 15MB 1 Used
3.Laptop HP Company 1 Used

5
SGMRP Mahagaon
AI Powered ChatBot Using Python

5.0 Literature Review:-

The AI-powered chatbot is an essential tool for enhancing user engagement and automating
interactions across various digital platforms. By leveraging advanced machine learning
(ML) techniques, this chatbot enables seamless communication between users and
machines, improving efficiency and accessibility.

This Python project focuses on creating an intelligent, real-time chatbot using frameworks
like Tkinter for the user interface and APIs such as Mistral AI for AI-driven responses. It
ensures dynamic and context-aware conversations while maintaining a user-friendly
experience.

6.0 Acknowledgement:-

We would like to express our sincere gratitude to everyone who contributed to the completion
of this notepad micro project in Python.

First and foremost, we extend our appreciation to the Python programming community for
providing valuable resources, documentation, and support throughout the development
process. Special thanks to the developers of Python and its libraries for creating such a
versatile and powerful programming language.

We are also grateful to the authors of relevant tutorials, articles, and online forums that helped
us understand and implement various concepts and features, including file handling, user
input/output, and basic GUI development in Python.

7.0 Features:-

 User-Friendly Interface

 Real-Time Response Generation

 Seamless API Integration

 Message Streaming

 Security Features

6
SGMRP Mahagaon
AI Powered ChatBot Using Python

8.0 Program:-

import json
import tkinter as tk
from tkinter import scrolledtext, font
import requests
import os import
threading

API_URL = os.getenv("MISTRAL_API_URL", "https://api.mistral.ai/v1/chat/completions")


API_KEY = os.getenv("MISTRAL_API_KEY",
"QWCTGsKVFBXSD5xhgUJ8B1xjhQGG8Afh") #mistral api

def get_mistral_response(user_input, chat_window):


headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
data = {
"model": "mistral-small",
"messages": [
{"role": "user", "content": user_input}
],
"stream": True,
}

try:
response = requests.post(API_URL, json=data, headers=headers, stream=True)
response.raise_for_status()

chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, "Bot: ", "bot")
chat_window.config(state=tk.DISABLED)

for chunk in response.iter_lines():


if chunk:
try:
decoded_chunk = chunk.decode('utf-8') if
decoded_chunk.startswith('data: '):
json_data = json.loads(decoded_chunk[6:])
if "choices" in json_data and len(json_data["choices"]) > 0:
content = json_data["choices"][0]["delta"].get("content")
if content:
chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, content, "bot")

7
SGMRP Mahagaon
AI Powered ChatBot Using Python

chat_window.config(state=tk.DISABLED)
chat_window.yview(tk.END)
except json.JSONDecodeError as e:
print(f"JSONDecodeError: {e}")

chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, "\n")
chat_window.config(state=tk.DISABLED)
chat_window.yview(tk.END)

except requests.exceptions.RequestException as e:
chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, f"Bot: Error: {str(e)}\n",
"bot") chat_window.config(state=tk.DISABLED)
chat_window.yview(tk.END)
except Exception as e:
chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, f"Bot: Error: {str(e)}\n",
"bot") chat_window.config(state=tk.DISABLED)
chat_window.yview(tk.END)

def send_message():
user_input = user_entry.get()
if user_input.strip() != "":
chat_window.config(state=tk.NORMAL)
chat_window.insert(tk.END, f"You: {user_input}\n",
"user") chat_window.config(state=tk.DISABLED)
chat_window.yview(tk.END)
user_entry.delete(0, tk.END)

threading.Thread(target=get_mistral_response, args=(user_input, chat_window)).start()

def on_enter_pressed(event):
send_message()

root = tk.Tk()
root.title("AI Powered Chatbot")
root.geometry("400x600")
root.configure(bg="#ECE5DD")

font_bold = font.Font(family="Segoe UI", size=12, weight="bold")


font_normal = font.Font(family="Segoe UI", size=12)

chat_window = scrolledtext.ScrolledText(root, wrap=tk.WORD, bg="#FFFFFF", fg="#333333",


font=font_normal, state=tk.DISABLED, bd=0) # No border
chat_window.pack(padx=10, pady=(10, 5), fill=tk.BOTH, expand=True)

8
SGMRP Mahagaon
AI Powered ChatBot Using Python

input_frame = tk.Frame(root, bg="#ECE5DD")


input_frame.pack(padx=10, pady=(5, 10), fill=tk.X)

user_entry = tk.Entry(input_frame, font=font_normal, bg="#F0F0F0", bd=0) # No border


user_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 5))

send_button = tk.Button(input_frame, text="Send", command=send_message, font=font_bold,


bg="#00BFA5", fg="white", bd=0) # WhatsApp send button color
send_button.pack(side=tk.RIGHT)

root.bind('<Return>', on_enter_pressed)

chat_window.tag_configure("user", justify='right', foreground='#000000', font=font_bold,


background="#DCF8C6")
chat_window.tag_configure("bot", justify='left', foreground='#000000', font=font_normal,
background="#FFFFF

9
SGMRP Mahagaon
AI Powered ChatBot Using Python

9.0 Output:-

10
SGMRP Mahagaon
AI Powered ChatBot Using Python

11
SGMRP Mahagaon
AI Powered ChatBot Using Python

Conclusion:-

In conclusion, we are proud of the accomplishments achieved through this notepad micro project
and remain enthusiastic about exploring new avenues for growth and innovation in Python
programming.

Through this project, we have successfully implemented a functional text editor that allows users to
create, open, edit, and save text files. We have explored essential concepts such as file handling, user
input/output, and basic GUI development, gaining hands-on experience in these fundamental areas of
programming.

Reference :-

https://www.w3schools.com/python/

https://www.officeclip.com/

https://chatgpt.com

12
SGMRP Mahagaon

You might also like