This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-16 23:21:00 -07:00
1 parent b211c407f4
commit 1a376ac17f
2 files changed
+22 -3

No files matched your search

+6
View File
@@ -411,6 +411,11 @@ class EventDefinitions(BaseModel):
description='Retrieval content was processed.', description='Retrieval content was processed.',
message='Retrieval Content processed', message='Retrieval Content processed',
) )
RETRIEVAL_CONTENT_PROCESS_FAILED: EventDefinition = EventDefinition(
name='retrieval.content.process_failed',
description='Retrieval content processing failed.',
message='Retrieval Content process failed',
)
RETRIEVAL_COLLECTION_DELETED: EventDefinition = EventDefinition( RETRIEVAL_COLLECTION_DELETED: EventDefinition = EventDefinition(
name='retrieval.collection.deleted', name='retrieval.collection.deleted',
description='A retrieval collection was deleted.', description='A retrieval collection was deleted.',
@@ -666,6 +671,7 @@ NOTIFICATION_EVENTS = (
EVENTS.CHAT_FAILED.name, EVENTS.CHAT_FAILED.name,
EVENTS.CHANNEL_MESSAGE.name, EVENTS.CHANNEL_MESSAGE.name,
EVENTS.CALENDAR_ALERT.name, EVENTS.CALENDAR_ALERT.name,
EVENTS.RETRIEVAL_CONTENT_PROCESS_FAILED.name,
) )
+16 -3
View File
@@ -1998,7 +1998,7 @@ async def process_file(
hash = calculate_sha256_string(text_content) hash = calculate_sha256_string(text_content)
if config.BYPASS_EMBEDDING_AND_RETRIEVAL: if config.BYPASS_EMBEDDING_AND_RETRIEVAL:
await Files.update_file_data_by_id(file.id, {'status': 'completed'}, db=db) await Files.update_file_data_by_id(file.id, {'status': 'completed', 'error': None}, db=db)
await Files.update_file_hash_by_id(file.id, hash, db=db) await Files.update_file_hash_by_id(file.id, hash, db=db)
await publish_event( await publish_event(
request, request,
@@ -2057,7 +2057,7 @@ async def process_file(
await Files.update_file_data_by_id( await Files.update_file_data_by_id(
file.id, file.id,
{'status': 'completed'}, {'status': 'completed', 'error': None},
db=session, db=session,
) )
await Files.update_file_hash_by_id(file.id, hash, db=session) await Files.update_file_hash_by_id(file.id, hash, db=session)
@@ -2087,12 +2087,25 @@ async def process_file(
async with get_async_db() as session: async with get_async_db() as session:
await Files.update_file_data_by_id( await Files.update_file_data_by_id(
file.id, file.id,
{'status': 'failed'}, {'status': 'failed', 'error': str(e)},
db=session, db=session,
) )
# Clear the hash so the file can be re-uploaded after fixing the issue # Clear the hash so the file can be re-uploaded after fixing the issue
await Files.update_file_hash_by_id(file.id, None, db=session) await Files.update_file_hash_by_id(file.id, None, db=session)
await publish_event(
request,
EVENTS.RETRIEVAL_CONTENT_PROCESS_FAILED,
actor=user,
subject_id=file.id,
subject_type='file',
data={
'collection_name': collection_name,
'filename': file.filename,
'message': f'{file.filename}: {e}',
},
)
if 'No pandoc was found' in str(e): if 'No pandoc was found' in str(e):
raise HTTPException( raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,