Update src/streamlit_app.py
Browse files- src/streamlit_app.py +17 -45
src/streamlit_app.py
CHANGED
|
@@ -158,53 +158,25 @@ with st.sidebar:
|
|
| 158 |
st.markdown("---")
|
| 159 |
st.caption("✨ Built by Shubham Sharma")
|
| 160 |
|
| 161 |
-
# 🧩 Developer Insights (Moved up here from main block)
|
| 162 |
-
if show_dev:
|
| 163 |
-
st.markdown("---")
|
| 164 |
-
with st.expander("🧩 Developer Insights", expanded=False):
|
| 165 |
-
st.markdown("**Retrieved Chunks (Context):**")
|
| 166 |
-
retrieved_chunks = st.session_state.get("retrieved", [])
|
| 167 |
-
for i, r in enumerate(retrieved_chunks, start=1):
|
| 168 |
-
st.markdown(f"- **Chunk {i}:** {r}")
|
| 169 |
-
|
| 170 |
-
toc_data = st.session_state.get("toc", [])
|
| 171 |
-
if toc_data:
|
| 172 |
-
st.markdown("---")
|
| 173 |
-
st.markdown("**Document Sections (TOC):**")
|
| 174 |
-
toc_text = "\n".join([f"{sec}. {title}" for sec, title in toc_data])
|
| 175 |
-
st.text_area("", toc_text, height=120)
|
| 176 |
-
|
| 177 |
-
doc_text = st.session_state.get("text", "")
|
| 178 |
-
if doc_text:
|
| 179 |
-
st.markdown("---")
|
| 180 |
-
st.markdown("**Document Preview:**")
|
| 181 |
-
st.text_area("", doc_text[:1000], height=120)
|
| 182 |
-
st.caption(f"{len(st.session_state.get('chunks', []))} chunks processed.")
|
| 183 |
-
|
| 184 |
# ==========================================================
|
| 185 |
-
#
|
| 186 |
# ==========================================================
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
else:
|
| 204 |
-
chunk_size, overlap, top_k = 1000, 120, 5
|
| 205 |
-
|
| 206 |
-
st.markdown("---")
|
| 207 |
-
st.caption("✨ Built by Shubham Sharma")
|
| 208 |
|
| 209 |
|
| 210 |
# ==========================================================
|
|
|
|
| 158 |
st.markdown("---")
|
| 159 |
st.caption("✨ Built by Shubham Sharma")
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ==========================================================
|
| 162 |
+
# 🧠 SESSION STATE
|
| 163 |
# ==========================================================
|
| 164 |
+
for key, val in {
|
| 165 |
+
"user_query_input": "",
|
| 166 |
+
"show_more": False,
|
| 167 |
+
"selected_suggestion": None,
|
| 168 |
+
"query_suggestions_fixed": None,
|
| 169 |
+
"last_doc": None,
|
| 170 |
+
"doc_lang": "en", # 🆕 optional: store document language
|
| 171 |
+
}.items():
|
| 172 |
+
if key not in st.session_state:
|
| 173 |
+
st.session_state[key] = val
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def set_user_query(q, idx):
|
| 177 |
+
st.session_state["user_query_input"] = q
|
| 178 |
+
st.session_state["selected_suggestion"] = idx
|
| 179 |
+
st.experimental_rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
|
| 182 |
# ==========================================================
|