diff --git a/docs/my-website/docs/providers/huggingface.md b/docs/my-website/docs/providers/huggingface.md index a860ae219f..7ee5a754b2 100644 --- a/docs/my-website/docs/providers/huggingface.md +++ b/docs/my-website/docs/providers/huggingface.md @@ -72,12 +72,13 @@ response = completion( print(response) ``` -### [OPTIONAL] API KEYS -If the endpoint you're calling requires an api key to be passed, set it in your os environment. [Code for how it's sent](https://github.com/BerriAI/litellm/blob/0100ab2382a0e720c7978fbf662cc6e6920e7e03/litellm/llms/huggingface_restapi.py#L25) +### [OPTIONAL] API KEYS + API BASE +If required, you can set the api key + api base, set it in your os environment. [Code for how it's sent](https://github.com/BerriAI/litellm/blob/0100ab2382a0e720c7978fbf662cc6e6920e7e03/litellm/llms/huggingface_restapi.py#L25) ```python import os os.environ["HUGGINGFACE_API_KEY"] = "" +os.environ["HUGGINGFACE_API_BASE"] = "" ``` ### Models with Prompt Formatting diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.md index 611fbfe353..b8726b70f6 100644 --- a/docs/my-website/docs/providers/vertex.md +++ b/docs/my-website/docs/providers/vertex.md @@ -13,9 +13,29 @@ ## Set Vertex Project & Vertex Location All calls using Vertex AI require the following parameters: * Your Project ID -`litellm.vertex_project = "hardy-device-38811" Your Project ID` +```python +import os, litellm + +# set via env var +os.environ["VERTEXAI_PROJECT"] = "hardy-device-38811" # Your Project ID` + +### OR ### + +# set directly on module +litellm.vertex_project = "hardy-device-38811" # Your Project ID` +``` * Your Project Location -`litellm.vertex_location = "us-central1" ` +```python +import os, litellm + +# set via env var +os.environ["VERTEXAI_LOCATION"] = "us-central1 # Your Location + +### OR ### + +# set directly on module +litellm.vertex_location = "us-central1 # Your Location +``` ## Sample Usage ```python diff --git a/litellm/llms/huggingface_restapi.py b/litellm/llms/huggingface_restapi.py index 09348313fe..796cf6b00c 100644 --- a/litellm/llms/huggingface_restapi.py +++ b/litellm/llms/huggingface_restapi.py @@ -49,6 +49,8 @@ def completion( completion_url = api_base elif "HF_API_BASE" in os.environ: completion_url = os.getenv("HF_API_BASE", "") + elif "HUGGINGFACE_API_BASE" in os.environ: + completion_url = os.getenv("HUGGINGFACE_API_BASE", "") else: completion_url = f"https://api-inference.huggingface.co/models/{model}" diff --git a/litellm/main.py b/litellm/main.py index 4428bef1b7..4b050c34b6 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -749,8 +749,10 @@ def completion( raise Exception("vertexai import failed please run `pip install google-cloud-aiplatform`") from vertexai.preview.language_models import ChatModel, CodeChatModel, InputOutputTextPair + vertex_project = (litellm.vertex_project or get_secret("VERTEXAI_PROJECT")) + vertex_location = (litellm.vertex_location or get_secret("VERTEXAI_LOCATION")) vertexai.init( - project=litellm.vertex_project, location=litellm.vertex_location + project=vertex_project, location=vertex_location ) # vertexai does not use an API key, it looks for credentials.json in the environment diff --git a/pyproject.toml b/pyproject.toml index 08fa7b327e..fac1e2b844 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.734" +version = "0.1.735" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"