model-pick / app.py
ilj's picture
pass model value
d0e1dbf
raw
history blame
1.35 kB
import streamlit as st
from langchain_pipeline import pipeline, model_names
st.title("Canarie AI Prototype")
st.subheader("Finding the canarie in the coal mine")
model_name = st.selectbox(
"Model",
model_names())
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
# To read file as bytes:
diff = ""
with st.spinner('Please wait ...'):
try:
diff = pipeline(uploaded_file, model_name)
except Exception as e:
st.exception(e)
diff_lines = diff.split("\n")
# Use HTML and CSS to style the diff lines
styled_diff = """
<style>
body {
font-family: 'Times New Roman', serif;
line-height: 1.5;
}
.diff {
margin: 10px 0;
padding: 5px;
}
.add {
color: green;
}
.remove {
color: red;
}
</style>
<div>
"""
for line in diff_lines:
if line.startswith('+'):
styled_diff += f'<div class="diff add">{line}</div>'
elif line.startswith('-'):
styled_diff += f'<div class="diff remove">{line}</div>'
else:
styled_diff += f'<div class="diff">{line}</div>'
styled_diff += "</div>"
# Display styled diff
st.markdown(styled_diff, unsafe_allow_html=True)
st.markdown("The key changes are:")