File size: 1,468 Bytes
beb5479
 
77901e9
beb5479
c2c7976
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
beb5479
c2c7976
 
 
 
beb5479
4094d81
c2c7976
 
1b78d27
 
 
c2c7976
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import streamlit as st
from shared.hf_helpers import build_pipeline
from retailgpt_evaluator.leaderboard import build_leaderboard
import yaml, pandas as pd, os
from pathlib import Path

def main():
    # Safely set page config (won’t error inside streamlit_hub.py)
    try:
        st.set_page_config(page_title="RetailGPT Evaluator", page_icon="πŸ›οΈ", layout="wide")
    except st.errors.StreamlitAPIException:
        pass

    st.title("πŸ›οΈ RetailGPT Evaluator β€” AxionX Digital")

    # Load config safely
    config_path = Path(__file__).resolve().parent / "config.yaml"
    with open(config_path) as f:
        cfg = yaml.safe_load(f)

    # Show leaderboard if exists
    if os.path.exists("models/retail_eval_results.json"):
        df = build_leaderboard()
        st.subheader("πŸ“Š Model Leaderboard")
        st.dataframe(df, use_container_width=True)
    else:
        st.warning("Run `evaluate.py` first to generate metrics.")

    # Model chat interface
    st.markdown("---")
    model_name = st.selectbox("Choose a model to chat with:", cfg["models"])
    pipe = build_pipeline(model_name)

    query = st.text_area("Customer query:", "Which is the best country for retail?.")
    if st.button("Ask Model"):
        result = pipe(query, max_new_tokens=cfg["demo"]["max_new_tokens"])
        st.markdown("### 🧠 Model Response")
        st.write(result[0]["generated_text"])

# Ensure it's import-safe
if __name__ == "__main__":
    main()