Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -32,12 +32,19 @@ def main():
|
|
| 32 |
)
|
| 33 |
|
| 34 |
st.title("SongLift LyrGen2")
|
| 35 |
-
st.sidebar.markdown(f"**Model:** {Settings.LLM_MODEL}")
|
| 36 |
if st.sidebar.button("New Song"):
|
| 37 |
st.session_state.chat_history = []
|
| 38 |
st.session_state.current_lyrics = None
|
| 39 |
st.rerun()
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Only run startup once per session
|
| 42 |
if 'initialized' not in st.session_state:
|
| 43 |
print("===== Application Startup at", datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "=====\n")
|
|
@@ -51,6 +58,21 @@ def main():
|
|
| 51 |
st.session_state.chat_history = []
|
| 52 |
st.session_state.current_lyrics = None
|
| 53 |
st.session_state.initialized = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
print("Generator initialized successfully")
|
| 55 |
st.rerun()
|
| 56 |
except Exception as e:
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
st.title("SongLift LyrGen2")
|
|
|
|
| 35 |
if st.sidebar.button("New Song"):
|
| 36 |
st.session_state.chat_history = []
|
| 37 |
st.session_state.current_lyrics = None
|
| 38 |
st.rerun()
|
| 39 |
|
| 40 |
+
# Show DB stats if available
|
| 41 |
+
if "db_stats" in st.session_state:
|
| 42 |
+
stats = st.session_state.db_stats
|
| 43 |
+
st.sidebar.markdown("---")
|
| 44 |
+
st.sidebar.metric("Artists", f"{stats['artists']:,}")
|
| 45 |
+
st.sidebar.metric("Songs", f"{stats['songs']:,}")
|
| 46 |
+
st.sidebar.metric("Chunks", f"{stats['chunks']:,}")
|
| 47 |
+
|
| 48 |
# Only run startup once per session
|
| 49 |
if 'initialized' not in st.session_state:
|
| 50 |
print("===== Application Startup at", datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "=====\n")
|
|
|
|
| 58 |
st.session_state.chat_history = []
|
| 59 |
st.session_state.current_lyrics = None
|
| 60 |
st.session_state.initialized = True
|
| 61 |
+
|
| 62 |
+
# Compute DB stats for sidebar
|
| 63 |
+
collection = generator.vector_store._collection
|
| 64 |
+
all_meta = collection.get(include=["metadatas"])["metadatas"]
|
| 65 |
+
artists = set()
|
| 66 |
+
songs = set()
|
| 67 |
+
for m in all_meta:
|
| 68 |
+
artists.add(m.get("artist", ""))
|
| 69 |
+
songs.add((m.get("artist", ""), m.get("song_title", "")))
|
| 70 |
+
st.session_state.db_stats = {
|
| 71 |
+
"chunks": len(all_meta),
|
| 72 |
+
"songs": len(songs),
|
| 73 |
+
"artists": len(artists),
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
print("Generator initialized successfully")
|
| 77 |
st.rerun()
|
| 78 |
except Exception as e:
|