louiecerv commited on
Commit
7f1a08b
·
1 Parent(s): 7404ad7

Fixed minor bugs

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -42,7 +42,7 @@ if uploaded_file is not None:
42
  mime_type = "application/pdf"
43
  else:
44
  st.error("Unsupported file type. Please upload an image or PDF.")
45
- return
46
 
47
  # Reset chat history when a new file is uploaded
48
  reset_chat()
@@ -60,21 +60,22 @@ if uploaded_file is not None:
60
  for message in st.session_state.messages:
61
  with st.chat_message(message["role"]):
62
  st.markdown(message["content"])
63
-
64
- # Upload the file with the correct MIME type
65
- file_data = genai.upload_file(uploaded_file, mime_type=mime_type)
66
-
67
- # Send file and prompt to Gemini API
68
- response = model.generate_content(
69
- [
70
- user_input,
71
- file_data
72
- ]
73
- )
74
-
75
- # Add Gemini response to chat history
76
- st.session_state.messages.append({"role": "assistant", "content": response.text})
77
-
78
- # Display Gemini response
79
- with st.chat_message("assistant"):
80
- st.markdown(response.text)
 
 
42
  mime_type = "application/pdf"
43
  else:
44
  st.error("Unsupported file type. Please upload an image or PDF.")
45
+ st.stop()
46
 
47
  # Reset chat history when a new file is uploaded
48
  reset_chat()
 
60
  for message in st.session_state.messages:
61
  with st.chat_message(message["role"]):
62
  st.markdown(message["content"])
63
+
64
+ with st.spinner("Processing..."):
65
+ # Upload the file with the correct MIME type
66
+ file_data = genai.upload_file(uploaded_file, mime_type=mime_type)
67
+
68
+ # Send file and prompt to Gemini API
69
+ response = model.generate_content(
70
+ [
71
+ user_input,
72
+ file_data
73
+ ]
74
+ )
75
+
76
+ # Add Gemini response to chat history
77
+ st.session_state.messages.append({"role": "assistant", "content": response.text})
78
+
79
+ # Display Gemini response
80
+ with st.chat_message("assistant"):
81
+ st.markdown(response.text)