Upload app.py
Browse files
app.py
CHANGED
|
@@ -175,6 +175,25 @@ html, body, [class*="css"] {
|
|
| 175 |
background: #161b2e !important;
|
| 176 |
}
|
| 177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
/* ββ Spinner ββ */
|
| 179 |
.stSpinner > div { border-top-color: #3b82f6 !important; }
|
| 180 |
|
|
@@ -1889,14 +1908,28 @@ for i, msg in enumerate(st.session_state.messages):
|
|
| 1889 |
avatar = "π§βπ" if msg["role"] == "user" else "π"
|
| 1890 |
with st.chat_message(msg["role"], avatar=avatar):
|
| 1891 |
st.markdown(msg["content"])
|
| 1892 |
-
#
|
| 1893 |
if msg["role"] == "assistant":
|
| 1894 |
-
|
| 1895 |
-
|
| 1896 |
-
|
| 1897 |
-
|
| 1898 |
-
|
| 1899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1900 |
|
| 1901 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1902 |
# INPUT β use st.chat_input (cleaner than text_input + button)
|
|
|
|
| 175 |
background: #161b2e !important;
|
| 176 |
}
|
| 177 |
|
| 178 |
+
/* ββ Copy button β Claude style ββ */
|
| 179 |
+
[data-testid="stChatMessage"] .stButton > button {
|
| 180 |
+
background: transparent !important;
|
| 181 |
+
border: 1px solid #2a2a2a !important;
|
| 182 |
+
color: #555 !important;
|
| 183 |
+
border-radius: 6px !important;
|
| 184 |
+
font-size: 0.75rem !important;
|
| 185 |
+
padding: 2px 6px !important;
|
| 186 |
+
width: auto !important;
|
| 187 |
+
min-height: 0 !important;
|
| 188 |
+
height: 24px !important;
|
| 189 |
+
transition: all 0.15s !important;
|
| 190 |
+
}
|
| 191 |
+
[data-testid="stChatMessage"] .stButton > button:hover {
|
| 192 |
+
border-color: #3b82f6 !important;
|
| 193 |
+
color: #ececec !important;
|
| 194 |
+
background: #1a1f2e !important;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
/* ββ Spinner ββ */
|
| 198 |
.stSpinner > div { border-top-color: #3b82f6 !important; }
|
| 199 |
|
|
|
|
| 1908 |
avatar = "π§βπ" if msg["role"] == "user" else "π"
|
| 1909 |
with st.chat_message(msg["role"], avatar=avatar):
|
| 1910 |
st.markdown(msg["content"])
|
| 1911 |
+
# Claude-style copy button β pure HTML/JS
|
| 1912 |
if msg["role"] == "assistant":
|
| 1913 |
+
safe_text = (msg["content"]
|
| 1914 |
+
.replace("&", "&")
|
| 1915 |
+
.replace("<", "<")
|
| 1916 |
+
.replace(">", ">")
|
| 1917 |
+
.replace('"', """)
|
| 1918 |
+
.replace("'", "'"))
|
| 1919 |
+
btn_id = f"copybtn_{i}"
|
| 1920 |
+
copy_html = (
|
| 1921 |
+
f'<button id="{btn_id}" '
|
| 1922 |
+
f'onclick="navigator.clipboard.writeText(this.getAttribute(\'data-text\'))'
|
| 1923 |
+
f'.then(()=>{{this.textContent=\'β
Copied!\';setTimeout(()=>{{this.textContent=\'π Copy\';}},2000)}})'
|
| 1924 |
+
f'.catch(()=>{{this.textContent=\'β Failed\'}})" '
|
| 1925 |
+
f'data-text="{safe_text}" '
|
| 1926 |
+
f'style="background:transparent;border:1px solid #2a2a2a;color:#666;'
|
| 1927 |
+
f'border-radius:6px;padding:2px 10px;font-size:0.75rem;'
|
| 1928 |
+
f'cursor:pointer;margin-top:4px;" '
|
| 1929 |
+
f'onmouseover="this.style.borderColor=\'#3b82f6\';this.style.color=\'#ececec\'" '
|
| 1930 |
+
f'onmouseout="this.style.borderColor=\'#2a2a2a\';this.style.color=\'#666\'">π Copy</button>'
|
| 1931 |
+
)
|
| 1932 |
+
st.markdown(copy_html, unsafe_allow_html=True)
|
| 1933 |
|
| 1934 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1935 |
# INPUT β use st.chat_input (cleaner than text_input + button)
|