Peter commited on
Commit
079d1ca
1 Parent(s): 34de38e

🎨 format

Browse files

Signed-off-by: Peter <[email protected]>

Files changed (2) hide show
  1. app.py +5 -5
  2. utils.py +11 -4
app.py CHANGED
@@ -299,11 +299,11 @@ if __name__ == "__main__":
299
  )
300
 
301
  text_file = gr.File(
302
- label="Download Summary as Text File",
303
- file_count="single",
304
- type="file",
305
- interactive=False,
306
- )
307
 
308
  gr.Markdown("---")
309
  with gr.Column():
 
299
  )
300
 
301
  text_file = gr.File(
302
+ label="Download Summary as Text File",
303
+ file_count="single",
304
+ type="file",
305
+ interactive=False,
306
+ )
307
 
308
  gr.Markdown("---")
309
  with gr.Column():
utils.py CHANGED
@@ -8,13 +8,16 @@ from datetime import datetime
8
  from natsort import natsorted
9
  import subprocess
10
 
11
- def get_timestamp()->str:
 
12
  """
13
  get_timestamp - get a timestamp for the current time
14
  Returns:
15
  str, the timestamp
16
  """
17
  return datetime.now().strftime("%Y%m%d_%H%M%S")
 
 
18
  def truncate_word_count(text, max_words=512):
19
  """
20
  truncate_word_count - a helper function for the gradio module
@@ -74,7 +77,8 @@ def load_example_filenames(example_path: str or Path):
74
  examples = {f.name: f for f in example_path.glob("*.txt")}
75
  return examples
76
 
77
- def saves_summary(summarize_output, outpath:str or Path=None, add_signature=True):
 
78
  """
79
 
80
  saves_summary - save the summary generated from summarize_via_tokenbatches() to a text file
@@ -87,8 +91,11 @@ def saves_summary(summarize_output, outpath:str or Path=None, add_signature=True
87
  )
88
  """
89
 
90
-
91
- outpath = Path.cwd() / f"document_summary_{get_timestamp()}.txt" if outpath is None else Path(outpath)
 
 
 
92
  sum_text = [s["summary"][0] for s in summarize_output]
93
  sum_scores = [f"\n - {round(s['summary_score'],4)}" for s in summarize_output]
94
  scores_text = "\n".join(sum_scores)
 
8
  from natsort import natsorted
9
  import subprocess
10
 
11
+
12
+ def get_timestamp() -> str:
13
  """
14
  get_timestamp - get a timestamp for the current time
15
  Returns:
16
  str, the timestamp
17
  """
18
  return datetime.now().strftime("%Y%m%d_%H%M%S")
19
+
20
+
21
  def truncate_word_count(text, max_words=512):
22
  """
23
  truncate_word_count - a helper function for the gradio module
 
77
  examples = {f.name: f for f in example_path.glob("*.txt")}
78
  return examples
79
 
80
+
81
+ def saves_summary(summarize_output, outpath: str or Path = None, add_signature=True):
82
  """
83
 
84
  saves_summary - save the summary generated from summarize_via_tokenbatches() to a text file
 
91
  )
92
  """
93
 
94
+ outpath = (
95
+ Path.cwd() / f"document_summary_{get_timestamp()}.txt"
96
+ if outpath is None
97
+ else Path(outpath)
98
+ )
99
  sum_text = [s["summary"][0] for s in summarize_output]
100
  sum_scores = [f"\n - {round(s['summary_score'],4)}" for s in summarize_output]
101
  scores_text = "\n".join(sum_scores)