Elffuss BraidHub

kikocis/llama-stack public

45a7e555f421 · 1.2 KiBRawPermalink
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
7from typing import Protocol
8
9from llama_models.schema_utils import webmethod # noqa: F401
10
11from pydantic import BaseModel # noqa: F401
12
13
14@json_schema_type
15class 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
31class 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: ...