Spaces:
Running
Running
Commit
·
2027242
1
Parent(s):
5dcf548
Update page1.py
Browse files
page1.py
CHANGED
|
@@ -41,11 +41,94 @@ def text():
|
|
| 41 |
"content": prompt
|
| 42 |
}
|
| 43 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
with st.chat_message("assistant").markdown(text_output):
|
| 51 |
st.session_state.messages.append(
|
|
@@ -53,4 +136,4 @@ def text():
|
|
| 53 |
"role": "assistant",
|
| 54 |
"content": text_output
|
| 55 |
}
|
| 56 |
-
)
|
|
|
|
| 41 |
"content": prompt
|
| 42 |
}
|
| 43 |
)
|
| 44 |
+
# Custom HTML and CSS for three-dot animation
|
| 45 |
+
spinner_html = """
|
| 46 |
+
<div class="col-3">
|
| 47 |
+
<div class="snippet" data-title="dot-pulse">
|
| 48 |
+
<div class="stage">
|
| 49 |
+
<div class="dot-pulse"></div>
|
| 50 |
+
</div>
|
| 51 |
+
</div>
|
| 52 |
+
</div>
|
| 53 |
+
"""
|
| 54 |
|
| 55 |
+
spinner_css = """
|
| 56 |
+
.dot-pulse {
|
| 57 |
+
position: relative;
|
| 58 |
+
left: -9999px;
|
| 59 |
+
|
| 60 |
+
width: 10px;
|
| 61 |
+
height: 10px;
|
| 62 |
+
border-radius: 5px;
|
| 63 |
+
background-color: #9880ff;
|
| 64 |
+
color: #9880ff;
|
| 65 |
+
box-shadow: 9999px 0 0 -5px;
|
| 66 |
+
animation: dot-pulse 1.5s infinite linear;
|
| 67 |
+
animation-delay: 0.25s;
|
| 68 |
+
}
|
| 69 |
+
.dot-pulse::before, .dot-pulse::after {
|
| 70 |
+
content: "";
|
| 71 |
+
display: inline-block;
|
| 72 |
+
position: absolute;
|
| 73 |
+
top: 0;
|
| 74 |
+
width: 10px;
|
| 75 |
+
height: 10px;
|
| 76 |
+
border-radius: 5px;
|
| 77 |
+
background-color: #9880ff;
|
| 78 |
+
color: #9880ff;
|
| 79 |
+
}
|
| 80 |
+
.dot-pulse::before {
|
| 81 |
+
box-shadow: 9984px 0 0 -5px;
|
| 82 |
+
animation: dot-pulse-before 1.5s infinite linear;
|
| 83 |
+
animation-delay: 0s;
|
| 84 |
+
}
|
| 85 |
+
.dot-pulse::after {
|
| 86 |
+
box-shadow: 10014px 0 0 -5px;
|
| 87 |
+
animation: dot-pulse-after 1.5s infinite linear;
|
| 88 |
+
animation-delay: 0.5s;
|
| 89 |
+
}
|
| 90 |
|
| 91 |
+
@keyframes dot-pulse-before {
|
| 92 |
+
0% {
|
| 93 |
+
box-shadow: 9984px 0 0 -5px;
|
| 94 |
+
}
|
| 95 |
+
30% {
|
| 96 |
+
box-shadow: 9984px 0 0 2px;
|
| 97 |
+
}
|
| 98 |
+
60%, 100% {
|
| 99 |
+
box-shadow: 9984px 0 0 -5px;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
@keyframes dot-pulse {
|
| 103 |
+
0% {
|
| 104 |
+
box-shadow: 9999px 0 0 -5px;
|
| 105 |
+
}
|
| 106 |
+
30% {
|
| 107 |
+
box-shadow: 9999px 0 0 2px;
|
| 108 |
+
}
|
| 109 |
+
60%, 100% {
|
| 110 |
+
box-shadow: 9999px 0 0 -5px;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
@keyframes dot-pulse-after {
|
| 114 |
+
0% {
|
| 115 |
+
box-shadow: 10014px 0 0 -5px;
|
| 116 |
+
}
|
| 117 |
+
30% {
|
| 118 |
+
box-shadow: 10014px 0 0 2px;
|
| 119 |
+
}
|
| 120 |
+
60%, 100% {
|
| 121 |
+
box-shadow: 10014px 0 0 -5px;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
"""
|
| 125 |
+
|
| 126 |
+
st.markdown(f'<style>{spinner_css}</style>', unsafe_allow_html=True)
|
| 127 |
+
st.markdown(spinner_html, unsafe_allow_html=True)
|
| 128 |
+
|
| 129 |
+
for chunk in llm_chain.stream(prompt):
|
| 130 |
+
text_output = chunk.get("text", "")
|
| 131 |
+
st.markdown('<style>.dot-pulse { visibility: hidden; }</style>', unsafe_allow_html=True)
|
| 132 |
|
| 133 |
with st.chat_message("assistant").markdown(text_output):
|
| 134 |
st.session_state.messages.append(
|
|
|
|
| 136 |
"role": "assistant",
|
| 137 |
"content": text_output
|
| 138 |
}
|
| 139 |
+
)
|