Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,8 @@ if "thread_id" not in st.session_state:
|
|
| 27 |
st.session_state.thread_id = None
|
| 28 |
if "image_url" not in st.session_state:
|
| 29 |
st.session_state.image_url = None
|
|
|
|
|
|
|
| 30 |
|
| 31 |
# ------------------ Sidebar Controls ------------------
|
| 32 |
st.sidebar.header("π§ Settings")
|
|
@@ -34,6 +36,7 @@ if st.sidebar.button("π Clear Chat"):
|
|
| 34 |
st.session_state.messages = []
|
| 35 |
st.session_state.thread_id = None
|
| 36 |
st.session_state.image_url = None
|
|
|
|
| 37 |
st.rerun()
|
| 38 |
|
| 39 |
show_image = st.sidebar.checkbox("π Show Document Image", value=True)
|
|
@@ -45,6 +48,7 @@ col1, col2 = st.columns([1, 2]) # Adjust ratio as needed
|
|
| 45 |
with col1:
|
| 46 |
if show_image and st.session_state.image_url:
|
| 47 |
st.image(st.session_state.image_url, caption="π Extracted Page", use_container_width=True)
|
|
|
|
| 48 |
|
| 49 |
# ------------------ Chat Panel (Right) ------------------
|
| 50 |
with col2:
|
|
@@ -106,6 +110,8 @@ with col2:
|
|
| 106 |
)
|
| 107 |
if image_match:
|
| 108 |
st.session_state.image_url = image_match.group(0)
|
|
|
|
|
|
|
| 109 |
|
| 110 |
except Exception as e:
|
| 111 |
st.error(f"β Error: {str(e)}")
|
|
|
|
| 27 |
st.session_state.thread_id = None
|
| 28 |
if "image_url" not in st.session_state:
|
| 29 |
st.session_state.image_url = None
|
| 30 |
+
if "image_updated" not in st.session_state:
|
| 31 |
+
st.session_state.image_updated = False
|
| 32 |
|
| 33 |
# ------------------ Sidebar Controls ------------------
|
| 34 |
st.sidebar.header("π§ Settings")
|
|
|
|
| 36 |
st.session_state.messages = []
|
| 37 |
st.session_state.thread_id = None
|
| 38 |
st.session_state.image_url = None
|
| 39 |
+
st.session_state.image_updated = False
|
| 40 |
st.rerun()
|
| 41 |
|
| 42 |
show_image = st.sidebar.checkbox("π Show Document Image", value=True)
|
|
|
|
| 48 |
with col1:
|
| 49 |
if show_image and st.session_state.image_url:
|
| 50 |
st.image(st.session_state.image_url, caption="π Extracted Page", use_container_width=True)
|
| 51 |
+
st.session_state.image_updated = False # Reset flag after rendering
|
| 52 |
|
| 53 |
# ------------------ Chat Panel (Right) ------------------
|
| 54 |
with col2:
|
|
|
|
| 110 |
)
|
| 111 |
if image_match:
|
| 112 |
st.session_state.image_url = image_match.group(0)
|
| 113 |
+
st.session_state.image_updated = True
|
| 114 |
+
st.rerun() # Trigger rerun to refresh image display
|
| 115 |
|
| 116 |
except Exception as e:
|
| 117 |
st.error(f"β Error: {str(e)}")
|