JoFrost commited on
Commit
e20b45b
1 Parent(s): 794fcfd

fix: revert to old compression method for parquet file & now show 10 first emails subjects

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. email_200.parquet +2 -2
app.py CHANGED
@@ -17,9 +17,8 @@ title = "Confidential forensics tool with ChatGPT"
17
  examples = ["Who is Phillip Allen?", "What the project in Austin is about?", "Give me more details about the real estate project"]
18
 
19
  index = GPTSimpleVectorIndex.load_from_disk('email.json')
20
-
21
- dat_fr = pd.DataFrame({"Documents loaded": ["email.json", "email_200.parquet"]})
22
  df = pd.read_parquet("email_200.parquet")
 
23
 
24
  def search_emails(opt, message, n=3):
25
  "Outputs the top n emails that match the most the pattern"
@@ -34,7 +33,7 @@ def search_emails(opt, message, n=3):
34
  message_tmp = df.sort_values('similarities', ascending=False).head(n)
35
  message_tmp = [(row.file, row.body, row.similarities) for index, row in message_tmp.iterrows()]
36
  for msg in message_tmp:
37
- message += f"{msg[0]}\nContent: {msg[1].strip()}\n{msg[2]}\n\n"
38
  except Exception as e:
39
  message = "An error occured when handling your query, please try again."
40
  print(e)
@@ -78,9 +77,10 @@ with gr.Blocks(title=title) as demo:
78
  # """ + title + """
79
  """)
80
  dat = gr.Dataframe(
81
- value=dat_fr,
82
  max_cols=1,
83
  max_rows=4,
 
84
  overflow_row_behaviour="paginate",
85
  )
86
  btn_upload = gr.UploadButton("Upload a new document...", file_types=["text"])
 
17
  examples = ["Who is Phillip Allen?", "What the project in Austin is about?", "Give me more details about the real estate project"]
18
 
19
  index = GPTSimpleVectorIndex.load_from_disk('email.json')
 
 
20
  df = pd.read_parquet("email_200.parquet")
21
+ df2 = df["subject"].replace([None], "<no title>").head(10).to_frame()
22
 
23
  def search_emails(opt, message, n=3):
24
  "Outputs the top n emails that match the most the pattern"
 
33
  message_tmp = df.sort_values('similarities', ascending=False).head(n)
34
  message_tmp = [(row.file, row.body, row.similarities) for index, row in message_tmp.iterrows()]
35
  for msg in message_tmp:
36
+ message += f"Mail ID: {msg[0]}\nContent: {msg[1].strip()}\nSimilarity score: {msg[2]}\n\n"
37
  except Exception as e:
38
  message = "An error occured when handling your query, please try again."
39
  print(e)
 
77
  # """ + title + """
78
  """)
79
  dat = gr.Dataframe(
80
+ value=df2,
81
  max_cols=1,
82
  max_rows=4,
83
+ title="Documents loaded",
84
  overflow_row_behaviour="paginate",
85
  )
86
  btn_upload = gr.UploadButton("Upload a new document...", file_types=["text"])
email_200.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:059c095bad18d8c299ab701ca19ac1d938e82bba28af7d6e9a333bd20a35586a
3
- size 3098469
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:689f185923970ee7a8da61eb63ae2116d75af0a473dd2735c0848bc87b505135
3
+ size 8670196