mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-05 20:27:35 +00:00
Some providers need to be factorized and considered as thin routing layers on top of other providers. Consider two examples: - The inference API should be a routing layer over inference providers, routed using the "model" key - The memory banks API is another instance where various memory bank types will be provided by independent providers (e.g., a vector store is served by Chroma while a keyvalue memory can be served by Redis or PGVector) This commit introduces a generalized routing layer for this purpose.
17 lines
500 B
Python
17 lines
500 B
Python
# 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 Any, List, Tuple
|
|
|
|
from llama_toolchain.core.datatypes import Api
|
|
|
|
|
|
async def get_router_impl(inner_impls: List[Tuple[str, Any]], deps: List[Api]):
|
|
from .router import MemoryRouterImpl
|
|
|
|
impl = MemoryRouterImpl(inner_impls, deps)
|
|
await impl.initialize()
|
|
return impl
|