Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,6 +60,7 @@ 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 |
index_size = os.path.getsize(index_file_path)
|
| 64 |
print(f"Size of {index_file_path}: {index_size} bytes") #let me know how big json file is.
|
| 65 |
return GPTSimpleVectorIndex.load_from_disk(index_file_path)
|
|
@@ -67,6 +68,12 @@ def get_index(index_file_path):
|
|
| 67 |
print(f"Error: '{index_file_path}' does not exist.")
|
| 68 |
sys.exit()
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
print(f"Creating index...")
|
| 71 |
index = get_index(INDEX_FILE)
|
| 72 |
|
|
|
|
| 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 |
+
load_json_file(index_file_path)
|
| 64 |
index_size = os.path.getsize(index_file_path)
|
| 65 |
print(f"Size of {index_file_path}: {index_size} bytes") #let me know how big json file is.
|
| 66 |
return GPTSimpleVectorIndex.load_from_disk(index_file_path)
|
|
|
|
| 68 |
print(f"Error: '{index_file_path}' does not exist.")
|
| 69 |
sys.exit()
|
| 70 |
|
| 71 |
+
def load_json_file(filepath):
|
| 72 |
+
with open(filepath, 'r') as f:
|
| 73 |
+
file_contents = f.read()
|
| 74 |
+
print(file_contents[:500]) # print only the first 500 characters
|
| 75 |
+
return json.loads(file_contents)
|
| 76 |
+
|
| 77 |
print(f"Creating index...")
|
| 78 |
index = get_index(INDEX_FILE)
|
| 79 |
|