-
Notifications
You must be signed in to change notification settings - Fork 1
/
page2.py
64 lines (60 loc) · 2.87 KB
/
page2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
def run_app():
# Page Title
st.title('Customise Your Bot')
# Taking inputs from the user
st.subheader('Please enter the following details:')
widget_background_color = st.color_picker('Widget Background Color', '#3B81F6')
main_widget_icon = st.text_input('Main Widget Icon URL')
welcome_message = st.text_input('Welcome Message')
chat_window_default_message = st.text_input('Chat Window Default Message', 'Type your question')
height_pixels = st.number_input('Height in Pixels', value=700)
width_pixels = st.number_input('Width in Pixels', value=400)
font_size = st.number_input('Font Size', value=16)
bot_avatar = st.text_input('Bot Avatar URL')
bot_message_background_color = st.color_picker('Bot Message Background Color', '#f7f8ff')
bot_message_text_color = st.color_picker('Bot Message Text Color', '#303235')
user_avatar = st.text_input('User Avatar URL')
user_background_message_color = st.color_picker('User Background Message Color', '#3B81F6')
user_text_message_color = st.color_picker('User Text Message Color', '#ffffff')
send_button_color = st.color_picker('Send Button Color', '#3B81F6')
# Generating the code based on user inputs
if st.button('Generate Code'):
bot_name = st.session_state.bot_name # Retrieve bot name from session state
code = f"""<script type="module">
import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
Chatbot.init({{
chatflowid: "80dde17d-aa68-4816-8750-0ac1d90682ba",
apiHost: "https://butterbot-ml2y.onrender.com",
chatflowConfig: {{
pineconeNamespace: "{bot_name}",
}},
theme: {{
button: {{
backgroundColor: "{widget_background_color}",
customIconSrc: "{main_widget_icon}",
}},
chatWindow: {{
welcomeMessage: "{welcome_message}",
height: {height_pixels},
width: {width_pixels},
fontSize: {font_size},
botMessage: {{
backgroundColor: "{bot_message_background_color}",
textColor: "{bot_message_text_color}",
avatarSrc: "{bot_avatar}",
}},
userMessage: {{
backgroundColor: "{user_background_message_color}",
textColor: "{user_text_message_color}",
avatarSrc: "{user_avatar}",
}},
textInput: {{
placeholder: "{chat_window_default_message}",
sendButtonColor: "{send_button_color}",
}}
}}
}}
}})
</script>"""
st.code(code, language='html')