Spaces:
Sleeping
Sleeping
import streamlit as st | |
import PyPDF2 | |
def extract_text_from_pdf(file): | |
pdf_reader = PyPDF2.PdfReader(file) | |
text = "" | |
for page_num in range(len(pdf_reader.pages)): | |
page = pdf_reader.pages[page_num] | |
text += page.extract_text() | |
return text | |
st.title("ML Trainer") | |
# File uploader | |
uploaded_file = st.file_uploader("Choose a PDF or Text file", type=["pdf", "txt"]) | |
if uploaded_file is not None: | |
if uploaded_file.type == "application/pdf": | |
text = extract_text_from_pdf(uploaded_file) | |
else: # Assuming it's a plain text file | |
text = uploaded_file.read().decode('utf-8') | |
# Display text fields | |
col1, col2 = st.columns(2) | |
with col1: | |
st.header("Uploaded Text") | |
st.text_area(text, height=300) | |
with col2: | |
st.header("User Notes") | |
user_notes = st.text_area("", height=200) | |
# Rating buttons | |
st.write("Rating:") | |
if st.button("Positive"): | |
rating("positive", user_notes) | |
if st.button("Satisfactory"): | |
rating("satisfactory", user_notes) | |
if st.button("Negative"): | |
rating("negative", user_notes) | |
def rating(rating_label, rationale): | |
# Placeholder for now - you'd add your ML model training logic here | |
st.write("Rating:", rating_label) | |
st.write("Rationale:", rationale) | |