mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +00:00
Merge daeed865df
into cbe89d2bdd
This commit is contained in:
commit
beae27975b
6 changed files with 176 additions and 2 deletions
|
@ -6,7 +6,8 @@
|
|||
|
||||
from typing import Any, Protocol, runtime_checkable
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field, HttpUrl, field_validator
|
||||
from pydantic_core import PydanticCustomError
|
||||
|
||||
from llama_stack.providers.datatypes import HealthResponse
|
||||
from llama_stack.schema_utils import json_schema_type, webmethod
|
||||
|
@ -19,6 +20,22 @@ class ProviderInfo(BaseModel):
|
|||
provider_type: str
|
||||
config: dict[str, Any]
|
||||
health: HealthResponse
|
||||
metrics: str | None = Field(
|
||||
default=None, description="Endpoint for metrics from providers. Must be a valid HTTP URL if provided."
|
||||
)
|
||||
|
||||
@field_validator("metrics")
|
||||
@classmethod
|
||||
def validate_metrics_url(cls, v):
|
||||
if v is None:
|
||||
return None
|
||||
if not isinstance(v, str):
|
||||
raise ValueError("'metrics' must be a string URL or None")
|
||||
try:
|
||||
HttpUrl(v) # Validate the URL
|
||||
return v
|
||||
except (PydanticCustomError, ValueError) as e:
|
||||
raise ValueError(f"'metrics' must be a valid HTTP or HTTPS URL: {str(e)}") from e
|
||||
|
||||
|
||||
class ListProvidersResponse(BaseModel):
|
||||
|
|
|
@ -51,18 +51,22 @@ class ProviderImpl(Providers):
|
|||
# Skip providers that are not enabled
|
||||
if p.provider_id is None:
|
||||
continue
|
||||
# Filter out "metrics" to be shown in config duplicated
|
||||
metrics_url = p.config.get("metrics")
|
||||
config = {k: v for k, v in p.config.items() if k != "metrics"}
|
||||
ret.append(
|
||||
ProviderInfo(
|
||||
api=api,
|
||||
provider_id=p.provider_id,
|
||||
provider_type=p.provider_type,
|
||||
config=p.config,
|
||||
config=config,
|
||||
health=providers_health.get(api, {}).get(
|
||||
p.provider_id,
|
||||
HealthResponse(
|
||||
status=HealthStatus.NOT_IMPLEMENTED, message="Provider does not implement health check"
|
||||
),
|
||||
),
|
||||
metrics=metrics_url,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue