mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
clean install and import - vertexai
This commit is contained in:
parent
99359b6464
commit
262bb07ade
2 changed files with 15 additions and 3 deletions
|
@ -10,6 +10,9 @@ All calls using Vertex AI require the following parameters:
|
|||
* Your Project Location
|
||||
`litellm.vertex_location` = "us-central1"
|
||||
|
||||
### Pre-requisites
|
||||
`pip install google-cloud-aiplatform`
|
||||
|
||||
Authentication:
|
||||
VertexAI uses Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information on setting this up
|
||||
|
||||
|
|
|
@ -605,7 +605,10 @@ def completion(
|
|||
return response
|
||||
response = model_response
|
||||
elif model in litellm.vertex_chat_models:
|
||||
import vertexai
|
||||
try:
|
||||
import vertexai
|
||||
except:
|
||||
Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
|
||||
from vertexai.preview.language_models import ChatModel, InputOutputTextPair
|
||||
|
||||
vertexai.init(
|
||||
|
@ -633,7 +636,10 @@ def completion(
|
|||
model_response["model"] = model
|
||||
response = model_response
|
||||
elif model in litellm.vertex_text_models:
|
||||
import vertexai
|
||||
try:
|
||||
import vertexai
|
||||
except:
|
||||
Exception("vertexai import failed please run `pip install google-cloud-aiplatform`")
|
||||
from vertexai.language_models import TextGenerationModel
|
||||
|
||||
vertexai.init(
|
||||
|
@ -790,7 +796,10 @@ def completion(
|
|||
|
||||
|
||||
def completion_with_retries(*args, **kwargs):
|
||||
import tenacity
|
||||
try:
|
||||
import tenacity
|
||||
except:
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue