xavierbarbier commited on
Commit
4ec8b91
·
verified ·
1 Parent(s): 824cb42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -56,6 +56,11 @@ chunk_size = 2048
56
 
57
  print("Finish the model init process")
58
 
 
 
 
 
 
59
  def extract_text(file):
60
 
61
 
@@ -75,8 +80,10 @@ def extract_text(file):
75
  def summarise(text):
76
 
77
  chunks = [text[i:i + chunk_size] for i in range(0, len(text), chunk_size)]
 
 
78
 
79
- return len(chunks)
80
 
81
  with gr.Blocks() as demo:
82
  file_input = gr.File(label="Upload a PDF file")
 
56
 
57
  print("Finish the model init process")
58
 
59
+ def get_text_embedding(text):
60
+
61
+ return embeddings.embed_query(text)
62
+
63
+
64
  def extract_text(file):
65
 
66
 
 
80
  def summarise(text):
81
 
82
  chunks = [text[i:i + chunk_size] for i in range(0, len(text), chunk_size)]
83
+
84
+ text_embeddings = np.array([get_text_embedding(chunk) for chunk in chunks])
85
 
86
+ return len(text_embeddings)
87
 
88
  with gr.Blocks() as demo:
89
  file_input = gr.File(label="Upload a PDF file")