aasherkamal216 commited on
Commit
ef2e22a
·
unverified ·
1 Parent(s): bd1502e

Update test4.py

Browse files
Files changed (1) hide show
  1. test4.py +13 -14
test4.py CHANGED
@@ -129,20 +129,19 @@ def messages_to_gemini(messages):
129
  if file_name not in uploaded_files:
130
  temp_file_path = base64_to_temp_file(content[content["type"]], file_name, "mp4" if content["type"] == "video_file" else "wav")
131
  st.write(temp_file_path)
132
- for attempt in range(3):
133
- try:
134
- with st.spinner(f"Sending {content['type'].replace('_', ' ')} to Gemini..."):
135
- gemini_message["parts"].append(genai.upload_file(path=temp_file_path))
136
- st.write("Huraaaa")
137
- break
138
-
139
- except FailedPrecondition as e:
140
- if attempt < max_retries - 1:
141
- st.warning("Retrying file upload...")
142
- time.sleep(1) # Brief delay before retrying
143
- else:
144
- st.error("Failed to upload file after several attempts.")
145
- raise e
146
  os.remove(temp_file_path)
147
 
148
  elif content["type"] == "pdf_file":
 
129
  if file_name not in uploaded_files:
130
  temp_file_path = base64_to_temp_file(content[content["type"]], file_name, "mp4" if content["type"] == "video_file" else "wav")
131
  st.write(temp_file_path)
132
+
133
+ try:
134
+ with st.spinner(f"Sending {content['type'].replace('_', ' ')} to Gemini..."):
135
+ file = genai.upload_file(path=temp_file_path)
136
+ while video_file.state.name == "PROCESSING":
137
+ st.write('##----*---##')
138
+ time.sleep(10)
139
+ gemini_message["parts"].append(file)
140
+ st.write("Huraaaa")
141
+
142
+
143
+ except FailedPrecondition as e:
144
+ st.error(f"An error occurred {e}")
 
145
  os.remove(temp_file_path)
146
 
147
  elif content["type"] == "pdf_file":