Spaces:
Running
Running
Vlad Bastina commited on
Commit ·
42332dc
1
Parent(s): cc36ebd
send height
Browse files
app.py
CHANGED
|
@@ -126,3 +126,25 @@ if __name__ == "__main__":
|
|
| 126 |
with st.chat_message("assistant"):
|
| 127 |
st.markdown(st.session_state.messages[i]["content"])
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
with st.chat_message("assistant"):
|
| 127 |
st.markdown(st.session_state.messages[i]["content"])
|
| 128 |
|
| 129 |
+
import streamlit.components.v1 as components
|
| 130 |
+
components.html(
|
| 131 |
+
"""
|
| 132 |
+
<script>
|
| 133 |
+
function sendHeightWhenReady() {
|
| 134 |
+
const el = window.parent.document.getElementsByClassName('st-emotion-cache-b95f0i')[0];
|
| 135 |
+
if (el) {
|
| 136 |
+
const height = el.scrollHeight;
|
| 137 |
+
console.log("Sending height to parent:", height);
|
| 138 |
+
window.parent.parent.postMessage({ type: 'setHeight', height: height }, '*');
|
| 139 |
+
} else {
|
| 140 |
+
// Retry in 100ms until the element appears
|
| 141 |
+
setTimeout(sendHeightWhenReady, 1000);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
window.onload = sendHeightWhenReady;
|
| 146 |
+
window.addEventListener('resize', sendHeightWhenReady);
|
| 147 |
+
setInterval(sendHeightWhenReady, 1000);
|
| 148 |
+
</script>
|
| 149 |
+
"""
|
| 150 |
+
)
|