-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_dashboard.py
More file actions
22 lines (19 loc) · 912 Bytes
/
patch_dashboard.py
File metadata and controls
22 lines (19 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
path = "D:/Projects/Research2Text-main/src/app_streamlit.py"
with open(path, "r", encoding="utf-8") as f:
code = f.read()
target = """ for i, chunk in enumerate(chunks[:5]):
with st.expander(f"Chunk {i+1}", expanded=False):
st.text(chunk.get("text", "")[:500])"""
replacement = """ for i, chunk in enumerate(chunks[:5]):
with st.expander(f"Chunk {i+1}", expanded=False):
if isinstance(chunk, str):
st.text(chunk[:500])
else:
st.text(chunk.get("text", "")[:500])"""
if target in code:
code = code.replace(target, replacement)
with open(path, "w", encoding="utf-8") as f:
f.write(code)
print("Successfully patched app_streamlit.py")
else:
print("Target not found in app_streamlit.py")