Spaces:
Build error
Build error
Commit ·
5e18627
1
Parent(s): 4153745
refactor: put chatbox in its own container
Browse files- wanderlust.py +20 -12
wanderlust.py
CHANGED
|
@@ -167,6 +167,23 @@ def ChatMessage(message):
|
|
| 167 |
)
|
| 168 |
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
@solara.component
|
| 171 |
def ChatInterface():
|
| 172 |
prompt = solara.use_reactive("")
|
|
@@ -230,18 +247,9 @@ def ChatInterface():
|
|
| 230 |
):
|
| 231 |
if len(messages.value) > 0:
|
| 232 |
# The height works effectively as `min-height`, since flex will grow the container to fill the available space
|
| 233 |
-
with
|
| 234 |
-
style={
|
| 235 |
-
|
| 236 |
-
"overflow-y": "auto",
|
| 237 |
-
"height": "100px",
|
| 238 |
-
"flex-direction": "column-reverse",
|
| 239 |
-
},
|
| 240 |
-
classes=["chat-box"],
|
| 241 |
-
):
|
| 242 |
-
for message in reversed(messages.value):
|
| 243 |
-
with solara.Row(style={"align-items": "flex-start"}):
|
| 244 |
-
ChatMessage(message)
|
| 245 |
|
| 246 |
with solara.Column():
|
| 247 |
solara.InputText(
|
|
|
|
| 167 |
)
|
| 168 |
|
| 169 |
|
| 170 |
+
@solara.component
|
| 171 |
+
def ChatBox(children=[]):
|
| 172 |
+
# this uses a flexbox with column-reverse to reverse the order of the messages
|
| 173 |
+
# if we now also reverse the order of the messages, we get the correct order
|
| 174 |
+
# but the scroll position is at the bottom of the container automatically
|
| 175 |
+
solara.Column(
|
| 176 |
+
style={
|
| 177 |
+
"flex-grow": "1",
|
| 178 |
+
"overflow-y": "auto",
|
| 179 |
+
"height": "100px",
|
| 180 |
+
"flex-direction": "column-reverse",
|
| 181 |
+
},
|
| 182 |
+
classes=["chat-box"],
|
| 183 |
+
children=reversed(children),
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
@solara.component
|
| 188 |
def ChatInterface():
|
| 189 |
prompt = solara.use_reactive("")
|
|
|
|
| 247 |
):
|
| 248 |
if len(messages.value) > 0:
|
| 249 |
# The height works effectively as `min-height`, since flex will grow the container to fill the available space
|
| 250 |
+
with ChatBox():
|
| 251 |
+
with solara.Row(style={"align-items": "flex-start"}):
|
| 252 |
+
ChatMessage(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
with solara.Column():
|
| 255 |
solara.InputText(
|