CCockrum commited on
Commit
4018845
·
verified ·
1 Parent(s): 92aeff5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -6,7 +6,7 @@ import requests
6
  import os
7
  from transformers import pipeline
8
  import datetime
9
- import io
10
 
11
  # Initialize Summarizer
12
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
@@ -150,16 +150,16 @@ def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=50000000
150
  return summary, info_table, ratios_table, sector_comp, fig
151
 
152
  def download_report(info_table, ratios_table, sector_comp, summary):
153
- buffer = io.StringIO()
154
- info_table.to_csv(buffer, index=False)
155
- buffer.write("\n")
156
- ratios_table.to_csv(buffer, index=False)
157
- buffer.write("\n")
158
- sector_comp.to_csv(buffer, index=False)
159
- buffer.write("\nSummary\n")
160
- buffer.write(summary)
161
- buffer.seek(0)
162
- return buffer
163
 
164
  with gr.Blocks() as iface:
165
  with gr.Row():
@@ -197,4 +197,4 @@ with gr.Blocks() as iface:
197
  )
198
 
199
  if __name__ == "__main__":
200
- iface.launch()
 
6
  import os
7
  from transformers import pipeline
8
  import datetime
9
+ import tempfile
10
 
11
  # Initialize Summarizer
12
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
 
150
  return summary, info_table, ratios_table, sector_comp, fig
151
 
152
  def download_report(info_table, ratios_table, sector_comp, summary):
153
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".csv", mode='w') as f:
154
+ info_table.to_csv(f, index=False)
155
+ f.write("\n")
156
+ ratios_table.to_csv(f, index=False)
157
+ f.write("\n")
158
+ sector_comp.to_csv(f, index=False)
159
+ f.write("\nSummary\n")
160
+ f.write(summary)
161
+ file_path = f.name
162
+ return file_path
163
 
164
  with gr.Blocks() as iface:
165
  with gr.Row():
 
197
  )
198
 
199
  if __name__ == "__main__":
200
+ iface.launch()