Skip to content

Commit bec18e9

Browse files
committed
use AnyHttpUrl for passthrough_url in provider data validator
1 parent 3994fc8 commit bec18e9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/llama_stack/providers/remote/inference/passthrough/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7-
from pydantic import BaseModel, ConfigDict, SecretStr
7+
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, SecretStr
88

99
from .config import PassthroughImplConfig
1010

@@ -18,7 +18,7 @@ class PassthroughProviderDataValidator(BaseModel):
1818
# Without it, Pydantic drops them before build_forwarded_headers() can read them.
1919
model_config = ConfigDict(extra="allow")
2020

21-
passthrough_url: str | None = None
21+
passthrough_url: AnyHttpUrl | None = None
2222
passthrough_api_key: SecretStr | None = None
2323

2424

src/llama_stack/providers/remote/inference/passthrough/passthrough.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _get_passthrough_url(self) -> str:
140140
raise ValueError(
141141
'Pass url of the passthrough endpoint in the header X-LlamaStack-Provider-Data as { "passthrough_url": <your passthrough url>}'
142142
)
143-
return provider_data.passthrough_url
143+
return str(provider_data.passthrough_url)
144144

145145
async def openai_completion(
146146
self,

tests/unit/providers/inference/test_passthrough_forward_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,15 @@ def test_accepts_empty_payload(self):
362362

363363
def test_accepts_only_passthrough_url(self):
364364
v = PassthroughProviderDataValidator(passthrough_url="http://x.example.com")
365-
assert v.passthrough_url == "http://x.example.com"
365+
assert str(v.passthrough_url) == "http://x.example.com/"
366366
assert v.passthrough_api_key is None
367367

368368
def test_accepts_both_fields(self):
369369
v = PassthroughProviderDataValidator(
370370
passthrough_url="http://x.example.com",
371371
passthrough_api_key="sk-test",
372372
)
373-
assert v.passthrough_url == "http://x.example.com"
373+
assert str(v.passthrough_url) == "http://x.example.com/"
374374
assert v.passthrough_api_key is not None
375375
assert v.passthrough_api_key.get_secret_value() == "sk-test"
376376

0 commit comments

Comments
 (0)