add version endpoint

This commit is contained in:
Xi Yan 2025-01-08 14:15:07 -08:00
parent 11332c39b1
commit b28e4002c9
2 changed files with 19 additions and 1 deletions

View file

@ -29,6 +29,11 @@ class HealthInfo(BaseModel):
# TODO: add a provider level status # TODO: add a provider level status
@json_schema_type
class VersionInfo(BaseModel):
version: str
@runtime_checkable @runtime_checkable
class Inspect(Protocol): class Inspect(Protocol):
@webmethod(route="/providers/list", method="GET") @webmethod(route="/providers/list", method="GET")
@ -39,3 +44,6 @@ class Inspect(Protocol):
@webmethod(route="/health", method="GET") @webmethod(route="/health", method="GET")
async def health(self) -> HealthInfo: ... async def health(self) -> HealthInfo: ...
@webmethod(route="/version", method="GET")
async def version(self) -> VersionInfo: ...

View file

@ -4,11 +4,18 @@
# This source code is licensed under the terms described in the LICENSE file in # This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree. # the root directory of this source tree.
from importlib.metadata import version
from typing import Dict, List from typing import Dict, List
from pydantic import BaseModel from pydantic import BaseModel
from llama_stack.apis.inspect import HealthInfo, Inspect, ProviderInfo, RouteInfo from llama_stack.apis.inspect import (
HealthInfo,
Inspect,
ProviderInfo,
RouteInfo,
VersionInfo,
)
from llama_stack.distribution.datatypes import StackRunConfig from llama_stack.distribution.datatypes import StackRunConfig
from llama_stack.distribution.server.endpoints import get_all_api_endpoints from llama_stack.distribution.server.endpoints import get_all_api_endpoints
@ -65,3 +72,6 @@ class DistributionInspectImpl(Inspect):
async def health(self) -> HealthInfo: async def health(self) -> HealthInfo:
return HealthInfo(status="OK") return HealthInfo(status="OK")
async def version(self) -> VersionInfo:
return VersionInfo(version=version("llama-stack"))