Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,12 +60,16 @@ def store_message(chatinput: str, chatresponse: str):
|
|
| 60 |
#gets the precompiled index file which is the context data compiled into a vector index
|
| 61 |
def get_index(index_file_path):
|
| 62 |
if os.path.exists(index_file_path):
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
else:
|
| 68 |
-
print(f"Error: '{index_file_path}' does not exist.")
|
| 69 |
sys.exit()
|
| 70 |
|
| 71 |
def load_json_file(filepath):
|
|
@@ -73,7 +77,6 @@ def load_json_file(filepath):
|
|
| 73 |
file_contents = f.read()
|
| 74 |
print(file_contents[:500]) # print only the first 500 characters
|
| 75 |
|
| 76 |
-
print(f"Creating index...")
|
| 77 |
index = get_index(INDEX_FILE)
|
| 78 |
|
| 79 |
# passes the prompt to the chatbot
|
|
|
|
| 60 |
#gets the precompiled index file which is the context data compiled into a vector index
|
| 61 |
def get_index(index_file_path):
|
| 62 |
if os.path.exists(index_file_path):
|
| 63 |
+
print(f"Loading index from {index_file_path}...")
|
| 64 |
+
try:
|
| 65 |
+
index = GPTSimpleVectorIndex.load_from_disk(index_file_path)
|
| 66 |
+
print(f"Index loaded successfully.")
|
| 67 |
+
return index
|
| 68 |
+
except Exception as e:
|
| 69 |
+
print(f"Failed to load index from disk: {str(e)}")
|
| 70 |
+
sys.exit()
|
| 71 |
else:
|
| 72 |
+
print(f"Error: Index file '{index_file_path}' does not exist.")
|
| 73 |
sys.exit()
|
| 74 |
|
| 75 |
def load_json_file(filepath):
|
|
|
|
| 77 |
file_contents = f.read()
|
| 78 |
print(file_contents[:500]) # print only the first 500 characters
|
| 79 |
|
|
|
|
| 80 |
index = get_index(INDEX_FILE)
|
| 81 |
|
| 82 |
# passes the prompt to the chatbot
|