peterpull commited on
Commit
870e32c
·
1 Parent(s): e94daa2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -57,24 +57,20 @@ def store_message(chatinput: str, chatresponse: str):
57
 
58
  return generate_text()
59
 
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):
76
  with open(filepath, 'r') as f:
77
  file_contents = f.read()
 
78
  print(file_contents[:500]) # print only the first 500 characters
79
 
80
  index = get_index(INDEX_FILE)
 
57
 
58
  return generate_text()
59
 
 
60
  def get_index(index_file_path):
61
  if os.path.exists(index_file_path):
62
+ load_json_file(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)
 
 
 
 
66
  else:
67
+ print(f"Error: '{index_file_path}' does not exist.")
68
  sys.exit()
69
 
70
  def load_json_file(filepath):
71
  with open(filepath, 'r') as f:
72
  file_contents = f.read()
73
+ print ("JSON FILE HEADER:")
74
  print(file_contents[:500]) # print only the first 500 characters
75
 
76
  index = get_index(INDEX_FILE)