-
Notifications
You must be signed in to change notification settings - Fork 2
/
templates.py
85 lines (75 loc) · 1.57 KB
/
templates.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from helpers import load_image_as_base64
# Custom CSS being used for UI
css = '''
<style>
.chat-message {
padding: 1.5rem; border-radius: 0.5rem; margin-bottom: 1rem; display: flex;
}
.chat-message.user {
background-color: #2b313e
}
.chat-message.bot {
border: 1px solid #ccc;
background-color: #0f0f0f
}
.chat-message .avatar {
width: 20%;
}
.chat-message .avatar img {
max-width: 78px;
max-height: 78px;
border-radius: 50%;
object-fit: cover;
}
.chat-history {
max-height: 60vh;
overflow-y: scroll;
padding: 1rem;
border: 1px solid #ccc;
}
#content{
display: flex;
flex-direction: column;
}
#images{
display: flex;
border-radius: 0.5rem;
flex-direction: row;
gap: 3;
}
#res_img{
width: 50%;
margin: 0.5rem;
}
#message{
width: 100%;
padding: 1rem;
text-align: left;
}
'''
captain_img = load_image_as_base64('./assets/captain.png')
user_img = load_image_as_base64('./assets/user.png')
# Chat message HTML for Bot
bot_template = f'''
<div class="chat-message bot">
<div class="avatar">
<img src="data:image/png;base64,{captain_img}" />
</div>
<div id="content">
<div id="message">{{{{MSG}}}}</div>
<div id="images">{{{{IMAGES}}}}</div>
</div>
</div>
'''
# Chat message HTML for User
user_template = f'''
<div class="chat-message user">
<div class="avatar">
<img src="data:image/png;base64,{user_img}" />
</div>
<div id="content">
<div id="message">{{{{MSG}}}}</div>
<div id="images">{{{{IMAGE}}}}</div>
</div>
</div>
'''