Spaces:
Runtime error
Runtime error
Resolve merge conflicts
Browse files- app.py +8 -5
- packages.txt +3 -1
- requirements-hf.txt +12 -4
app.py
CHANGED
|
@@ -203,16 +203,19 @@ except Exception as e:
|
|
| 203 |
print(f"⚠️ Error initializing vector store: {str(e)}")
|
| 204 |
raise
|
| 205 |
|
| 206 |
-
#
|
| 207 |
def get_similar_passages(query, k=5):
|
| 208 |
query_embedding = embeddings.embed_query(query)
|
| 209 |
-
|
| 210 |
-
return [texts[i] for i in I[0]]
|
| 211 |
|
| 212 |
# Setup retriever function
|
| 213 |
def get_context(query):
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
# ----------------------
|
| 218 |
# 3️⃣ Gemini LLM + RAG Chain
|
|
|
|
| 203 |
print(f"⚠️ Error initializing vector store: {str(e)}")
|
| 204 |
raise
|
| 205 |
|
| 206 |
+
# Initialize the similarity search function
|
| 207 |
def get_similar_passages(query, k=5):
|
| 208 |
query_embedding = embeddings.embed_query(query)
|
| 209 |
+
return similarity_search(query_embedding, k)
|
|
|
|
| 210 |
|
| 211 |
# Setup retriever function
|
| 212 |
def get_context(query):
|
| 213 |
+
try:
|
| 214 |
+
passages = get_similar_passages(query)
|
| 215 |
+
return "\n\n".join(passages)
|
| 216 |
+
except Exception as e:
|
| 217 |
+
print(f"⚠️ Error in retrieval: {str(e)}")
|
| 218 |
+
return "The Archives are experiencing difficulties retrieving the information."
|
| 219 |
|
| 220 |
# ----------------------
|
| 221 |
# 3️⃣ Gemini LLM + RAG Chain
|
packages.txt
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
python3-dev
|
| 2 |
build-essential
|
|
|
|
| 3 |
libpq-dev
|
| 4 |
ffmpeg
|
| 5 |
git
|
| 6 |
-
git-lfs
|
|
|
|
|
|
| 1 |
python3-dev
|
| 2 |
build-essential
|
| 3 |
+
libopenblas-dev
|
| 4 |
libpq-dev
|
| 5 |
ffmpeg
|
| 6 |
git
|
| 7 |
+
git-lfs
|
| 8 |
+
pkg-config
|
requirements-hf.txt
CHANGED
|
@@ -10,10 +10,18 @@ transformers==4.31.0
|
|
| 10 |
torch==2.0.1
|
| 11 |
numpy==1.24.3
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
scikit-learn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Utilities
|
| 19 |
requests==2.31.0
|
|
|
|
| 10 |
torch==2.0.1
|
| 11 |
numpy==1.24.3
|
| 12 |
|
| 13 |
+
# Core ML dependencies (install order matters)
|
| 14 |
+
numpy==1.24.3
|
| 15 |
+
scipy==1.11.3
|
| 16 |
+
scikit-learn==1.3.0
|
| 17 |
+
|
| 18 |
+
# Vector store
|
| 19 |
+
faiss-cpu
|
| 20 |
+
faiss-gpu
|
| 21 |
+
|
| 22 |
+
# Additional ML dependencies
|
| 23 |
+
threadpoolctl>=3.2.0
|
| 24 |
+
joblib>=1.3.2
|
| 25 |
|
| 26 |
# Utilities
|
| 27 |
requests==2.31.0
|