mtyrrell commited on
Commit
2e14ef4
·
1 Parent(s): 2c0a6a2

Updated innovation delay; added auot file download

Browse files
Files changed (2) hide show
  1. app.py +20 -1
  2. src/pipeline/components/innovation.py +1 -1
app.py CHANGED
@@ -24,6 +24,8 @@ from src.pipeline.pipeline import process_data
24
  setup_logging()
25
  import logging
26
  from io import BytesIO
 
 
27
 
28
  logger = logging.getLogger(__name__)
29
 
@@ -211,8 +213,25 @@ def main():
211
  current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M-%S')
212
  output_filename = f'processed_applications_{current_datetime}.xlsx'
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  st.download_button(
215
- label="Download Analysis Data File",
216
  data=excel_buffer,
217
  file_name=output_filename,
218
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
 
24
  setup_logging()
25
  import logging
26
  from io import BytesIO
27
+ import base64
28
+ import streamlit.components.v1 as components
29
 
30
  logger = logging.getLogger(__name__)
31
 
 
213
  current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M-%S')
214
  output_filename = f'processed_applications_{current_datetime}.xlsx'
215
 
216
+ # Auto-download the file via JavaScript
217
+ b64 = base64.b64encode(excel_buffer.getvalue()).decode()
218
+ components.html(
219
+ f"""
220
+ <script>
221
+ const link = document.createElement('a');
222
+ link.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,{b64}';
223
+ link.download = '{output_filename}';
224
+ link.click();
225
+ </script>
226
+ """,
227
+ height=0,
228
+ )
229
+
230
+ st.success("Analysis complete — file downloaded automatically.")
231
+
232
+ # Fallback manual download button
233
  st.download_button(
234
+ label="Download Again",
235
  data=excel_buffer,
236
  file_name=output_filename,
237
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
src/pipeline/components/innovation.py CHANGED
@@ -70,6 +70,6 @@ def classify_innovation(client, deployment, concept_id: str, tech: str, rational
70
  response = call_structured(client, deployment, prompt, InnovationClassify, logger)
71
 
72
  # Rate limit delay to avoid 429 errors
73
- time.sleep(10)
74
 
75
  return response
 
70
  response = call_structured(client, deployment, prompt, InnovationClassify, logger)
71
 
72
  # Rate limit delay to avoid 429 errors
73
+ time.sleep(5)
74
 
75
  return response