mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-06 20:44:58 +00:00
skeleton models api
This commit is contained in:
parent
59af1c8fec
commit
68131afc86
9 changed files with 233 additions and 10 deletions
23
llama_stack/providers/impls/builtin/models/__init__.py
Normal file
23
llama_stack/providers/impls/builtin/models/__init__.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
from typing import Dict
|
||||
|
||||
from llama_stack.distribution.datatypes import Api, ProviderSpec
|
||||
|
||||
from .config import BuiltinImplConfig # noqa
|
||||
|
||||
|
||||
async def get_provider_impl(config: BuiltinImplConfig, deps: Dict[Api, ProviderSpec]):
|
||||
from .models import BuiltinModelsImpl
|
||||
|
||||
assert isinstance(
|
||||
config, BuiltinImplConfig
|
||||
), f"Unexpected config type: {type(config)}"
|
||||
|
||||
impl = BuiltinModelsImpl(config)
|
||||
await impl.initialize()
|
||||
return impl
|
18
llama_stack/providers/impls/builtin/models/config.py
Normal file
18
llama_stack/providers/impls/builtin/models/config.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from llama_models.datatypes import ModelFamily
|
||||
|
||||
from llama_models.schema_utils import json_schema_type
|
||||
from llama_models.sku_list import all_registered_models, resolve_model
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class BuiltinImplConfig(BaseModel): ...
|
46
llama_stack/providers/impls/builtin/models/models.py
Normal file
46
llama_stack/providers/impls/builtin/models/models.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
import asyncio
|
||||
|
||||
from typing import AsyncIterator, Union
|
||||
|
||||
from llama_models.llama3.api.datatypes import StopReason
|
||||
from llama_models.sku_list import resolve_model
|
||||
|
||||
from llama_stack.apis.models import * # noqa: F403
|
||||
from llama_models.llama3.api.datatypes import * # noqa: F403
|
||||
from llama_models.datatypes import CoreModelId, Model
|
||||
from llama_models.sku_list import resolve_model
|
||||
|
||||
from .config import BuiltinImplConfig
|
||||
|
||||
DUMMY_MODELS_SPEC = ModelSpec(
|
||||
llama_model_metadata=resolve_model("Meta-Llama3.1-8B"),
|
||||
providers_spec={"inference": {"provider_type": "meta-reference"}},
|
||||
)
|
||||
|
||||
|
||||
class BuiltinModelsImpl(Models):
|
||||
def __init__(
|
||||
self,
|
||||
config: BuiltinImplConfig,
|
||||
) -> None:
|
||||
self.config = config
|
||||
self.models_list = [DUMMY_MODELS_SPEC]
|
||||
|
||||
async def initialize(self) -> None:
|
||||
pass
|
||||
|
||||
async def list_models(self) -> ModelsListResponse:
|
||||
return ModelsListResponse(models_list=self.models_list)
|
||||
|
||||
async def get_model(self, core_model_id: str) -> ModelsGetResponse:
|
||||
return ModelsGetResponse(core_model_spec=DUMMY_MODELS_SPEC)
|
||||
|
||||
async def register_model(
|
||||
self, model_id: str, api: str, provider_spec: Dict[str, str]
|
||||
) -> ModelsRegisterResponse:
|
||||
return ModelsRegisterResponse()
|
Loading…
Add table
Add a link
Reference in a new issue