Skip to content
Snippets Groups Projects
Commit 0c40ab95 authored by jevin3107's avatar jevin3107
Browse files

Main Streamlit app file

parent d0d528e0
No related branches found
No related tags found
No related merge requests found
import pandas as pd
import streamlit as st
from rasa.core.agent import Agent
from rasa.core.tracker_store import InMemoryTrackerStore
import matplotlib.pyplot as plt
# Load the dataset
df = pd.read_csv('FakeDataset.csv')
df = pd.read_csv("FakeDataset.csv")
# Initialize Streamlit
st.title("Airline Chatbot")
# Load an image for display
#st.image("bot_image.png", caption="Welcome to the Airline Chatbot")
# Greet the user
if "greeted" not in st.session_state:
st.session_state.greeted = False
if not st.session_state.greeted:
st.write("Hello! I am here to assist you with flight details.")
st.session_state.greeted = True
# Get user inputs
passenger_id = st.text_input("Please enter your Passenger ID:")
# Respond to the query
if st.button("Get Flight Details"):
if passenger_id:
result = df[df.applymap(lambda x: passenger_id.lower() in str(x).lower() if pd.notnull(x) else False).any(axis=1)]
if not result.empty:
st.write("Here are your flight details:")
st.dataframe(result)
st.title("Airline Chatbot & Data Explorer")
#Adding the Bot image
st.image("Chatbot_image.jpg", caption="Welcome to the Airline Chatbot & Data Explorer!", use_container_width=True)
# Add navigation
menu = st.sidebar.selectbox("Select a Feature", ["Chatbot", "Data Explorer", "Visualizations"])
if menu == "Chatbot":
# Chatbot Section
st.subheader("Chat with Airline Assistant")
if "greeted" not in st.session_state:
st.session_state.greeted = False
if not st.session_state.greeted:
st.write("Hello! I am here to assist you with flight details.")
st.session_state.greeted = True
passenger_id = st.text_input("Please enter your Passenger ID:")
if st.button("Get Flight Details"):
if passenger_id:
result = df[df.applymap(lambda x: passenger_id.lower() in str(x).lower() if pd.notnull(x) else False).any(axis=1)]
if not result.empty:
st.write("Here are your flight details:")
st.dataframe(result)
else:
st.write("No details found for the given information. Please try again.")
else:
st.write("No details found for the given information. Please try again.")
else:
st.write("Please provide all the required details.")
# Goodbye message
user_message = st.text_input("Anything else you'd like to know?")
if user_message.lower() in ["good", "thank you", "bye"]:
st.write("Happy to assist you!")
st.write("Please provide all the required details.")
user_message = st.text_input("Anything else you'd like to know?")
if user_message.lower() in ["good", "thank you", "bye"]:
st.write("Happy to assist you!")
elif menu == "Data Explorer":
# Data Explorer Section
st.subheader("Explore the Airline Dataset")
# Display dataset columns
columns = st.multiselect("Select columns to view:", options=df.columns.tolist(), default=df.columns.tolist())
st.dataframe(df[columns])
# Filter by Flight Status
flight_status = st.selectbox("Filter by Flight Status:", options=["All"] + df["Flight Status"].unique().tolist())
if flight_status != "All":
st.dataframe(df[df["Flight Status"] == flight_status])
elif menu == "Visualizations":
# Visualizations Section
st.subheader("Visualize the Data")
# Bar chart for flight statuses
st.write("Flight Status Distribution")
status_counts = df["Flight Status"].value_counts()
fig, ax = plt.subplots()
status_counts.plot(kind="bar", ax=ax)
ax.set_title("Flight Status Distribution")
ax.set_xlabel("Flight Status")
ax.set_ylabel("Count")
st.pyplot(fig)
# Pie chart for passenger nationality distribution
st.write("Passenger Nationality Distribution")
nationality_counts = df["Nationality"].value_counts().head(10) # Top 10 nationalities
fig, ax = plt.subplots()
nationality_counts.plot(kind="pie", autopct="%1.1f%%", ax=ax)
ax.set_ylabel("")
ax.set_title("Top 10 Passenger Nationalities")
st.pyplot(fig)
bot_image.png

5.17 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment