Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
folkien committed Apr 22, 2023
1 parent dbd7a32 commit c3b7009
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions vectordb-create.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))

datasetpath = "trainingdata/evangeligaudium"

# Datasetpath is wrong
if (not os.path.exists(datasetpath)):
logging.error('Dataset path does not exist. Please check the path.')
sys.exit(-1)

# Data set load and create if not exists
db_index = None
if (not os.path.exists('trainingdata/sesa.json')):
if (not os.path.exists(f'{datasetpath}.json')):
logging.info('Creating database...')
db_documents = SimpleDirectoryReader('trainingdata/sesa').load_data()
db_documents = SimpleDirectoryReader(datasetpath).load_data()
db_index = GPTSimpleVectorIndex.from_documents(db_documents)
db_index.save_to_disk('trainingdata/sesa.json')
db_index.save_to_disk(f"{datasetpath}.json")

if (db_index is None):
logging.info('Loading database...')
db_index = GPTSimpleVectorIndex.load_from_disk('trainingdata/sesa.json')
db_index = GPTSimpleVectorIndex.load_from_disk(f"{datasetpath}.json")

prompt = input("Podaje zapytanie do ewangelizatora:")
prompt = input("Podaj zapytanie:")
response = db_index.query(prompt)

print("Odpowiedź: " + str(response))
Expand Down

0 comments on commit c3b7009

Please sign in to comment.