Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ from helper import (
|
|
| 10 |
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
| 11 |
TEXTRACT_API_URL = "https://2tsig211e0.execute-api.us-east-1.amazonaws.com/my_textract"
|
| 12 |
|
| 13 |
-
st.set_page_config(page_title="Chat with OCR", layout="wide")
|
| 14 |
|
| 15 |
# Initialize chat history if not in session state
|
| 16 |
if "messages" not in st.session_state:
|
|
@@ -18,7 +18,7 @@ if "messages" not in st.session_state:
|
|
| 18 |
|
| 19 |
# Sidebar for image upload
|
| 20 |
with st.sidebar:
|
| 21 |
-
st.title("Upload and Display Images")
|
| 22 |
uploaded_image = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])
|
| 23 |
|
| 24 |
if uploaded_image:
|
|
@@ -41,6 +41,13 @@ with st.sidebar:
|
|
| 41 |
|
| 42 |
# Extract text from Textract
|
| 43 |
cleaned_up_body = extract_text_from_textract_blocks(result_dict['body'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# Main chat interface
|
| 46 |
st.title("Chat with OCR Output")
|
|
|
|
| 10 |
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
| 11 |
TEXTRACT_API_URL = "https://2tsig211e0.execute-api.us-east-1.amazonaws.com/my_textract"
|
| 12 |
|
| 13 |
+
st.set_page_config(page_title="💬 Chat with OCR 📝", layout="wide")
|
| 14 |
|
| 15 |
# Initialize chat history if not in session state
|
| 16 |
if "messages" not in st.session_state:
|
|
|
|
| 18 |
|
| 19 |
# Sidebar for image upload
|
| 20 |
with st.sidebar:
|
| 21 |
+
st.title("🖼️ Upload and Display Images")
|
| 22 |
uploaded_image = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])
|
| 23 |
|
| 24 |
if uploaded_image:
|
|
|
|
| 41 |
|
| 42 |
# Extract text from Textract
|
| 43 |
cleaned_up_body = extract_text_from_textract_blocks(result_dict['body'])
|
| 44 |
+
|
| 45 |
+
# Add some space at the bottom of the sidebar
|
| 46 |
+
st.sidebar.markdown("<br><br><br><br>", unsafe_allow_html=True)
|
| 47 |
+
|
| 48 |
+
# Clear session button at the bottom of the sidebar
|
| 49 |
+
if st.sidebar.button("Clear Session"):
|
| 50 |
+
st.session_state.messages = []
|
| 51 |
|
| 52 |
# Main chat interface
|
| 53 |
st.title("Chat with OCR Output")
|