Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try-except to loading in the data index #123

Open
rchan26 opened this issue Oct 5, 2023 · 0 comments
Open

Add try-except to loading in the data index #123

rchan26 opened this issue Oct 5, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rchan26
Copy link
Collaborator

rchan26 commented Oct 5, 2023

When running the CLI reginald_run to set up slack bot with a llama-index model, you get error when you don't have the index built (i.e. the correct folder doesn't exist in your data directory) in which case you need to build the index by using --force-new-index flag. We could have better error handling.

Either:

  • Build it if you don't have it - so not necessary to --force-new-index (it'd still be useful to have because there's times where it does exist and you need to build again)
  • Give better error handling to let the user know that the folder doesn't exist and need to --force-new-index

The specific lines of code to change are here:

if force_new_index:
logging.info("Generating the index from scratch...")
self._prep_documents()
self.index = VectorStoreIndex.from_documents(
self.documents, service_context=service_context
)
# save the service context and persist the index
logging.info("Saving the index")
self.index.storage_context.persist(
persist_dir=self.data_dir / LLAMA_INDEX_DIR / which_index
)
else:
logging.info("Loading the storage context")
storage_context = StorageContext.from_defaults(
persist_dir=self.data_dir / LLAMA_INDEX_DIR / which_index
)
logging.info("Loading the pre-processed index")
self.index = load_index_from_storage(
storage_context=storage_context, service_context=service_context
)

Note: consider the folder may not exist because the data directory was misspecified, so perhaps the first suggestion is not ideal.

@rchan26 rchan26 added enhancement New feature or request good first issue Good for newcomers labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant