From 060b4eb776f1bd5a816ee882f5c475a3555f8816 Mon Sep 17 00:00:00 2001 From: Matthew Farrellee Date: Tue, 26 Nov 2024 20:46:44 -0500 Subject: [PATCH] allow env NVIDIA_BASE_URL to set NVIDIAConfig.url (#531) # What does this PR do? this allows setting an NVIDIA_BASE_URL variable to control the NVIDIAConfig.url option ## Test Plan `pytest -s -v --providers inference=nvidia llama_stack/providers/tests/inference/ --env NVIDIA_BASE_URL=http://localhost:8000` ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [x] Ran pre-commit to handle lint / formatting issues. - [x] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests. --- llama_stack/providers/remote/inference/nvidia/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llama_stack/providers/remote/inference/nvidia/config.py b/llama_stack/providers/remote/inference/nvidia/config.py index c50143043..28be43f4c 100644 --- a/llama_stack/providers/remote/inference/nvidia/config.py +++ b/llama_stack/providers/remote/inference/nvidia/config.py @@ -35,7 +35,9 @@ class NVIDIAConfig(BaseModel): """ url: str = Field( - default="https://integrate.api.nvidia.com", + default_factory=lambda: os.getenv( + "NVIDIA_BASE_URL", "https://integrate.api.nvidia.com" + ), description="A base url for accessing the NVIDIA NIM", ) api_key: Optional[str] = Field(