better exception raising for package not imported

This commit is contained in:
ishaan-jaff 2023-09-08 17:42:01 -07:00
parent a9cb373d04
commit c5ae0147d0

View file

@ -1578,7 +1578,7 @@ def exception_type(model, original_exception, custom_llm_provider):
model=model, model=model,
llm_provider=original_exception.llm_provider llm_provider=original_exception.llm_provider
) )
raise original_exception raise ValueError(original_exception)
elif model: elif model:
error_str = str(original_exception) error_str = str(original_exception)
if isinstance(original_exception, BaseException): if isinstance(original_exception, BaseException):
@ -1761,6 +1761,7 @@ def exception_type(model, original_exception, custom_llm_provider):
llm_provider="cohere", llm_provider="cohere",
model=model model=model
) )
raise ValueError(original_exception)
elif custom_llm_provider == "huggingface": elif custom_llm_provider == "huggingface":
if "length limit exceeded" in error_str: if "length limit exceeded" in error_str:
exception_mapping_worked = True exception_mapping_worked = True
@ -1912,7 +1913,7 @@ def exception_type(model, original_exception, custom_llm_provider):
model=model model=model
) )
else: else:
raise original_exception raise ValueError(original_exception)
except Exception as e: except Exception as e:
# LOGGING # LOGGING
exception_logging( exception_logging(
@ -1929,7 +1930,7 @@ def exception_type(model, original_exception, custom_llm_provider):
): ):
threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start() threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start()
# don't let an error with mapping interrupt the user from receiving an error from the llm api calls # don't let an error with mapping interrupt the user from receiving an error from the llm api calls
raise original_exception raise ValueError(original_exception)
####### CRASH REPORTING ################ ####### CRASH REPORTING ################