mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
add --version to llama stack CLI & /version endpoint (#732)
# What does this PR do? - add --version to llama stack CLI - add /version endpoint - run OpenAPI generator for the new endpoint ## Test Plan **CLI** <img width="184" alt="image" src="https://github.com/user-attachments/assets/3acb1d22-453e-4b79-baf6-e98e88d0671c" /> **endpoint** <img width="430" alt="image" src="https://github.com/user-attachments/assets/79cdd670-493b-40cf-8f9e-28a4ac0988ac" /> ## Sources Please link relevant resources if necessary. ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Ran pre-commit to handle lint / formatting issues. - [ ] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests.
This commit is contained in:
parent
a5e6f10e33
commit
596afc6497
5 changed files with 110 additions and 1 deletions
|
@ -2467,6 +2467,36 @@
|
|||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"/alpha/version": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/VersionInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Inspect"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "X-LlamaStack-ProviderData",
|
||||
"in": "header",
|
||||
"description": "JSON-encoded provider data which will be made available to the adapter servicing the API",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
|
@ -6457,6 +6487,9 @@
|
|||
"gradient_accumulation_steps": {
|
||||
"type": "integer"
|
||||
},
|
||||
"max_validation_steps": {
|
||||
"type": "integer"
|
||||
},
|
||||
"data_config": {
|
||||
"$ref": "#/components/schemas/DataConfig"
|
||||
},
|
||||
|
@ -6476,6 +6509,7 @@
|
|||
"n_epochs",
|
||||
"max_steps_per_epoch",
|
||||
"gradient_accumulation_steps",
|
||||
"max_validation_steps",
|
||||
"data_config",
|
||||
"optimizer_config"
|
||||
]
|
||||
|
@ -7686,6 +7720,18 @@
|
|||
"required": [
|
||||
"model_id"
|
||||
]
|
||||
},
|
||||
"VersionInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"version"
|
||||
]
|
||||
}
|
||||
},
|
||||
"responses": {}
|
||||
|
@ -8382,6 +8428,10 @@
|
|||
"name": "VectorMemoryBankParams",
|
||||
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/VectorMemoryBankParams\" />"
|
||||
},
|
||||
{
|
||||
"name": "VersionInfo",
|
||||
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/VersionInfo\" />"
|
||||
},
|
||||
{
|
||||
"name": "ViolationLevel",
|
||||
"description": "<SchemaDefinition schemaRef=\"#/components/schemas/ViolationLevel\" />"
|
||||
|
@ -8576,6 +8626,7 @@
|
|||
"UserMessage",
|
||||
"VectorMemoryBank",
|
||||
"VectorMemoryBankParams",
|
||||
"VersionInfo",
|
||||
"ViolationLevel",
|
||||
"WolframAlphaToolDefinition"
|
||||
]
|
||||
|
|
|
@ -3002,6 +3002,8 @@ components:
|
|||
type: integer
|
||||
max_steps_per_epoch:
|
||||
type: integer
|
||||
max_validation_steps:
|
||||
type: integer
|
||||
n_epochs:
|
||||
type: integer
|
||||
optimizer_config:
|
||||
|
@ -3010,6 +3012,7 @@ components:
|
|||
- n_epochs
|
||||
- max_steps_per_epoch
|
||||
- gradient_accumulation_steps
|
||||
- max_validation_steps
|
||||
- data_config
|
||||
- optimizer_config
|
||||
type: object
|
||||
|
@ -3192,6 +3195,14 @@ components:
|
|||
- embedding_model
|
||||
- chunk_size_in_tokens
|
||||
type: object
|
||||
VersionInfo:
|
||||
additionalProperties: false
|
||||
properties:
|
||||
version:
|
||||
type: string
|
||||
required:
|
||||
- version
|
||||
type: object
|
||||
ViolationLevel:
|
||||
enum:
|
||||
- info
|
||||
|
@ -4731,6 +4742,25 @@ paths:
|
|||
description: OK
|
||||
tags:
|
||||
- Telemetry
|
||||
/alpha/version:
|
||||
get:
|
||||
parameters:
|
||||
- description: JSON-encoded provider data which will be made available to the
|
||||
adapter servicing the API
|
||||
in: header
|
||||
name: X-LlamaStack-ProviderData
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VersionInfo'
|
||||
description: OK
|
||||
tags:
|
||||
- Inspect
|
||||
security:
|
||||
- Default: []
|
||||
servers:
|
||||
|
@ -5225,6 +5255,8 @@ tags:
|
|||
- description: <SchemaDefinition schemaRef="#/components/schemas/VectorMemoryBankParams"
|
||||
/>
|
||||
name: VectorMemoryBankParams
|
||||
- description: <SchemaDefinition schemaRef="#/components/schemas/VersionInfo" />
|
||||
name: VersionInfo
|
||||
- description: <SchemaDefinition schemaRef="#/components/schemas/ViolationLevel" />
|
||||
name: ViolationLevel
|
||||
- description: <SchemaDefinition schemaRef="#/components/schemas/WolframAlphaToolDefinition"
|
||||
|
@ -5411,5 +5443,6 @@ x-tagGroups:
|
|||
- UserMessage
|
||||
- VectorMemoryBank
|
||||
- VectorMemoryBankParams
|
||||
- VersionInfo
|
||||
- ViolationLevel
|
||||
- WolframAlphaToolDefinition
|
||||
|
|
|
@ -29,6 +29,11 @@ class HealthInfo(BaseModel):
|
|||
# TODO: add a provider level status
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class VersionInfo(BaseModel):
|
||||
version: str
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class Inspect(Protocol):
|
||||
@webmethod(route="/providers/list", method="GET")
|
||||
|
@ -39,3 +44,6 @@ class Inspect(Protocol):
|
|||
|
||||
@webmethod(route="/health", method="GET")
|
||||
async def health(self) -> HealthInfo: ...
|
||||
|
||||
@webmethod(route="/version", method="GET")
|
||||
async def version(self) -> VersionInfo: ...
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# the root directory of this source tree.
|
||||
|
||||
import argparse
|
||||
from importlib.metadata import version
|
||||
|
||||
from llama_stack.cli.subcommand import Subcommand
|
||||
|
||||
|
@ -24,6 +25,12 @@ class StackParser(Subcommand):
|
|||
description="Operations for the Llama Stack / Distributions",
|
||||
)
|
||||
|
||||
self.parser.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version=f"{version('llama-stack')}",
|
||||
)
|
||||
|
||||
subparsers = self.parser.add_subparsers(title="stack_subcommands")
|
||||
|
||||
# Add sub-commands
|
||||
|
|
|
@ -4,11 +4,18 @@
|
|||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
from importlib.metadata import version
|
||||
from typing import Dict, List
|
||||
|
||||
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.server.endpoints import get_all_api_endpoints
|
||||
|
||||
|
@ -65,3 +72,6 @@ class DistributionInspectImpl(Inspect):
|
|||
|
||||
async def health(self) -> HealthInfo:
|
||||
return HealthInfo(status="OK")
|
||||
|
||||
async def version(self) -> VersionInfo:
|
||||
return VersionInfo(version=version("llama-stack"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue