From c2af9763f275334c8d996ccb856f65b981e0e12a Mon Sep 17 00:00:00 2001 From: Rene Teigen Date: Sat, 25 Feb 2023 08:03:27 +0000 Subject: [PATCH] Check index type --- models/index_model.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/models/index_model.py b/models/index_model.py index 087daa0..63afc62 100644 --- a/models/index_model.py +++ b/models/index_model.py @@ -4,6 +4,7 @@ import random import tempfile import traceback import asyncio +import json from collections import defaultdict import aiohttp @@ -239,7 +240,13 @@ class Index_handler: return index def index_load_file(self, file_path) -> [GPTSimpleVectorIndex, ComposableGraph]: - if "composed_deep" in str(file_path): + with open(file_path, "r", encoding="utf8") as f: + file_contents = f.read() + index_dict = json.loads(file_contents) + doc_id = index_dict['index_struct_id'] + doc_type = index_dict['docstore']['docs'][doc_id]['__type__'] + f.close() + if doc_type == "tree": index = GPTTreeIndex.load_from_disk(file_path) else: index = GPTSimpleVectorIndex.load_from_disk(file_path)