CoolFace
Apppublic

sujithh/llm-evaluation

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py71 linesDownload Raw Back to root
1import streamlit as st2import json3import os4import subprocess5 6st.title("LLM Evaluation for GATE Papers")7 8model_type = st.selectbox("Select model type:", ["groq", "gemini"])9question_url = st.text_input("Enter GATE Question Paper URL (Optional, default one is GATE CS25-Set-2 Paper)")10answer_url = st.text_input("Enter GATE Answer Key URL (Optional):")11 12if st.button("Run Evaluation"):13    st.info(f"Running evaluation using {model_type} model...")14 15    os.environ["MLC_MODEL_TYPE"] = model_type16    if model_type == "gemini":17        os.environ["GEMINI_API_KEY"] = st.secrets["GEMINI_API_KEY"]18    elif model_type == "groq":19        os.environ["GROQ_API_KEY"] = st.secrets["GROQ_API_KEY"]20 21    if question_url:22        os.environ["MLC_GATE_QUESTION_PDF_URL"] = question_url23    if answer_url:24        os.environ["MLC_GATE_ANSWER_PDF_URL"] = answer_url25 26    # --- Run process.py and stream logs ---27    process = subprocess.Popen(28        ["python3", "process.py"],29        stdout=subprocess.PIPE,30        stderr=subprocess.STDOUT,31        text=True,32        bufsize=133    )34 35    # container for logs36    log_container = st.empty()37    logs = ""38 39    # Stream logs with auto-scroll40    for line in iter(process.stdout.readline, ''):41        logs += line42        log_container.code(logs, language="bash")  # preserves colors + auto height43        st.markdown(44            "<script>window.scrollTo(0, document.body.scrollHeight);</script>",45            unsafe_allow_html=True46        )47 48    process.stdout.close()49    process.wait()50 51    st.success("Evaluation completed successfully !!")52 53   # Ensure the results folder exists54    os.makedirs("./results", exist_ok=True)55    output_json = "./results"56    57    if os.path.exists(output_json):58        with open(output_json, "r") as f:59            result_data = json.load(f)60    else:61        # Create an empty placeholder if missing62        result_data = {63            "status": "empty",64            "message": f"No results found yet for {model_type}. Placeholder file created."65        }66        with open(output_json, "w") as f:67            json.dump(result_data, f, indent=2)68    69    st.subheader("Evaluation Results JSON")70    st.json(result_data)71