Skip to content

Commit fd396fb

Browse files
committed
feat: enhance link display in chat by using markdown for better formatting and adding truncation style
1 parent 816fa06 commit fd396fb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pages/ask_uos_chat.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,19 @@ def generate_response(self, prompt):
117117

118118
def display_visited_links(self):
119119
"""Display the links visited for the current user query."""
120+
120121
with st.expander(session_state["_"]("Sources")):
121122
for link in visited_links():
122-
st.write("- " + link)
123+
st.markdown(
124+
f"""
125+
126+
<div class="truncate">
127+
<span>&#8226;</span> <a href="{link}" target="_blank" rel="noopener noreferrer">{link}</a>
128+
</div>
129+
130+
""",
131+
unsafe_allow_html=True,
132+
)
123133
visited_links.clear()
124134

125135
def store_response(self, output, prompt):

pages/static/style.css

+12
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ background-image: url('app/static/Icon-Daumen-u-2.png'); /* Path to your png fil
8080
span[data-testid="stHeaderActionElements"] a {
8181
display: none !important;
8282
}
83+
84+
85+
/* Prevents that urls displayed in the st.expander overflow the container */
86+
.truncate {
87+
width: 100%; /* Allow full width of the container */
88+
max-width: 100%; /* Prevent exceeding the container */
89+
white-space: nowrap;
90+
overflow: hidden;
91+
text-overflow: ellipsis;
92+
display: inline-block; /* Use inline-block to allow the bullet and link in one line */
93+
margin-bottom: 10px; /* Space between items (line break) */
94+
}

0 commit comments

Comments
 (0)