Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ from litellm import completion
|
|
8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
|
10 |
from huggingface_hub import login
|
|
|
|
|
11 |
|
12 |
|
13 |
token=os.getenv("HF_TOKEN")
|
@@ -49,6 +51,19 @@ index = faiss.read_index(doc_path)
|
|
49 |
if not index:
|
50 |
print("Problème index")
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def qa(question):
|
53 |
"""Fonction principale pour répondre à la question en utilisant RAG avec jusqu'à 5 chunks."""
|
54 |
|
|
|
8 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
|
10 |
from huggingface_hub import login
|
11 |
+
import pickle
|
12 |
+
|
13 |
|
14 |
|
15 |
token=os.getenv("HF_TOKEN")
|
|
|
51 |
if not index:
|
52 |
print("Problème index")
|
53 |
|
54 |
+
# Télécharger le fichier depuis le Hub
|
55 |
+
doc_path = hf_hub_download(repo_id="xavierbarbier/rag_ngap", filename="resource/fichier_chunks.pkl", repo_type="space")
|
56 |
+
|
57 |
+
# Charger les chunks depuis le fichier pickle
|
58 |
+
with open(doc_path, "rb") as f:
|
59 |
+
chunks = pickle.load(f)
|
60 |
+
|
61 |
+
if not chunks:
|
62 |
+
print("Problème chunks")
|
63 |
+
|
64 |
+
if len(chunks):
|
65 |
+
print("Problème len chunks")
|
66 |
+
|
67 |
def qa(question):
|
68 |
"""Fonction principale pour répondre à la question en utilisant RAG avec jusqu'à 5 chunks."""
|
69 |
|