mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
handle pre-existing providers
This commit is contained in:
parent
a8b2a0242f
commit
9e491218c6
1 changed files with 25 additions and 14 deletions
|
|
@ -541,6 +541,18 @@ async def resolve_impls_via_provider_registration(
|
|||
else:
|
||||
# Regular providers - register through ProviderImpl
|
||||
api = Api(api_str)
|
||||
cache_key = f"{api.value}::{provider.provider_id}"
|
||||
|
||||
# Check if provider already exists (loaded from kvstore during initialization)
|
||||
if cache_key in providers_impl.dynamic_providers:
|
||||
logger.info(f"Provider {provider.provider_id} for {api.value} already exists, using existing instance")
|
||||
impl = providers_impl.dynamic_provider_impls.get(cache_key)
|
||||
if impl is None:
|
||||
# Provider exists but not instantiated, instantiate it
|
||||
conn_info = providers_impl.dynamic_providers[cache_key]
|
||||
impl = await providers_impl._instantiate_provider(conn_info)
|
||||
providers_impl.dynamic_provider_impls[cache_key] = impl
|
||||
else:
|
||||
logger.info(f"Registering {provider.provider_id} for {api.value}")
|
||||
|
||||
await providers_impl.register_provider(
|
||||
|
|
@ -552,15 +564,14 @@ async def resolve_impls_via_provider_registration(
|
|||
)
|
||||
|
||||
# Get the instantiated impl from dynamic_provider_impls using composite key
|
||||
cache_key = f"{api.value}::{provider.provider_id}"
|
||||
impl = providers_impl.dynamic_provider_impls[cache_key]
|
||||
logger.info(f"Successfully registered startup provider: {provider.provider_id}")
|
||||
|
||||
impls[api] = impl
|
||||
|
||||
# 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}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to handle provider {provider.provider_id}: {e}")
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue