Neom99 commited on
Commit
40e6eee
·
verified ·
1 Parent(s): 8585ec5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -66,7 +66,7 @@ else:
66
  print("RAG functionality will not work without a valid Google API key and accessible model.")
67
 
68
  # Global variable to store the PARSED DATAFRAME for download functions
69
- # FOR VERY LARGE DATASETS, THIS WOULD BE REPLACED BY DATABASE CALLS
70
  global_analysis_df_for_export = pd.DataFrame()
71
  global_raw_markdown_for_export = ""
72
 
@@ -923,7 +923,7 @@ def generate_pdf_report(user_timezone_str): # <--- NEW: Added user_timezone_str
923
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file:
924
  # Get the value from the BytesIO object and write it to the temporary file
925
  pdf.output(tmp_file.name) # FPDF can write directly to a file path
926
- temp_file_path = tmp_file.name # Get the path to the temporary file
927
 
928
  # Return update object for Gradio
929
  return gr.File.update(value=temp_file_path, visible=True, label="Download PDF Report")
@@ -1167,6 +1167,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
1167
  )
1168
 
1169
  # <--- NEW: JavaScript to detect and set user timezone on page load
 
1170
  demo.load(
1171
  fn=None, # No Python function needed for this part
1172
  _js="""
@@ -1176,12 +1177,10 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
1176
  if (timezoneInput) {
1177
  // Set the value directly for Gradio's internal state
1178
  // This might require more advanced Gradio internal methods for direct binding.
1179
- // For a simpler approach, we rely on Gradio's automatic value capture on click.
1180
- // The key is that the input element 'user-timezone-input' itself has its value attribute updated.
1181
- timezoneInput.value = userTimeZone;
1182
  // For immediate visual feedback or if Gradio's internal state needs explicit update:
1183
- // If Gradio version is new enough to support this pattern:
1184
- // timezoneInput.dispatchEvent(new Event('input', { bubbles: true })); // Trigger change event
 
1185
  }
1186
  }
1187
  """,
 
66
  print("RAG functionality will not work without a valid Google API key and accessible model.")
67
 
68
  # Global variable to store the PARSED DATAFRAME for download functions
69
+ # FOR VERY LARGE DATASETS, THIS WOULD BE BE REPLACED BY DATABASE CALLS
70
  global_analysis_df_for_export = pd.DataFrame()
71
  global_raw_markdown_for_export = ""
72
 
 
923
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file:
924
  # Get the value from the BytesIO object and write it to the temporary file
925
  pdf.output(tmp_file.name) # FPDF can write directly to a file path
926
+ temp_file_path = tmp_file.name
927
 
928
  # Return update object for Gradio
929
  return gr.File.update(value=temp_file_path, visible=True, label="Download PDF Report")
 
1167
  )
1168
 
1169
  # <--- NEW: JavaScript to detect and set user timezone on page load
1170
+ # This syntax requires Gradio 4.0.0+
1171
  demo.load(
1172
  fn=None, # No Python function needed for this part
1173
  _js="""
 
1177
  if (timezoneInput) {
1178
  // Set the value directly for Gradio's internal state
1179
  // This might require more advanced Gradio internal methods for direct binding.
 
 
 
1180
  // For immediate visual feedback or if Gradio's internal state needs explicit update:
1181
+ // timezoneInput.dispatchEvent(new Event('input', { bubbles: true })); // Trigger change event if needed for reactive update in some cases
1182
+ // However, for passing to a button click, just setting .value is usually enough.
1183
+ timezoneInput.value = userTimeZone;
1184
  }
1185
  }
1186
  """,