Spaces:
Running
Running
dineshabeysinghe
commited on
Commit
β’
8a09ccf
1
Parent(s):
7dd7372
add css style folder and file
Browse files- app.py +12 -63
- style/style.css +61 -0
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import streamlit as st
|
3 |
|
|
|
|
|
4 |
# Set up Streamlit app title and page width
|
5 |
st.set_page_config(page_title='Simple Chatbot with Streamlit', layout='wide')
|
6 |
|
@@ -11,74 +15,20 @@ chatbot = pipeline("text2text-generation", model="facebook/blenderbot-400M-disti
|
|
11 |
if 'chat_history' not in st.session_state:
|
12 |
st.session_state['chat_history'] = []
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
.stApp {
|
21 |
-
max-width: 800px;
|
22 |
-
margin: auto;
|
23 |
-
padding-top: 50px;
|
24 |
-
}
|
25 |
-
.stTextInput {
|
26 |
-
margin-bottom: 20px;
|
27 |
-
}
|
28 |
-
.stButton button {
|
29 |
-
background-color: #4CAF50; /* Green */
|
30 |
-
border: none;
|
31 |
-
color: white;
|
32 |
-
padding: 15px 32px;
|
33 |
-
text-align: center;
|
34 |
-
text-decoration: none;
|
35 |
-
display: inline-block;
|
36 |
-
font-size: 16px;
|
37 |
-
margin: 4px 2px;
|
38 |
-
cursor: pointer;
|
39 |
-
border-radius: 5px;
|
40 |
-
}
|
41 |
-
.stButton button:hover {
|
42 |
-
background-color: #7EC0EE; /* Darker sky blue on hover */
|
43 |
-
}
|
44 |
-
.chat-container {
|
45 |
-
padding:6px;
|
46 |
-
border-radius: 5px;
|
47 |
-
overflow: hidden;
|
48 |
-
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.3);
|
49 |
-
# border: 1px solid #d3d3d3;
|
50 |
-
overflow: hidden;
|
51 |
-
}
|
52 |
-
.user-message {
|
53 |
-
background-color: #4CAF50;
|
54 |
-
color: white;
|
55 |
-
padding: 10px 20px;
|
56 |
-
margin: 5px;
|
57 |
-
border-radius: 5px;
|
58 |
-
clear: both;
|
59 |
-
float: left;
|
60 |
-
}
|
61 |
-
.bot-message {
|
62 |
-
background-color: #f1f1f1;
|
63 |
-
color: black;
|
64 |
-
padding: 10px 20px;stButton
|
65 |
-
margin: 5px;
|
66 |
-
border-radius: 5px;
|
67 |
-
clear: both;
|
68 |
-
float: right;
|
69 |
-
}
|
70 |
-
|
71 |
-
</style>
|
72 |
-
""", unsafe_allow_html=True)
|
73 |
|
74 |
# Define Streamlit app layout
|
75 |
st.markdown("<h1 style='color: orange;'>π¬ Chatbot</h1>", unsafe_allow_html=True)
|
76 |
-
st.caption("π Chat bot created By :- [Dinesh Abeysinghe
|
77 |
|
78 |
# Create text area for user input
|
79 |
user_input = st.text_input("", placeholder="Your message")
|
80 |
|
81 |
-
|
82 |
# Define Streamlit app behavior
|
83 |
if st.button('Send'):
|
84 |
if not user_input.strip(): # Check if input is empty or whitespace
|
@@ -95,8 +45,7 @@ if st.button('Send'):
|
|
95 |
|
96 |
# Update chat history in session state
|
97 |
st.session_state['chat_history'] = chat_history
|
98 |
-
|
99 |
-
|
100 |
# Create text area for chat history
|
101 |
chat_area = st.empty()
|
102 |
|
|
|
1 |
+
# app.py
|
2 |
+
|
3 |
from transformers import pipeline
|
4 |
import streamlit as st
|
5 |
|
6 |
+
|
7 |
+
|
8 |
# Set up Streamlit app title and page width
|
9 |
st.set_page_config(page_title='Simple Chatbot with Streamlit', layout='wide')
|
10 |
|
|
|
15 |
if 'chat_history' not in st.session_state:
|
16 |
st.session_state['chat_history'] = []
|
17 |
|
18 |
+
# Read the CSS file
|
19 |
+
with open("./style/style.css") as f:
|
20 |
+
css = f.read()
|
21 |
+
|
22 |
+
# Inject CSS into the Streamlit app
|
23 |
+
st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Define Streamlit app layout
|
26 |
st.markdown("<h1 style='color: orange;'>π¬ Chatbot</h1>", unsafe_allow_html=True)
|
27 |
+
st.caption("π Chat bot created By :- [Dinesh Abeysinghe](https://www.linkedin.com/in/dinesh-abeysinghe-bb773293)")
|
28 |
|
29 |
# Create text area for user input
|
30 |
user_input = st.text_input("", placeholder="Your message")
|
31 |
|
|
|
32 |
# Define Streamlit app behavior
|
33 |
if st.button('Send'):
|
34 |
if not user_input.strip(): # Check if input is empty or whitespace
|
|
|
45 |
|
46 |
# Update chat history in session state
|
47 |
st.session_state['chat_history'] = chat_history
|
48 |
+
|
|
|
49 |
# Create text area for chat history
|
50 |
chat_area = st.empty()
|
51 |
|
style/style.css
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* style.css */
|
2 |
+
|
3 |
+
body {
|
4 |
+
background-color: #f0f2f6;
|
5 |
+
}
|
6 |
+
|
7 |
+
.stApp {
|
8 |
+
max-width: 800px;
|
9 |
+
margin: auto;
|
10 |
+
padding-top: 50px;
|
11 |
+
}
|
12 |
+
|
13 |
+
.stTextInput {
|
14 |
+
margin-bottom: 20px;
|
15 |
+
}
|
16 |
+
|
17 |
+
.stButton button {
|
18 |
+
background-color: #4CAF50; /* Green */
|
19 |
+
border: none;
|
20 |
+
color: white;
|
21 |
+
padding: 15px 32px;
|
22 |
+
text-align: center;
|
23 |
+
text-decoration: none;
|
24 |
+
display: inline-block;
|
25 |
+
font-size: 16px;
|
26 |
+
margin: 4px 2px;
|
27 |
+
cursor: pointer;
|
28 |
+
border-radius: 5px;
|
29 |
+
}
|
30 |
+
|
31 |
+
.stButton button:hover {
|
32 |
+
background-color: #7EC0EE; /* Darker sky blue on hover */
|
33 |
+
}
|
34 |
+
|
35 |
+
.chat-container {
|
36 |
+
padding: 6px;
|
37 |
+
border-radius: 5px;
|
38 |
+
overflow: hidden;
|
39 |
+
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.3);
|
40 |
+
overflow: hidden;
|
41 |
+
}
|
42 |
+
|
43 |
+
.user-message {
|
44 |
+
background-color: #4CAF50;
|
45 |
+
color: white;
|
46 |
+
padding: 10px 20px;
|
47 |
+
margin: 5px;
|
48 |
+
border-radius: 5px;
|
49 |
+
clear: both;
|
50 |
+
float: left;
|
51 |
+
}
|
52 |
+
|
53 |
+
.bot-message {
|
54 |
+
background-color: #f1f1f1;
|
55 |
+
color: black;
|
56 |
+
padding: 10px 20px;
|
57 |
+
margin: 5px;
|
58 |
+
border-radius: 5px;
|
59 |
+
clear: both;
|
60 |
+
float: right;
|
61 |
+
}
|