Spaces:
Build error
Build error
Update app.py
Browse filesremoved Documents dir, files will be stored as txt in project folder
app.py
CHANGED
|
@@ -28,17 +28,11 @@ embedding_dim = 768 # Adjust according to model
|
|
| 28 |
|
| 29 |
# Initialize FAISS index
|
| 30 |
index = faiss.IndexFlatL2(embedding_dim)
|
| 31 |
-
documents = [] # Store raw text for reference
|
| 32 |
|
| 33 |
# Initialize paths
|
| 34 |
-
DOCUMENT_DIR = os.path.join(os.path.dirname(__file__), "documents")
|
| 35 |
INDEX_FILE = "faiss_index.bin" # FAISS index file (binary format)
|
| 36 |
METADATA_FILE = "metadata.json" # Document metadata
|
| 37 |
|
| 38 |
-
# Create the documents directory if it doesn’t exist
|
| 39 |
-
os.makedirs(DOCUMENT_DIR, exist_ok=True)
|
| 40 |
-
|
| 41 |
-
|
| 42 |
print(os.getcwd()) # This will print the current working directory
|
| 43 |
print(os.listdir(".")) # This will show files in the current director
|
| 44 |
|
|
@@ -63,7 +57,7 @@ def store_document(text):
|
|
| 63 |
|
| 64 |
# Generate a unique filename
|
| 65 |
doc_id = len(metadata) + 1
|
| 66 |
-
filename =
|
| 67 |
print(f"Saving document at: {filename}")
|
| 68 |
|
| 69 |
# Save document to file
|
|
|
|
| 28 |
|
| 29 |
# Initialize FAISS index
|
| 30 |
index = faiss.IndexFlatL2(embedding_dim)
|
|
|
|
| 31 |
|
| 32 |
# Initialize paths
|
|
|
|
| 33 |
INDEX_FILE = "faiss_index.bin" # FAISS index file (binary format)
|
| 34 |
METADATA_FILE = "metadata.json" # Document metadata
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
print(os.getcwd()) # This will print the current working directory
|
| 37 |
print(os.listdir(".")) # This will show files in the current director
|
| 38 |
|
|
|
|
| 57 |
|
| 58 |
# Generate a unique filename
|
| 59 |
doc_id = len(metadata) + 1
|
| 60 |
+
filename = f"doc_{doc_id}.txt"
|
| 61 |
print(f"Saving document at: {filename}")
|
| 62 |
|
| 63 |
# Save document to file
|