Updated app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from llama_cpp import Llama
|
4 |
from huggingface_hub import snapshot_download, login
|
5 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
6 |
-
import
|
7 |
import numpy as np
|
8 |
|
9 |
#--------------------MODEL SETUP--------------------
|
@@ -35,7 +35,7 @@ def update_rag_index():
|
|
35 |
if not documents:
|
36 |
return
|
37 |
vectors = vectorizer.fit_transform(documents).toarray().asype('float32')
|
38 |
-
index =
|
39 |
index.add(vectors)
|
40 |
|
41 |
def retrive_relvant_docs(query, k=2):
|
|
|
3 |
from llama_cpp import Llama
|
4 |
from huggingface_hub import snapshot_download, login
|
5 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
6 |
+
import faiss
|
7 |
import numpy as np
|
8 |
|
9 |
#--------------------MODEL SETUP--------------------
|
|
|
35 |
if not documents:
|
36 |
return
|
37 |
vectors = vectorizer.fit_transform(documents).toarray().asype('float32')
|
38 |
+
index = faiss.IndexFlatL2(vectors.shape[1])
|
39 |
index.add(vectors)
|
40 |
|
41 |
def retrive_relvant_docs(query, k=2):
|