Skip to content

Commit

Permalink
fix: UI tweaks and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirbanbasu committed May 30, 2024
1 parent 338d8a3 commit c337d5d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
27 changes: 27 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,33 @@ def Page():
""",
)
ingest_uic.IngestSelectiveComponent()
if (
sm.global_knowledge_graph_index.value is not None
and sm.global_semantic_search_index.value is not None
):
solara.Markdown(
"You can use the following index IDs to reload the knowledge graph and semantic search indices."
)
rv.Alert(
type="success",
outlined=True,
icon="mdi-graph-outline",
children=[
solara.Markdown(
f"**Knowledge graph**: {sm.global_knowledge_graph_index.value.index_id}"
)
],
)
rv.Alert(
type="success",
outlined=True,
icon="mdi-vector-combine",
children=[
solara.Markdown(
f"**Semantic search**: {sm.global_semantic_search_index.value.index_id}"
)
],
)
with rv.CardActions():
solara.Button(
"LLM",
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
margin: auto;
}

.v-alert {
margin: 1rem;
}

.v-stepper {
box-shadow: none;
border-style: none;
Expand Down
50 changes: 36 additions & 14 deletions ui/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def ChatInterface():
),
color=(
(
solara.lab.theme.themes.dark.primary
solara.lab.theme.themes.dark.accent
if solara.lab.use_dark_effective()
else (solara.lab.theme.themes.light.primary)
else (solara.lab.theme.themes.light.accent)
)
if item[constants.CHAT_KEY_ROLE]
== constants.CHAT_KEY_VALUE_ASSISTANT
Expand All @@ -279,9 +279,9 @@ def ChatInterface():
),
avatar_background_color=(
(
solara.lab.theme.themes.dark.primary
solara.lab.theme.themes.dark.accent
if solara.lab.use_dark_effective()
else (solara.lab.theme.themes.light.primary)
else (solara.lab.theme.themes.light.accent)
)
if item[constants.CHAT_KEY_ROLE]
== constants.CHAT_KEY_VALUE_ASSISTANT
Expand All @@ -298,7 +298,8 @@ def ChatInterface():
solara.Markdown(
md_text=":thinking: _Thinking of a response..._"
)
if ask_tldrlc.pending
if item[constants.CHAT_KEY_CONTENT]
== constants.EMPTY_STRING
else solara.Markdown(
md_text=f"{item[constants.CHAT_KEY_CONTENT]}"
)
Expand All @@ -322,6 +323,7 @@ def ChatInterface():
== constants.CHAT_KEY_VALUE_ASSISTANT
and item == sm.global_chat_messages.value[-1]
and not ask_tldrlc.pending
and not submit_feedback.pending
and len(sm.global_chat_messages.value) > 1
and sm.global_settings_langfuse_enabled.value
and (
Expand All @@ -332,7 +334,6 @@ def ChatInterface():
with rv.ExpansionPanels():
with rv.ExpansionPanel(
disabled=submit_feedback.pending
or submit_feedback.finished
):
with rv.ExpansionPanelHeader():
solara.Markdown("🧐 _How did I do?_")
Expand All @@ -356,8 +357,12 @@ def ChatInterface():
outlined=True,
on_click=submit_feedback,
)
# if ask_tldrlc.pending:
# solara.Markdown(":thinking: _Thinking of a response..._")
if (
len(sm.global_chat_messages.value) > 0
and sm.global_chat_messages.value[-1][constants.CHAT_KEY_ROLE]
== constants.CHAT_KEY_VALUE_USER
):
solara.Markdown(":construction: _Working on it..._")
# if exported_chat_json.value:
# solara.Markdown(
# f"""
Expand All @@ -371,24 +376,41 @@ def ChatInterface():
label="Type your message here...",
style={"width": "100%"},
value=user_chat_input,
update_events=["keyup.enter"],
on_value=ask_tldrlc,
disabled=ask_tldrlc.pending,
disabled=(
ask_tldrlc.pending
or (
len(sm.global_chat_messages.value) > 0
and sm.global_chat_messages.value[-1][constants.CHAT_KEY_ROLE]
== constants.CHAT_KEY_VALUE_USER
)
),
)
solara.Button(
label="Ask",
icon_name="mdi-send",
on_click=ask_tldrlc,
color="success",
disabled=ask_tldrlc.pending,
# outlined=True,
disabled=(
ask_tldrlc.pending
or (
len(sm.global_chat_messages.value) > 0
and sm.global_chat_messages.value[-1][constants.CHAT_KEY_ROLE]
== constants.CHAT_KEY_VALUE_USER
)
),
)
# solara.Button(
# label="Clear chat",
# on_click=clear_chat_history,
# color="error",
# disabled=(
# ask_tldrlc.pending
# or len(global_state.global_chat_messages.value) == 0
# (ask_tldrlc.pending or len(sm.global_chat_messages.value) == 0)
# or (
# len(sm.global_chat_messages.value) > 0
# and sm.global_chat_messages.value[-1][constants.CHAT_KEY_ROLE]
# == constants.CHAT_KEY_VALUE_USER
# )
# ),
# style={"display": "none"},
# )
8 changes: 4 additions & 4 deletions utils/state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,16 @@ def set_theme_colours():
"""Set the theme colours for the Solara app."""

solara.lab.theme.themes.light.primary = "#2196f3"
solara.lab.theme.themes.light.secondary = "#ff8159" # "#ff5722"
solara.lab.theme.themes.light.accent = "#a7c8d9" # "#607d8b"
solara.lab.theme.themes.light.secondary = "#ff8159"
solara.lab.theme.themes.light.accent = "#7abff5"
solara.lab.theme.themes.light.error = "#f44336"
solara.lab.theme.themes.light.warning = "#ffc107"
solara.lab.theme.themes.light.info = "#00bcd4"
solara.lab.theme.themes.light.success = "#8bc34a"

solara.lab.theme.themes.dark.primary = "#ff8159" # ff5722"
solara.lab.theme.themes.dark.primary = "#ff8159"
solara.lab.theme.themes.dark.secondary = "#673ab7"
solara.lab.theme.themes.dark.accent = "#808a24" # "#cddc39"
solara.lab.theme.themes.dark.accent = "#c0cf36"
solara.lab.theme.themes.dark.error = "#f44336"
solara.lab.theme.themes.dark.warning = "#ffc107"
solara.lab.theme.themes.dark.info = "#00bcd4"
Expand Down

0 comments on commit c337d5d

Please sign in to comment.