mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
updates
This commit is contained in:
parent
e21db79d6c
commit
13b6f3df65
12 changed files with 1238 additions and 605 deletions
|
|
@ -34,16 +34,21 @@ from llama_stack.apis.synthetic_data_generation import SyntheticDataGeneration
|
|||
from llama_stack.apis.telemetry import Telemetry
|
||||
from llama_stack.apis.tools import RAGToolRuntime, ToolGroups, ToolRuntime
|
||||
from llama_stack.apis.vector_io import VectorIO
|
||||
from llama_stack.core.access_control.datatypes import AccessRule
|
||||
from llama_stack.core.conversations.conversations import ConversationServiceConfig, ConversationServiceImpl
|
||||
from llama_stack.core.datatypes import Provider, SafetyConfig, StackRunConfig, VectorStoresConfig
|
||||
from llama_stack.core.distribution import get_provider_registry
|
||||
from llama_stack.core.distribution import builtin_automatically_routed_apis, get_provider_registry
|
||||
from llama_stack.core.inspect import DistributionInspectConfig, DistributionInspectImpl
|
||||
from llama_stack.core.prompts.prompts import PromptServiceConfig, PromptServiceImpl
|
||||
from llama_stack.core.providers import ProviderImpl, ProviderImplConfig
|
||||
from llama_stack.core.resolver import ProviderRegistry, resolve_impls
|
||||
from llama_stack.core.resolver import (
|
||||
ProviderRegistry,
|
||||
instantiate_provider,
|
||||
sort_providers_by_deps,
|
||||
specs_for_autorouted_apis,
|
||||
validate_and_prepare_providers,
|
||||
)
|
||||
from llama_stack.core.routing_tables.common import CommonRoutingTableImpl
|
||||
from llama_stack.core.access_control.datatypes import AccessRule
|
||||
from llama_stack.core.store.registry import DistributionRegistry
|
||||
from llama_stack.core.storage.datatypes import (
|
||||
InferenceStoreReference,
|
||||
KVStoreReference,
|
||||
|
|
@ -54,10 +59,12 @@ from llama_stack.core.storage.datatypes import (
|
|||
StorageBackendConfig,
|
||||
StorageConfig,
|
||||
)
|
||||
from llama_stack.core.store.registry import create_dist_registry
|
||||
from llama_stack.core.store.registry import DistributionRegistry, create_dist_registry
|
||||
from llama_stack.core.utils.dynamic import instantiate_class_type
|
||||
from llama_stack.log import get_logger
|
||||
from llama_stack.providers.datatypes import Api
|
||||
from llama_stack.providers.utils.kvstore.kvstore import register_kvstore_backends
|
||||
from llama_stack.providers.utils.sqlstore.sqlstore import register_sqlstore_backends
|
||||
|
||||
logger = get_logger(name=__name__, category="core")
|
||||
|
||||
|
|
@ -401,9 +408,6 @@ def _initialize_storage(run_config: StackRunConfig):
|
|||
else:
|
||||
raise ValueError(f"Unknown storage backend type: {type}")
|
||||
|
||||
from llama_stack.providers.utils.kvstore.kvstore import register_kvstore_backends
|
||||
from llama_stack.providers.utils.sqlstore.sqlstore import register_sqlstore_backends
|
||||
|
||||
register_kvstore_backends(kv_backends)
|
||||
register_sqlstore_backends(sql_backends)
|
||||
|
||||
|
|
@ -429,9 +433,6 @@ async def resolve_impls_via_provider_registration(
|
|||
Returns:
|
||||
Dictionary mapping API to implementation instances
|
||||
"""
|
||||
from llama_stack.core.distribution import builtin_automatically_routed_apis
|
||||
from llama_stack.core.resolver import sort_providers_by_deps, specs_for_autorouted_apis, validate_and_prepare_providers
|
||||
|
||||
routing_table_apis = {x.routing_table_api for x in builtin_automatically_routed_apis()}
|
||||
router_apis = {x.router_api for x in builtin_automatically_routed_apis()}
|
||||
|
||||
|
|
@ -455,50 +456,29 @@ async def resolve_impls_via_provider_registration(
|
|||
# Register each provider through ProviderImpl
|
||||
impls = internal_impls.copy()
|
||||
|
||||
logger.info(f"🚀 Starting provider registration for {len(sorted_providers)} providers from run.yaml")
|
||||
logger.info(f"Provider registration for {len(sorted_providers)} providers from run.yaml")
|
||||
|
||||
for api_str, provider in sorted_providers:
|
||||
# Skip providers that are not enabled
|
||||
if provider.provider_id is None:
|
||||
continue
|
||||
|
||||
# Skip internal APIs that need special handling
|
||||
# - providers: already initialized as internal_impls
|
||||
# - inspect: already initialized as internal_impls
|
||||
# - telemetry: internal observability, directly instantiated below
|
||||
# Skip internal APIs (already initialized)
|
||||
if api_str in ["providers", "inspect"]:
|
||||
continue
|
||||
|
||||
# Telemetry is an internal API that should be directly instantiated
|
||||
if api_str == "telemetry":
|
||||
logger.info(f"Instantiating {provider.provider_id} for {api_str}")
|
||||
|
||||
from llama_stack.core.resolver import instantiate_provider
|
||||
|
||||
deps = {a: impls[a] for a in provider.spec.api_dependencies if a in impls}
|
||||
for a in provider.spec.optional_api_dependencies:
|
||||
if a in impls:
|
||||
deps[a] = impls[a]
|
||||
|
||||
impl = await instantiate_provider(provider, deps, {}, dist_registry, run_config, policy)
|
||||
api = Api(api_str)
|
||||
impls[api] = impl
|
||||
providers_impl.deps[api] = impl
|
||||
continue
|
||||
|
||||
# Handle different provider types
|
||||
try:
|
||||
# Check if this is a routing table or router (system infrastructure)
|
||||
is_routing_table = api_str.startswith("inner-") or provider.spec.provider_type in ["routing_table", "router"]
|
||||
is_router = not api_str.startswith("inner-") and (Api(api_str) in router_apis or provider.spec.provider_type == "router")
|
||||
# Check if this is a router (system infrastructure)
|
||||
is_router = not api_str.startswith("inner-") and (
|
||||
Api(api_str) in router_apis or provider.spec.provider_type == "router"
|
||||
)
|
||||
|
||||
if api_str.startswith("inner-") or provider.spec.provider_type == "routing_table":
|
||||
# Inner providers or routing tables cannot be registered through the API
|
||||
# They need to be instantiated directly
|
||||
logger.info(f"Instantiating {provider.provider_id} for {api_str}")
|
||||
|
||||
from llama_stack.core.resolver import instantiate_provider
|
||||
|
||||
deps = {a: impls[a] for a in provider.spec.api_dependencies if a in impls}
|
||||
for a in provider.spec.optional_api_dependencies:
|
||||
if a in impls:
|
||||
|
|
@ -510,8 +490,9 @@ async def resolve_impls_via_provider_registration(
|
|||
# For routing tables of autorouted APIs, get inner impls from the router API
|
||||
# E.g., tool_groups routing table needs inner-tool_runtime providers
|
||||
if provider.spec.provider_type == "routing_table":
|
||||
from llama_stack.core.distribution import builtin_automatically_routed_apis
|
||||
autorouted_map = {info.routing_table_api: info.router_api for info in builtin_automatically_routed_apis()}
|
||||
autorouted_map = {
|
||||
info.routing_table_api: info.router_api for info in builtin_automatically_routed_apis()
|
||||
}
|
||||
if Api(api_str) in autorouted_map:
|
||||
router_api_str = autorouted_map[Api(api_str)].value
|
||||
inner_key = f"inner-{router_api_str}"
|
||||
|
|
@ -540,8 +521,6 @@ async def resolve_impls_via_provider_registration(
|
|||
# Router providers also need special handling
|
||||
logger.info(f"Instantiating router {provider.provider_id} for {api_str}")
|
||||
|
||||
from llama_stack.core.resolver import instantiate_provider
|
||||
|
||||
deps = {a: impls[a] for a in provider.spec.api_dependencies if a in impls}
|
||||
for a in provider.spec.optional_api_dependencies:
|
||||
if a in impls:
|
||||
|
|
@ -564,9 +543,9 @@ async def resolve_impls_via_provider_registration(
|
|||
api = Api(api_str)
|
||||
logger.info(f"Registering {provider.provider_id} for {api.value}")
|
||||
|
||||
response = await providers_impl.register_provider(
|
||||
provider_id=provider.provider_id,
|
||||
await providers_impl.register_provider(
|
||||
api=api.value,
|
||||
provider_id=provider.provider_id,
|
||||
provider_type=provider.spec.provider_type,
|
||||
config=provider.config,
|
||||
attributes=getattr(provider, "attributes", None),
|
||||
|
|
@ -580,10 +559,10 @@ async def resolve_impls_via_provider_registration(
|
|||
# IMPORTANT: Update providers_impl.deps so subsequent providers can depend on this one
|
||||
providers_impl.deps[api] = impl
|
||||
|
||||
logger.info(f"✅ Successfully registered startup provider: {provider.provider_id}")
|
||||
logger.info(f"Successfully registered startup provider: {provider.provider_id}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Failed to handle provider {provider.provider_id}: {e}")
|
||||
logger.error(f"Failed to handle provider {provider.provider_id}: {e}")
|
||||
raise
|
||||
|
||||
return impls
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue