Spaces:
Sleeping
Sleeping
CB commited on
Update streamlit_app.py
Browse files- streamlit_app.py +8 -18
streamlit_app.py
CHANGED
|
@@ -261,14 +261,7 @@ def upload_video_sdk(filepath: str):
|
|
| 261 |
if not HAS_GENAI or upload_file is None:
|
| 262 |
raise RuntimeError("google.generativeai SDK not available; cannot upload")
|
| 263 |
genai.configure(api_key=key)
|
| 264 |
-
|
| 265 |
-
# Include the ragStoreName parameter
|
| 266 |
-
rag_config = {
|
| 267 |
-
'ragStoreName': 'your_rag_store_name' # Specify your ragStoreName here
|
| 268 |
-
}
|
| 269 |
-
genai.configure_rag_context(rag_config) # Hypothetical function to configure
|
| 270 |
-
|
| 271 |
-
return upload_file(filepath) # Ensure this is the correct call function
|
| 272 |
|
| 273 |
def wait_for_processed(file_obj, timeout: int = None):
|
| 274 |
if timeout is None:
|
|
@@ -447,16 +440,13 @@ if generate_now and not st.session_state.get("busy"):
|
|
| 447 |
local_path = current_path
|
| 448 |
upload_path, compressed = compress_video_if_large(local_path, threshold_mb=st.session_state.get("compress_threshold_mb", 200))
|
| 449 |
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
# Configure the context for using RAG
|
| 453 |
-
try:
|
| 454 |
-
genai.configure_rag_context({'ragStoreName': rag_store_name}) # Hypothetical function
|
| 455 |
-
with st.spinner(f"Uploading video{' (compressed)' if compressed else ''}..."):
|
| 456 |
uploaded = upload_video_sdk(upload_path)
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
|
|
|
| 460 |
|
| 461 |
try:
|
| 462 |
processing_placeholder = st.empty()
|
|
@@ -621,4 +611,4 @@ if generate_now and not st.session_state.get("busy"):
|
|
| 621 |
st.session_state["last_error"] = f"{e}\n{traceback.format_exc()}"
|
| 622 |
st.error("An error occurred while generating the story. You can try Generate again; the uploaded video will be reused.")
|
| 623 |
finally:
|
| 624 |
-
st.session_state["busy"] = False
|
|
|
|
| 261 |
if not HAS_GENAI or upload_file is None:
|
| 262 |
raise RuntimeError("google.generativeai SDK not available; cannot upload")
|
| 263 |
genai.configure(api_key=key)
|
| 264 |
+
return upload_file(filepath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
def wait_for_processed(file_obj, timeout: int = None):
|
| 267 |
if timeout is None:
|
|
|
|
| 440 |
local_path = current_path
|
| 441 |
upload_path, compressed = compress_video_if_large(local_path, threshold_mb=st.session_state.get("compress_threshold_mb", 200))
|
| 442 |
|
| 443 |
+
with st.spinner(f"Uploading video{' (compressed)' if compressed else ''}..."):
|
| 444 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
uploaded = upload_video_sdk(upload_path)
|
| 446 |
+
except Exception as e:
|
| 447 |
+
st.session_state["last_error"] = f"Upload failed for {upload_path}: {e}\n{traceback.format_exc()}"
|
| 448 |
+
st.error(f"Upload failed: {e}. Check the error log for more details.")
|
| 449 |
+
return # Prevent further processing.
|
| 450 |
|
| 451 |
try:
|
| 452 |
processing_placeholder = st.empty()
|
|
|
|
| 611 |
st.session_state["last_error"] = f"{e}\n{traceback.format_exc()}"
|
| 612 |
st.error("An error occurred while generating the story. You can try Generate again; the uploaded video will be reused.")
|
| 613 |
finally:
|
| 614 |
+
st.session_state["busy"] = False
|