raise cohere, vertex, tenacity import errors

This commit is contained in:
ishaan-jaff 2023-09-08 15:26:09 -07:00
parent 0cc561bc5d
commit 1c9169e563

View file

@ -484,7 +484,7 @@ def completion(
try:
import cohere
except:
Exception("Cohere import failed please run `pip install cohere`")
raise Exception("Cohere import failed please run `pip install cohere`")
cohere_key = (
api_key
@ -587,7 +587,7 @@ def completion(
try:
import vertexai
except:
Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
raise Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
from vertexai.preview.language_models import ChatModel, InputOutputTextPair
vertexai.init(
@ -618,7 +618,7 @@ def completion(
try:
import vertexai
except:
Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
raise Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
from vertexai.language_models import TextGenerationModel
vertexai.init(
@ -835,7 +835,7 @@ def completion_with_retries(*args, **kwargs):
try:
import tenacity
except:
Exception("tenacity import failed please run `pip install tenacity`")
raise Exception("tenacity import failed please run `pip install tenacity`")
retryer = tenacity.Retrying(stop=tenacity.stop_after_attempt(3), reraise=True)
return retryer(completion, *args, **kwargs)