kikocis/llama-stack public
Changesets · Branches · Tags · Compare
| Changeset | 45a7e555f421fb4d768accbb0c152e835b5f25169843053c5ed078eb60b10efd |
|---|---|
| Author | Xi Yan <xiyan@meta.com> · 2024-09-12 11:29 -07:00 |
| Committer | Xi Yan <xiyan@meta.com> · 2024-09-16 12:57 -07:00 |
| Parents | efac2a2f572e |
2 files changed
added llama_toolchain/models/api/api.py +41 −0
| @@ -0,0 +1,41 @@ | ||
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. | |
| 2 | +# All rights reserved. | |
| 3 | +# | |
| 4 | +# This source code is licensed under the terms described in the LICENSE file in | |
| 5 | +# the root directory of this source tree. | |
| 6 | + | |
| 7 | +from typing import Protocol | |
| 8 | + | |
| 9 | +from llama_models.schema_utils import webmethod # noqa: F401 | |
| 10 | + | |
| 11 | +from pydantic import BaseModel # noqa: F401 | |
| 12 | + | |
| 13 | + | |
| 14 | +@json_schema_type | |
| 15 | +class ModelSpec(BaseModel): | |
| 16 | + model_name: str = Field(description="Name of the model") | |
| 17 | + providers_spec: Dict[Api, Dict[str, str]] = Field( | |
| 18 | + default_factory=dict, | |
| 19 | + description="Map of API to the concrete provider specs. E.g. {}".format( | |
| 20 | + { | |
| 21 | + "inference": { | |
| 22 | + "provider_type": "remote::tgi", | |
| 23 | + "url": "localhost::5555", | |
| 24 | + "api_token": "hf_xxx", | |
| 25 | + } | |
| 26 | + } | |
| 27 | + ), | |
| 28 | + ) | |
| 29 | + | |
| 30 | + | |
| 31 | +class Models(Protocol): | |
| 32 | + @webmethod(route="/models/list", method="GET") | |
| 33 | + async def list_models(self) -> List[ModelSpec]: ... | |
| 34 | + | |
| 35 | + @webmethod(route="/models/get", method="GET") | |
| 36 | + async def get_model(self, model_name: str) -> ModelSpec: ... | |
| 37 | + | |
| 38 | + @webmethod(route="/models/register") | |
| 39 | + async def register_model( | |
| 40 | + self, name: str, provider: Api, provider_spec: Dict[str, str] | |
| 41 | + ) -> ModelSpec: ... |
deleted llama_toolchain/models/api/endpoints.py +0 −14
| @@ -1,14 +0,0 @@ | ||
| 1 | -# Copyright (c) Meta Platforms, Inc. and affiliates. | |
| 2 | -# All rights reserved. | |
| 3 | -# | |
| 4 | -# This source code is licensed under the terms described in the LICENSE file in | |
| 5 | -# the root directory of this source tree. | |
| 6 | - | |
| 7 | -from typing import Protocol | |
| 8 | - | |
| 9 | -from llama_models.schema_utils import webmethod # noqa: F401 | |
| 10 | - | |
| 11 | -from pydantic import BaseModel # noqa: F401 | |
| 12 | - | |
| 13 | - | |
| 14 | -class Models(Protocol): ... |