feat: add optional metrics under API /providers

- add field "metrcis" under API "/providers"
- each provider can config "metrics" in run.yaml in "config"
  - if no "metrics":  /provider/<provider_id> shows "metrics: null" in response
  - if has "metrics": /provider/<provider_id> show result in response
  - if has "metrics" but is not string type and not httpurl, raise ValidationError
- add unit tests for providers
- update "docs"

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
This commit is contained in:
Wen Zhou 2025-06-30 09:10:43 +02:00
parent 5400a2e2b1
commit 8563c76f88
7 changed files with 248 additions and 2 deletions

View file

@ -19,3 +19,13 @@ class TestProviders:
pid = provider.provider_id
provider = llama_stack_client.providers.retrieve(pid)
assert provider is not None
@pytest.mark.asyncio
def test_providers_metrics_field(self, llama_stack_client: LlamaStackAsLibraryClient | LlamaStackClient):
"""Test metrics field is in provider responses."""
provider_list = llama_stack_client.providers.list()
assert provider_list is not None
assert len(provider_list) > 0
for provider in provider_list:
assert provider.metrics is None or isinstance(provider.metrics, str)