Skip to content

Commit

Permalink
Fixes. Added base for LLAMA_index.
Browse files Browse the repository at this point in the history
  • Loading branch information
folkien committed Apr 22, 2023
1 parent cb469e7 commit ec0c311
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Empty file removed temp/README.md
Empty file.
29 changes: 29 additions & 0 deletions vectordb-create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'''
This script creates a vector database from texts with
llama_index.
'''
import logging
import sys
from llama_index import (
GPTSimpleVectorIndex,
GPTSimpleKeywordTableIndex,
GPTListIndex,
SimpleDirectoryReader
)

# Setup logging and configure basics
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))


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

if (db_index is None):
logging.info('Loading database...')
db_index = GPTSimpleVectorIndex.('trainingdata/sesa.json')

0 comments on commit ec0c311

Please sign in to comment.