mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-02 01:42:53 -05:00
refac
This commit is contained in:
1 parent
55f1b5c0cb
commit
1c59e41e5f
18 files changed
+137
-71
No files matched your search
@@ -106,8 +106,8 @@ class EventDefinitions(BaseModel):
|
||||
description='Suggestion configuration was updated.',
|
||||
message='Config Suggestions updated',
|
||||
)
|
||||
AUTH_SIGNUP: EventDefinition = EventDefinition(
|
||||
name='auth.signup', description='A user account was created through signup.', message='User signed up'
|
||||
AUTH_SIGNED_UP: EventDefinition = EventDefinition(
|
||||
name='auth.signed_up', description='A user account was created through signup.', message='User signed up'
|
||||
)
|
||||
AUTH_MFA_ENROLLED: EventDefinition = EventDefinition(
|
||||
name='auth.mfa.enrolled', description='MFA enrolled.', message='MFA enrolled'
|
||||
@@ -138,14 +138,14 @@ class EventDefinitions(BaseModel):
|
||||
AUTH_MFA_POLICY_CHANGED: EventDefinition = EventDefinition(
|
||||
name='auth.mfa.policy_changed', description='MFA policy changed.', message='MFA policy changed'
|
||||
)
|
||||
AUTH_LOGIN: EventDefinition = EventDefinition(
|
||||
name='auth.login', description='A user successfully logged in.', message='User logged in'
|
||||
AUTH_LOGGED_IN: EventDefinition = EventDefinition(
|
||||
name='auth.logged_in', description='A user successfully logged in.', message='User logged in'
|
||||
)
|
||||
AUTH_SESSIONS_REVOKED: EventDefinition = EventDefinition(
|
||||
name='auth.sessions_revoked', description='All user sessions were revoked.', message='User sessions revoked'
|
||||
)
|
||||
AUTH_LOGOUT: EventDefinition = EventDefinition(
|
||||
name='auth.logout', description='A user logged out.', message='User logged out'
|
||||
AUTH_LOGGED_OUT: EventDefinition = EventDefinition(
|
||||
name='auth.logged_out', description='A user logged out.', message='User logged out'
|
||||
)
|
||||
AUTH_PASSWORD_CHANGED: EventDefinition = EventDefinition(
|
||||
name='auth.password_changed', description='A user password was changed.', message='Password changed'
|
||||
@@ -203,11 +203,11 @@ class EventDefinitions(BaseModel):
|
||||
CHAT_CREATED: EventDefinition = EventDefinition(
|
||||
name='chat.created', description='A chat was created.', message='Chat created'
|
||||
)
|
||||
CHAT_FINISHED: EventDefinition = EventDefinition(
|
||||
name='chat.finished', description='A chat response finished.', message='Chat finished'
|
||||
CHAT_RESPONSE_COMPLETED: EventDefinition = EventDefinition(
|
||||
name='chat.response_completed', description='A chat response finished.', message='Chat finished'
|
||||
)
|
||||
CHAT_FAILED: EventDefinition = EventDefinition(
|
||||
name='chat.failed', description='A chat response failed.', message='Chat failed'
|
||||
CHAT_RESPONSE_FAILED: EventDefinition = EventDefinition(
|
||||
name='chat.response_failed', description='A chat response failed.', message='Chat failed'
|
||||
)
|
||||
CHAT_IMPORTED: EventDefinition = EventDefinition(
|
||||
name='chat.imported', description='A chat was imported.', message='Chat imported'
|
||||
@@ -218,8 +218,8 @@ class EventDefinitions(BaseModel):
|
||||
CHAT_DELETED: EventDefinition = EventDefinition(
|
||||
name='chat.deleted', description='A chat was deleted.', message='Chat deleted'
|
||||
)
|
||||
CHAT_DELETED_ALL: EventDefinition = EventDefinition(
|
||||
name='chat.deleted_all', description='All chats for a scope were deleted.', message='Chat deleted all'
|
||||
CHAT_ALL_DELETED: EventDefinition = EventDefinition(
|
||||
name='chat.all_deleted', description='All chats for a scope were deleted.', message='All chats deleted'
|
||||
)
|
||||
CHAT_COMPACTED: EventDefinition = EventDefinition(
|
||||
name='chat.compacted', description='A chat was compacted.', message='Chat compacted'
|
||||
@@ -306,8 +306,8 @@ class EventDefinitions(BaseModel):
|
||||
description='A channel member active state was updated.',
|
||||
message='Channel member active updated',
|
||||
)
|
||||
CHANNEL_MESSAGE: EventDefinition = EventDefinition(
|
||||
name='channel.message',
|
||||
CHANNEL_MESSAGE_POSTED: EventDefinition = EventDefinition(
|
||||
name='channel.message_posted',
|
||||
description='A channel message was posted.',
|
||||
message='Channel message',
|
||||
)
|
||||
@@ -338,8 +338,8 @@ class EventDefinitions(BaseModel):
|
||||
FILE_DELETED: EventDefinition = EventDefinition(
|
||||
name='file.deleted', description='A file was deleted.', message='File deleted'
|
||||
)
|
||||
FILE_DELETED_ALL: EventDefinition = EventDefinition(
|
||||
name='file.deleted_all', description='All files for a scope were deleted.', message='File deleted all'
|
||||
FILE_ALL_DELETED: EventDefinition = EventDefinition(
|
||||
name='file.all_deleted', description='All files for a scope were deleted.', message='All files deleted'
|
||||
)
|
||||
FOLDER_CREATED: EventDefinition = EventDefinition(
|
||||
name='folder.created', description='A folder was created.', message='Folder created'
|
||||
@@ -543,15 +543,15 @@ class EventDefinitions(BaseModel):
|
||||
FUNCTION_DISABLED: EventDefinition = EventDefinition(
|
||||
name='function.disabled', description='A function was disabled.', message='Function disabled'
|
||||
)
|
||||
FUNCTION_ENABLE_STARTED: EventDefinition = EventDefinition(
|
||||
name='function.enable_started',
|
||||
FUNCTION_ENABLING: EventDefinition = EventDefinition(
|
||||
name='function.enabling',
|
||||
description='A function is about to be enabled.',
|
||||
message='Function enable started',
|
||||
message='Function enabling',
|
||||
)
|
||||
FUNCTION_DISABLE_STARTED: EventDefinition = EventDefinition(
|
||||
name='function.disable_started',
|
||||
FUNCTION_DISABLING: EventDefinition = EventDefinition(
|
||||
name='function.disabling',
|
||||
description='A function is about to be disabled.',
|
||||
message='Function disable started',
|
||||
message='Function disabling',
|
||||
)
|
||||
FUNCTION_VALVES_UPDATED: EventDefinition = EventDefinition(
|
||||
name='function.valves_updated', description='Function valves were updated.', message='Function valves updated'
|
||||
@@ -653,8 +653,8 @@ class EventDefinitions(BaseModel):
|
||||
description='A calendar event RSVP was updated.',
|
||||
message='Calendar Event rsvp updated',
|
||||
)
|
||||
CALENDAR_ALERT: EventDefinition = EventDefinition(
|
||||
name='calendar.alert',
|
||||
CALENDAR_ALERT_TRIGGERED: EventDefinition = EventDefinition(
|
||||
name='calendar.alert_triggered',
|
||||
description='A calendar event alert was triggered.',
|
||||
message='Calendar alert',
|
||||
)
|
||||
@@ -696,8 +696,8 @@ class EventDefinitions(BaseModel):
|
||||
FEEDBACK_DELETED: EventDefinition = EventDefinition(
|
||||
name='feedback.deleted', description='A feedback was deleted.', message='Feedback deleted'
|
||||
)
|
||||
FEEDBACK_DELETED_ALL: EventDefinition = EventDefinition(
|
||||
name='feedback.deleted_all', description='All feedback for a scope was deleted.', message='Feedback deleted all'
|
||||
FEEDBACK_ALL_DELETED: EventDefinition = EventDefinition(
|
||||
name='feedback.all_deleted', description='All feedback for a scope was deleted.', message='All feedback deleted'
|
||||
)
|
||||
IMAGE_GENERATED: EventDefinition = EventDefinition(
|
||||
name='image.generated', description='An image was generated.', message='Image generated'
|
||||
@@ -722,11 +722,13 @@ class EventDefinitions(BaseModel):
|
||||
TERMINAL_SESSION_CLOSED: EventDefinition = EventDefinition(
|
||||
name='terminal.session.closed', description='A terminal session was closed.', message='Terminal Session closed'
|
||||
)
|
||||
NOTIFICATION_TEST: EventDefinition = EventDefinition(
|
||||
name='notification.test', description='A notification target test was sent.', message='Notification test'
|
||||
NOTIFICATION_TEST_SENT: EventDefinition = EventDefinition(
|
||||
name='notification.test_sent',
|
||||
description='A notification target test was sent.',
|
||||
message='Notification test sent',
|
||||
)
|
||||
NOTIFICATION_MANUAL: EventDefinition = EventDefinition(
|
||||
name='notification.manual', description='A manual notification was sent.', message='Notification sent'
|
||||
NOTIFICATION_SENT: EventDefinition = EventDefinition(
|
||||
name='notification.sent', description='A manual notification was sent.', message='Notification sent'
|
||||
)
|
||||
|
||||
|
||||
@@ -736,10 +738,10 @@ EVENT_DEFINITIONS_BY_NAME = {definition.name: definition for definition in EVENT
|
||||
EVENT_CATALOG = tuple(definition.name for definition in EVENT_DEFINITIONS)
|
||||
EVENT_CATALOG_SET = set(EVENT_CATALOG)
|
||||
NOTIFICATION_EVENTS = (
|
||||
EVENTS.CHAT_FINISHED.name,
|
||||
EVENTS.CHAT_FAILED.name,
|
||||
EVENTS.CHANNEL_MESSAGE.name,
|
||||
EVENTS.CALENDAR_ALERT.name,
|
||||
EVENTS.CHAT_RESPONSE_COMPLETED.name,
|
||||
EVENTS.CHAT_RESPONSE_FAILED.name,
|
||||
EVENTS.CHANNEL_MESSAGE_POSTED.name,
|
||||
EVENTS.CALENDAR_ALERT_TRIGGERED.name,
|
||||
EVENTS.AUTOMATION_RUN_FAILED.name,
|
||||
)
|
||||
|
||||
@@ -1166,10 +1168,10 @@ class SocketSessionEventSink:
|
||||
EVENTS.FOLDER_UPDATED.name,
|
||||
EVENTS.FOLDER_PARENT_UPDATED.name,
|
||||
EVENTS.FOLDER_DELETED.name,
|
||||
EVENTS.CHAT_DELETED_ALL.name,
|
||||
EVENTS.CHAT_ALL_DELETED.name,
|
||||
}:
|
||||
await refresh_chat_access()
|
||||
if event.event != EVENTS.CHAT_DELETED_ALL.name:
|
||||
if event.event != EVENTS.CHAT_ALL_DELETED.name:
|
||||
await refresh_note_access()
|
||||
elif event.event == EVENTS.NOTE_FOLDER_UPDATED.name:
|
||||
await refresh_note_access((event.subject or {}).get('id'))
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
"""rename notification events
|
||||
|
||||
Revision ID: 59d393357c0c
|
||||
Revises: 7a0951ce0fe5
|
||||
Create Date: 2026-12-01 00:35:45
|
||||
|
||||
Renames the event names stored in users' notification targets and in inbox notifications
|
||||
to the past-tense names: chat.finished -> chat.response_completed, and so on.
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import context, op
|
||||
|
||||
revision: str = '59d393357c0c'
|
||||
down_revision: str | None = '7a0951ce0fe5'
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
RENAMES = {
|
||||
'chat.finished': 'chat.response_completed',
|
||||
'chat.failed': 'chat.response_failed',
|
||||
'channel.message': 'channel.message_posted',
|
||||
'calendar.alert': 'calendar.alert_triggered',
|
||||
}
|
||||
|
||||
user = sa.table('user', sa.column('id', sa.Text()), sa.column('settings', sa.JSON()))
|
||||
notification = sa.table('notification', sa.column('event_type', sa.Text()))
|
||||
|
||||
|
||||
def rename(renames: dict[str, str]) -> None:
|
||||
if context.is_offline_mode():
|
||||
return
|
||||
conn = op.get_bind()
|
||||
for old, new in renames.items():
|
||||
conn.execute(sa.update(notification).where(notification.c.event_type == old).values(event_type=new))
|
||||
for row in conn.execute(sa.select(user.c.id, user.c.settings)).all():
|
||||
targets = ((row.settings or {}).get('notifications') or {}).get('targets')
|
||||
if not isinstance(targets, list):
|
||||
continue
|
||||
changed = False
|
||||
for target in targets:
|
||||
if isinstance(target, dict) and isinstance(target.get('events'), list):
|
||||
events = [renames.get(event, event) for event in target['events']]
|
||||
if events != target['events']:
|
||||
target['events'] = events
|
||||
changed = True
|
||||
if changed:
|
||||
conn.execute(sa.update(user).where(user.c.id == row.id).values(settings=row.settings))
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
rename(RENAMES)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
rename({new: old for old, new in RENAMES.items()})
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import time
|
||||
import uuid
|
||||
from collections import Counter
|
||||
from collections.abc import Mapping
|
||||
from contextlib import nullcontext
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
@@ -269,7 +270,7 @@ class ChatMessageTable:
|
||||
value = next((data[key] for key in keys if data.get(key)), None)
|
||||
return value if isinstance(value, str) else None
|
||||
|
||||
message = ChatMessage(
|
||||
columns = dict(
|
||||
id=composite_id,
|
||||
chat_id=chat_id,
|
||||
user_id=user_id,
|
||||
@@ -290,7 +291,8 @@ class ChatMessageTable:
|
||||
created_at=(recorded_timestamp(data.get('timestamp')) or 0) if 'timestamp' in data else now,
|
||||
updated_at=now,
|
||||
)
|
||||
from_columns = ChatMessageTable._message_to_dict(message)
|
||||
message = ChatMessage(**columns)
|
||||
from_columns = ChatMessageTable._message_to_dict(columns)
|
||||
message.data = {
|
||||
key: value
|
||||
for key, value in data.items()
|
||||
@@ -299,14 +301,14 @@ class ChatMessageTable:
|
||||
return message
|
||||
|
||||
@classmethod
|
||||
def _message_to_dict(cls, message: ChatMessage | Row) -> dict:
|
||||
"""Convert a row to the chat.history.messages shape, keeping only the fields it has set."""
|
||||
def _message_to_dict(cls, message: Mapping[str, Any]) -> dict:
|
||||
"""Convert a row's columns to the chat.history.messages shape, keeping only the fields it has set."""
|
||||
message_dict = {
|
||||
'id': message.id.removeprefix(f'{message.chat_id}-'),
|
||||
'id': message['id'].removeprefix(f'{message["chat_id"]}-'),
|
||||
**{
|
||||
cls.DB_TO_JSON_KEY_MAP.get(column.key, column.key): getattr(message, column.key)
|
||||
cls.DB_TO_JSON_KEY_MAP.get(column.key, column.key): message[column.key]
|
||||
for column in ChatMessage.__table__.columns
|
||||
if column.key not in cls.EXCLUDED_COLUMNS and getattr(message, column.key) is not None
|
||||
if column.key not in cls.EXCLUDED_COLUMNS and message[column.key] is not None
|
||||
},
|
||||
}
|
||||
if message_dict.get('role') == '':
|
||||
@@ -425,9 +427,10 @@ class ChatMessageTable:
|
||||
child_ids = message.get('childrenIds')
|
||||
return [child_id for child_id in child_ids if isinstance(child_id, str)] if isinstance(child_ids, list) else []
|
||||
|
||||
def to_message(self, row: ChatMessage | Row) -> dict:
|
||||
def to_message(self, row: Row) -> dict:
|
||||
"""The message dict a row was saved from, in the shape of chat.history.messages."""
|
||||
return {**self._message_to_dict(row), **(row.data or {})}
|
||||
# Read by key: attribute reads on a Row are several times slower, which long chats feel.
|
||||
return {**self._message_to_dict(row._mapping), **(row.data or {})}
|
||||
|
||||
async def get_messages_map_by_chat_id(self, chat_id: str, db: Optional[AsyncSession] = None) -> Optional[dict]:
|
||||
"""Build a {message_id: message_dict} map from chat_message rows.
|
||||
|
||||
@@ -476,7 +476,9 @@ class ChatTable:
|
||||
if chat is None:
|
||||
yield None
|
||||
return
|
||||
row = await session.get(ChatMessage, f'{chat_id}-{message_id}')
|
||||
row = (
|
||||
await session.execute(select(ChatMessage.__table__).where(ChatMessage.id == f'{chat_id}-{message_id}'))
|
||||
).first()
|
||||
if row is None:
|
||||
yield None
|
||||
return
|
||||
|
||||
@@ -70,7 +70,7 @@ DATA_TYPES = {
|
||||
'channel.mentioned': NotificationData,
|
||||
'chat.mentioned': ChatMentionData,
|
||||
'channel.replied': NotificationData,
|
||||
'calendar.alert': ReminderData,
|
||||
'calendar.alert_triggered': ReminderData,
|
||||
'automation.run_failed': NotificationData,
|
||||
'system.announcement': SystemData,
|
||||
}
|
||||
|
||||
@@ -895,7 +895,7 @@ async def signup(
|
||||
)
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.AUTH_SIGNUP,
|
||||
EVENTS.AUTH_SIGNED_UP,
|
||||
actor=user,
|
||||
subject_id=user.id,
|
||||
subject_type='user',
|
||||
@@ -941,7 +941,7 @@ async def signout(request: Request, response: Response, db: AsyncSession = Depen
|
||||
await invalidate_token(request, token)
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.AUTH_LOGOUT,
|
||||
EVENTS.AUTH_LOGGED_OUT,
|
||||
actor=actor,
|
||||
subject_id=actor.id if actor else None,
|
||||
subject_type='user' if actor else None,
|
||||
|
||||
@@ -1132,7 +1132,7 @@ async def send_notification(request, channel, message, active_user_ids, db=None)
|
||||
if enable_user_webhooks and u.settings:
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.CHANNEL_MESSAGE,
|
||||
EVENTS.CHANNEL_MESSAGE_POSTED,
|
||||
subject_id=channel.id,
|
||||
subject_type='channel',
|
||||
data={
|
||||
|
||||
@@ -847,7 +847,7 @@ async def delete_all_user_chats(
|
||||
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.CHAT_DELETED_ALL,
|
||||
EVENTS.CHAT_ALL_DELETED,
|
||||
actor=user,
|
||||
subject_id=user.id,
|
||||
subject_type='user',
|
||||
|
||||
@@ -268,7 +268,7 @@ async def delete_all_feedbacks(
|
||||
if success:
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.FEEDBACK_DELETED_ALL,
|
||||
EVENTS.FEEDBACK_ALL_DELETED,
|
||||
actor=user,
|
||||
subject_id='all',
|
||||
)
|
||||
@@ -312,7 +312,7 @@ async def delete_feedbacks(
|
||||
if success:
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.FEEDBACK_DELETED_ALL,
|
||||
EVENTS.FEEDBACK_ALL_DELETED,
|
||||
actor=user,
|
||||
subject_id=user.id,
|
||||
subject_type='user',
|
||||
|
||||
@@ -629,7 +629,7 @@ async def delete_all_files(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DEFAULT('Error deleting files'),
|
||||
)
|
||||
await publish_event(request, EVENTS.FILE_DELETED_ALL, actor=user, subject_type='file')
|
||||
await publish_event(request, EVENTS.FILE_ALL_DELETED, actor=user, subject_type='file')
|
||||
return {'message': 'All files deleted successfully'}
|
||||
else:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -292,7 +292,7 @@ async def toggle_function_by_id(
|
||||
if function:
|
||||
lifecycle_event = build_event(
|
||||
request,
|
||||
EVENTS.FUNCTION_DISABLE_STARTED if function.is_active else EVENTS.FUNCTION_ENABLE_STARTED,
|
||||
EVENTS.FUNCTION_DISABLING if function.is_active else EVENTS.FUNCTION_ENABLING,
|
||||
actor=user,
|
||||
subject_id=function.id,
|
||||
subject_type='function',
|
||||
|
||||
@@ -748,7 +748,7 @@ async def create_session_response(
|
||||
)
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.AUTH_LOGIN,
|
||||
EVENTS.AUTH_LOGGED_IN,
|
||||
actor=user,
|
||||
subject_id=user.id,
|
||||
subject_type='user',
|
||||
|
||||
@@ -1094,7 +1094,7 @@ async def _check_calendar_alerts(app) -> None:
|
||||
|
||||
alert_event = build_event(
|
||||
request,
|
||||
EVENTS.CALENDAR_ALERT,
|
||||
EVENTS.CALENDAR_ALERT_TRIGGERED,
|
||||
subject_id=event.id,
|
||||
subject_type='calendar.event',
|
||||
source='scheduler',
|
||||
|
||||
@@ -70,7 +70,7 @@ async def validate_source(event_type, resource_type, resource_id, object_type, o
|
||||
and obj.automation_id == resource_id
|
||||
and obj.status == 'error'
|
||||
)
|
||||
elif event_type == 'calendar.alert':
|
||||
elif event_type == 'calendar.alert_triggered':
|
||||
valid = (
|
||||
object_type == 'calendar_event'
|
||||
and resource_type == 'calendar'
|
||||
@@ -229,7 +229,7 @@ async def visible_clause(user, db):
|
||||
('message', 'channel_id', ['channel.mentioned', 'channel.replied']),
|
||||
('chat_message', 'chat_id', ['chat.mentioned']),
|
||||
('automation_run', 'automation_id', ['automation.run_failed']),
|
||||
('calendar_event', 'calendar_id', ['calendar.alert']),
|
||||
('calendar_event', 'calendar_id', ['calendar.alert_triggered']),
|
||||
):
|
||||
model = models[kind]
|
||||
conditions = [model.id == Notification.object_id, getattr(model, parent_column) == Notification.resource_id]
|
||||
@@ -435,7 +435,7 @@ async def consume_event(event, db):
|
||||
|
||||
subject_id = (event.subject or {}).get('id')
|
||||
models = source_models()
|
||||
if event.event == EVENTS.CHAT_FINISHED.name:
|
||||
if event.event == EVENTS.CHAT_RESPONSE_COMPLETED.name:
|
||||
from open_webui.utils.chat_id import is_saved_chat_id
|
||||
|
||||
message_id = event.data.get('message_id')
|
||||
@@ -507,7 +507,7 @@ async def consume_event(event, db):
|
||||
object_id=run.id,
|
||||
db=db,
|
||||
)
|
||||
elif event.event == EVENTS.CALENDAR_ALERT.name:
|
||||
elif event.event == EVENTS.CALENDAR_ALERT_TRIGGERED.name:
|
||||
calendar_event = await db.get(models['calendar_event'], subject_id)
|
||||
if not calendar_event or event.data.get('start_at') != calendar_event.start_at:
|
||||
raise ValueError('Calendar alert must reference the current occurrence')
|
||||
|
||||
@@ -269,7 +269,7 @@ async def publish_chat_finished_event(
|
||||
model = (getattr(request.app.state, 'MODELS', {}) or {}).get(metadata.get('model_id'), {})
|
||||
event = build_event(
|
||||
request,
|
||||
EVENTS.CHAT_FINISHED,
|
||||
EVENTS.CHAT_RESPONSE_COMPLETED,
|
||||
actor=user,
|
||||
subject_id=chat_id,
|
||||
subject_type='chat',
|
||||
@@ -312,7 +312,7 @@ async def publish_chat_failed_event(request: Request, user: UserModel, metadata:
|
||||
webui_url = await Config.get('webui.url')
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.CHAT_FAILED,
|
||||
EVENTS.CHAT_RESPONSE_FAILED,
|
||||
actor=user,
|
||||
subject_id=chat_id,
|
||||
subject_type='chat',
|
||||
|
||||
@@ -14,12 +14,12 @@ from open_webui.utils.webhook import post_webhook
|
||||
|
||||
|
||||
VALID_EVENTS = set(NOTIFICATION_EVENTS)
|
||||
LEGACY_EVENTS = {'chat.finished', 'chat.failed'}
|
||||
LEGACY_EVENTS = {'chat.response_completed', 'chat.response_failed'}
|
||||
VALID_DELIVERY = {'away', 'always'}
|
||||
CHAT_FINISHED_EVENT = 'chat.finished'
|
||||
CHAT_FAILED_EVENT = 'chat.failed'
|
||||
CHANNEL_MESSAGE_EVENT = 'channel.message'
|
||||
CALENDAR_ALERT_EVENT = 'calendar.alert'
|
||||
CHAT_FINISHED_EVENT = 'chat.response_completed'
|
||||
CHAT_FAILED_EVENT = 'chat.response_failed'
|
||||
CHANNEL_MESSAGE_EVENT = 'channel.message_posted'
|
||||
CALENDAR_ALERT_EVENT = 'calendar.alert_triggered'
|
||||
|
||||
DEFAULT_TARGET_ID = 'webhook'
|
||||
DESCRIPTION_DEFAULT = object()
|
||||
|
||||
@@ -61,7 +61,7 @@ export const inboxLabels: Record<string, string> = {
|
||||
'channel.mentioned': '{{name}} mentioned you',
|
||||
'chat.mentioned': '{{modelName}} mentioned you',
|
||||
'channel.replied': '{{name}} replied',
|
||||
'calendar.alert': 'Upcoming event',
|
||||
'calendar.alert_triggered': 'Upcoming event',
|
||||
'automation.run_failed': 'Automation failed',
|
||||
'system.announcement': 'Announcement'
|
||||
};
|
||||
@@ -50,12 +50,12 @@
|
||||
// $i18n.t('Chat failed'); $i18n.t('A chat run failed.');
|
||||
let events: { event: string; label: string; description?: string }[] = [
|
||||
{
|
||||
event: 'chat.finished',
|
||||
event: 'chat.response_completed',
|
||||
label: 'Chat finished',
|
||||
description: 'A chat run finished successfully.'
|
||||
},
|
||||
{
|
||||
event: 'chat.failed',
|
||||
event: 'chat.response_failed',
|
||||
label: 'Chat failed',
|
||||
description: 'A chat run failed.'
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user