Add a helpful error message when Fails fails to load indexes

We've had a few cases recently where Faiss is unable to load its
indexes properly, like after users upgrade versions of Llama Stack or
numpy dependencies. This catches any exceptions when deserializing the
index with an error message about what likely went wrong and how to
potentially fix it so that users can attempt to fix this without
needing to raise an issue or being confused.

The most common case of new users hitting this will be with the
SqliteKVStoreImpl, since that's our local storage most people use when
testing out Llama Stack. So, I added a `__str__` method to it that
shows the proper path and table name that users need to potentially
delete to resolve this error.

Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
Ben Browning 2025-06-27 14:16:05 -04:00
parent 6a3e8c0265
commit a5ebac18bd
2 changed files with 12 additions and 1 deletions

View file

@ -18,6 +18,9 @@ class SqliteKVStoreImpl(KVStore):
self.db_path = config.db_path
self.table_name = "kvstore"
def __str__(self):
return f"SqliteKVStoreImpl(db_path={self.db_path}, table_name={self.table_name})"
async def initialize(self):
os.makedirs(os.path.dirname(self.db_path), exist_ok=True)
async with aiosqlite.connect(self.db_path) as db: