mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-07 14:26:44 +00:00
updates to fix pre-commits check
This commit is contained in:
parent
24707a1173
commit
47373a65cf
2 changed files with 46 additions and 41 deletions
|
@ -1,6 +1,14 @@
|
|||
# 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.
|
||||
|
||||
"""
|
||||
Patch for the provider impl to fix the health check for the FAISS provider.
|
||||
It is the workaround fix with current implementation if place for get_providers_health
|
||||
as it returns a dict mapping API names to a single health response, but list_providers
|
||||
expects a dict mapping API names to a dict of provider IDs to health responses.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -17,6 +25,7 @@ original_list_providers = ProviderImpl.list_providers
|
|||
|
||||
VECTOR_DIMENSION = 128 # sample dimension
|
||||
|
||||
|
||||
# Helper method to check FAISS health directly
|
||||
async def check_faiss_health():
|
||||
"""Check the health of the FAISS vector database directly."""
|
||||
|
@ -25,10 +34,8 @@ async def check_faiss_health():
|
|||
faiss.IndexFlatL2(VECTOR_DIMENSION)
|
||||
return HealthResponse(status=HealthStatus.OK)
|
||||
except Exception as e:
|
||||
return HealthResponse(
|
||||
status=HealthStatus.ERROR,
|
||||
message=f"FAISS health check failed: {str(e)}"
|
||||
)
|
||||
return HealthResponse(status=HealthStatus.ERROR, message=f"FAISS health check failed: {str(e)}")
|
||||
|
||||
|
||||
async def patched_list_providers(self):
|
||||
"""Patched version of list_providers to include FAISS health check."""
|
||||
|
@ -44,7 +51,9 @@ async def patched_list_providers(self):
|
|||
logger.debug("Updated FAISS health to: %s", provider.health)
|
||||
return response
|
||||
|
||||
new_list_providers = patched_list_providers
|
||||
|
||||
# Apply the patch by replacing the original method with patched version
|
||||
ProviderImpl.list_providers = new_list_providers
|
||||
# Added type: ignore because mypy cannot infer the correct type
|
||||
# The typing error doesn't affect runtime behavior - it's only a static type check warning
|
||||
ProviderImpl.list_providers = patched_list_providers # type: ignore
|
||||
logger.debug("Successfully applied patch for FAISS provider health check")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue