Seth0330 commited on
Commit
2dd2c85
·
verified ·
1 Parent(s): 4cba20f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -26,8 +26,6 @@ if "json_links" not in st.session_state:
26
  st.session_state.json_links = []
27
  if "json_link_details" not in st.session_state:
28
  st.session_state.json_link_details = {}
29
- if "expanded_json" not in st.session_state:
30
- st.session_state.expanded_json = set()
31
 
32
  st.set_page_config(page_title="Chat with Your JSON Vectors (Hybrid, Clean)", layout="wide")
33
  st.title("Chat with Your Vectorized JSON Files")
@@ -243,19 +241,13 @@ def show_tiny_json_links():
243
  # Only show for the last assistant answer if there are matching JSONs
244
  if not st.session_state.json_links:
245
  return
246
- st.write("")
247
  for idx, link_key in enumerate(st.session_state.json_links):
248
  label = st.session_state.json_link_details[link_key]['label']
249
  rec = st.session_state.json_link_details[link_key]['record']
250
- unique_id = f"{link_key}_{idx}"
251
- link_text = f"<a href='javascript:void(0);' style='font-size: 11px; color: #555; text-decoration: underline;' onclick=\"document.getElementById('{unique_id}').style.display = (document.getElementById('{unique_id}').style.display === 'none' ? 'block' : 'none')\">[view JSON]</a> <span style='font-size: 10px; color: #999'>{label}</span>"
252
- st.markdown(link_text, unsafe_allow_html=True)
253
- if unique_id not in st.session_state.expanded_json:
254
- st.session_state.expanded_json.remove(unique_id) if unique_id in st.session_state.expanded_json else None
255
- if st.session_state.get("show_" + unique_id, False):
256
- st.code(json.dumps(rec, indent=2), language="json", key=unique_id)
257
- else:
258
- st.markdown(f"<div id='{unique_id}' style='display:none'>{json.dumps(rec, indent=2)}</div>", unsafe_allow_html=True)
259
  st.session_state.json_links = []
260
  st.session_state.json_link_details = {}
261
 
@@ -294,6 +286,5 @@ if st.button("Clear chat"):
294
  st.session_state.messages = []
295
  st.session_state.json_links = []
296
  st.session_state.json_link_details = {}
297
- st.session_state.expanded_json = set()
298
 
299
  st.info(f"Batches ingested so far (this session): {st.session_state.ingested_batches}")
 
26
  st.session_state.json_links = []
27
  if "json_link_details" not in st.session_state:
28
  st.session_state.json_link_details = {}
 
 
29
 
30
  st.set_page_config(page_title="Chat with Your JSON Vectors (Hybrid, Clean)", layout="wide")
31
  st.title("Chat with Your Vectorized JSON Files")
 
241
  # Only show for the last assistant answer if there are matching JSONs
242
  if not st.session_state.json_links:
243
  return
 
244
  for idx, link_key in enumerate(st.session_state.json_links):
245
  label = st.session_state.json_link_details[link_key]['label']
246
  rec = st.session_state.json_link_details[link_key]['record']
247
+ expander_label = f"<span style='font-size:11px; color:#444; text-decoration:underline;'>[view JSON]</span> <span style='font-size:10px; color:#aaa'>{label}</span>"
248
+ with st.expander(label="", expanded=False):
249
+ st.markdown(expander_label, unsafe_allow_html=True)
250
+ st.code(json.dumps(rec, indent=2), language="json")
 
 
 
 
 
251
  st.session_state.json_links = []
252
  st.session_state.json_link_details = {}
253
 
 
286
  st.session_state.messages = []
287
  st.session_state.json_links = []
288
  st.session_state.json_link_details = {}
 
289
 
290
  st.info(f"Batches ingested so far (this session): {st.session_state.ingested_batches}")