Merge pull request #175 from Hikari-Haru/check-index-type

Check index type
Kaveen Kumarasinghe 2 years ago committed by GitHub
commit 5d3a3bbec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@ import random
import tempfile import tempfile
import traceback import traceback
import asyncio import asyncio
import json
from collections import defaultdict from collections import defaultdict
import aiohttp import aiohttp
@ -239,7 +240,13 @@ class Index_handler:
return index return index
def index_load_file(self, file_path) -> [GPTSimpleVectorIndex, ComposableGraph]: 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) index = GPTTreeIndex.load_from_disk(file_path)
else: else:
index = GPTSimpleVectorIndex.load_from_disk(file_path) index = GPTSimpleVectorIndex.load_from_disk(file_path)

Loading…
Cancel
Save