codelion commited on
Commit
591125d
·
verified ·
1 Parent(s): 55a428a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -28
app.py CHANGED
@@ -9,6 +9,13 @@ import json
9
  import random
10
  import urllib.parse
11
  import time
 
 
 
 
 
 
 
12
 
13
  # Initialize the Google Generative AI client with the API key from environment variables
14
  try:
@@ -1059,40 +1066,14 @@ with gr.Blocks(
1059
  user_input.submit(
1060
  fn=start_feed,
1061
  inputs=[user_input, generate_video_checkbox, current_index, feed_items],
1062
- outputs=[current_user_input, current_index, feed_items, feed_html, share_html, is_loading],
1063
- _js="""
1064
- async (user_input, generate_video, current_index, feed_items) => {
1065
- const results = [];
1066
- for await (const update of gradioApp().fn_stream(start_feed, [user_input, generate_video, current_index, feed_items])) {
1067
- results.push(update);
1068
- if (update.length === 4) { // Progress update
1069
- const [progress, message, html_content, is_loading] = update;
1070
- gradioApp().update_component('feed_html', { value: html_content });
1071
- }
1072
- }
1073
- return results[results.length - 1]; // Return final result
1074
- }
1075
- """
1076
  )
1077
 
1078
  # Handle magic button click to generate next item
1079
  magic_button.click(
1080
  fn=load_next,
1081
  inputs=[user_input, generate_video_checkbox, current_index, feed_items],
1082
- outputs=[current_user_input, current_index, feed_items, feed_html, share_html, is_loading],
1083
- _js="""
1084
- async (user_input, generate_video, current_index, feed_items) => {
1085
- const results = [];
1086
- for await (const update of gradioApp().fn_stream(load_next, [user_input, generate_video, current_index, feed_items])) {
1087
- results.push(update);
1088
- if (update.length === 4) { // Progress update
1089
- const [progress, message, html_content, is_loading] = update;
1090
- gradioApp().update_component('feed_html', { value: html_content });
1091
- }
1092
- }
1093
- return results[results.length - 1]; // Return final result
1094
- }
1095
- """
1096
  )
1097
 
1098
  # Hidden button for previous item navigation
 
9
  import random
10
  import urllib.parse
11
  import time
12
+ import gradio
13
+
14
+ # Check Gradio version
15
+ required_version = "4.44.0"
16
+ current_version = gradio.__version__
17
+ if current_version < required_version:
18
+ raise ValueError(f"Gradio version {current_version} is outdated. Please upgrade to {required_version} or later using 'pip install gradio=={required_version}'.")
19
 
20
  # Initialize the Google Generative AI client with the API key from environment variables
21
  try:
 
1066
  user_input.submit(
1067
  fn=start_feed,
1068
  inputs=[user_input, generate_video_checkbox, current_index, feed_items],
1069
+ outputs=[current_user_input, current_index, feed_items, feed_html, share_html, is_loading]
 
 
 
 
 
 
 
 
 
 
 
 
 
1070
  )
1071
 
1072
  # Handle magic button click to generate next item
1073
  magic_button.click(
1074
  fn=load_next,
1075
  inputs=[user_input, generate_video_checkbox, current_index, feed_items],
1076
+ outputs=[current_user_input, current_index, feed_items, feed_html, share_html, is_loading]
 
 
 
 
 
 
 
 
 
 
 
 
 
1077
  )
1078
 
1079
  # Hidden button for previous item navigation