xavierbarbier commited on
Commit
fd3b445
·
verified ·
1 Parent(s): e7006d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -60,8 +60,10 @@ def get_text_embedding(text):
60
 
61
  return embeddings.embed_query(text)
62
 
63
- doc_path = hf_hub_download(repo_id="xavierbarbier/rag_ngap", filename="resource/NGAP 01042024.pdf", repo_type="space")
64
 
 
 
65
  reader = PdfReader( doc_path )
66
 
67
 
@@ -80,7 +82,7 @@ text_embeddings = np.array([get_text_embedding(chunk) for chunk in chunks])
80
 
81
  d = text_embeddings.shape[1]
82
  index = faiss.IndexFlatL2(d)
83
- index.add(text_embeddings)
84
 
85
 
86
  def extract_text(file):
@@ -121,7 +123,7 @@ def qa(question):
121
  return prompt
122
 
123
  def test_func(text):
124
- return len(text_embeddings)
125
 
126
  with gr.Blocks() as demo:
127
 
 
60
 
61
  return embeddings.embed_query(text)
62
 
63
+ doc_path = hf_hub_download(repo_id="xavierbarbier/rag_ngap", filename="resource/embeddings_ngap.faiss", repo_type="space")
64
 
65
+ index = faiss.read_index(doc_path)
66
+ """
67
  reader = PdfReader( doc_path )
68
 
69
 
 
82
 
83
  d = text_embeddings.shape[1]
84
  index = faiss.IndexFlatL2(d)
85
+ index.add(text_embeddings)"""
86
 
87
 
88
  def extract_text(file):
 
123
  return prompt
124
 
125
  def test_func(text):
126
+ return len(index)
127
 
128
  with gr.Blocks() as demo:
129