mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
refac
This commit is contained in:
parent
b211c407f4
commit
1a376ac17f
2 changed files with 22 additions and 3 deletions
|
|
@ -411,6 +411,11 @@ class EventDefinitions(BaseModel):
|
|||
description='Retrieval content was 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(
|
||||
name='retrieval.collection.deleted',
|
||||
description='A retrieval collection was deleted.',
|
||||
|
|
@ -666,6 +671,7 @@ NOTIFICATION_EVENTS = (
|
|||
EVENTS.CHAT_FAILED.name,
|
||||
EVENTS.CHANNEL_MESSAGE.name,
|
||||
EVENTS.CALENDAR_ALERT.name,
|
||||
EVENTS.RETRIEVAL_CONTENT_PROCESS_FAILED.name,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1998,7 +1998,7 @@ async def process_file(
|
|||
hash = calculate_sha256_string(text_content)
|
||||
|
||||
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 publish_event(
|
||||
request,
|
||||
|
|
@ -2057,7 +2057,7 @@ async def process_file(
|
|||
|
||||
await Files.update_file_data_by_id(
|
||||
file.id,
|
||||
{'status': 'completed'},
|
||||
{'status': 'completed', 'error': None},
|
||||
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:
|
||||
await Files.update_file_data_by_id(
|
||||
file.id,
|
||||
{'status': 'failed'},
|
||||
{'status': 'failed', 'error': str(e)},
|
||||
db=session,
|
||||
)
|
||||
# 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 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):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue