Spaces:
Running
Running
File size: 1,198 Bytes
7110704 0644d4b 7110704 0644d4b 7110704 0644d4b 7110704 0644d4b 7110704 0644d4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
import streamlit as st
import utils
# Set up the sidebar
# Ask the user for an API key in the sidebar
os.environ["OPENAI_API_KEY"] = st.sidebar.text_input("Your OpenAI API Key", type="password")
st.sidebar.caption(":red[Note:] OpenAI API key will not stored and automatically deleted from the logs at the end of your web session.")
# Display a title
st.title("Invoice Buddy")
# Short description of the app
st.markdown("""
### Extract information from invoices
""")
if os.environ["OPENAI_API_KEY"] == "":
disable_file_uploader = True
st.error('Kindly enter OpenAI API key')
else:
disable_file_uploader = False
# Add a file uploader widget
uploaded_file = st.file_uploader("Upload invoice image (png, jpg, jpeg)", type=['png', 'jpg'], disabled=disable_file_uploader)
if uploaded_file is not None:
utils.empty_directory('data')
utils.save_uploaded_file('data', uploaded_file)
response = utils.pass_to_openai_vision_api(uploaded_file)
st.markdown('Data extracted from invoice is ')
st.markdown(response)
utils.make_discord_trace_multimodal(image_path=os.path.join('data', uploaded_file.name), text_message=response)
utils.empty_directory('data') |