mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-16 09:58:10 +00:00
Add simple validation for RemoteProviderConfig
This commit is contained in:
parent
898cd5b352
commit
2cd8b2ff5b
1 changed files with 8 additions and 1 deletions
|
@ -9,7 +9,7 @@ from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from llama_models.schema_utils import json_schema_type
|
from llama_models.schema_utils import json_schema_type
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field, validator
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
|
@ -62,6 +62,13 @@ class RemoteProviderConfig(BaseModel):
|
||||||
..., description="API key, if needed, for the provider"
|
..., description="API key, if needed, for the provider"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@validator("base_url")
|
||||||
|
@classmethod
|
||||||
|
def validate_base_url(cls, base_url: str) -> str:
|
||||||
|
if not base_url.startswith("http"):
|
||||||
|
raise ValueError(f"URL must start with http: {base_url}")
|
||||||
|
return base_url
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class RemoteProviderSpec(ProviderSpec):
|
class RemoteProviderSpec(ProviderSpec):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue