import streamlit as st
# Function to load CSS content from a file
def load_css(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
return f.read()
# Function to load JavaScript content from a file
def load_js(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
return f.read()
# Example usage
css_content = load_css('styles.css')
clear_button_style = """
<style>
.clear-history-button {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #131720;
color: white;
border: 1px solid #343840;
padding: 0.40rem 0.75rem;
border-radius: 0.5rem;
cursor: pointer;
font-size: 16px;
z-index: 1000;
}
.clear-history-button:hover {
border: 1px solid #FE4B4A;
background-color: #131720;
color: #FE4B4A;
}
.clear-history-button:active{
background-color: #FE4B4A;
color: white;
}
</style>
<button class="clear-history-button" onclick="window.location.href=window.location.pathname + '?clear-history=true';">
Clear History
</button>
"""
st.markdown(clear_button_style, unsafe_allow_html=True)
# Handle the button click
if st.experimental_get_query_params().get("clear-history"):
with open('conversation_log.json', 'w', encoding='utf-8') as f:
f.write('[]')
st.success("Conversation log cleared successfully!")
the button is not working