Skip to content

Commit

Permalink
catch exceptions in update_access loop
Browse files Browse the repository at this point in the history
Signed-off-by: Anupam Kumar <[email protected]>
  • Loading branch information
kyteinsky committed Dec 13, 2024
1 parent bf5259f commit 5060d0e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions context_chat_backend/chain/ingest/injest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ...types import TConfig
from ...utils import is_valid_source_id, to_int
from ...vectordb.base import BaseVectorDB
from ...vectordb.types import DbException, UpdateAccessOp
from ...vectordb.types import DbException, SafeDbException, UpdateAccessOp
from ..types import InDocument
from .doc_loader import decode_source
from .doc_splitter import get_splitter_for
Expand Down Expand Up @@ -107,11 +107,15 @@ def _process_sources(
if len(existing_sources) > 0:
print('Increasing access for existing sources:', [source.filename for source in existing_sources], flush=True)
for source in existing_sources:
vectordb.update_access(
UpdateAccessOp.allow,
source.headers['userIds'].split(','),
source.filename, # pyright: ignore[reportArgumentType]
)
try:
vectordb.update_access(
UpdateAccessOp.allow,
source.headers['userIds'].split(','),
source.filename, # pyright: ignore[reportArgumentType]
)
except SafeDbException as e:
print('Failed to update access for source (', source.filename, '):', e.args[0], flush=True)
continue

if len(filtered_sources) == 0:
# no new sources to embed
Expand Down

0 comments on commit 5060d0e

Please sign in to comment.