[PR #18050] [CLOSED] feat(callback): add asynchronous callback system #63510

Closed
opened 2026-05-06 08:20:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/18050
Author: @mitchou10
Created: 10/4/2025
Status: Closed

Base: devHead: feat/route-callback


📝 Commits (1)

  • f1aa79c feat: implement CallbackRoute for enhanced request handling across routers

📊 Changes

6 files changed (+134 additions, -4 deletions)

View changed files

📝 backend/open_webui/routers/evaluations.py (+2 -1)
📝 backend/open_webui/routers/files.py (+2 -1)
📝 backend/open_webui/routers/knowledge.py (+2 -1)
📝 backend/open_webui/routers/notes.py (+2 -1)
backend/open_webui/test/util/test_callback.py (+70 -0)
backend/open_webui/utils/callback.py (+56 -0)

📄 Description

Pull Request Checklist

Discussions 18017

Before submitting, make sure you've checked the following:

  • Target branch: dev
  • Description: Added asynchronous callback mechanism with unit tests.
  • Changelog: Entry added below.
  • Documentation: Added inline docstrings and clarified environment variables.
  • Testing: Implemented pytest unit tests for send_callback.
  • Code review: Self-reviewed for async safety and mocking consistency.
  • Prefix: feat

Changelog Entry

Description

Introduce an asynchronous callback system for selected API routes.
This allows Open WebUI to notify an external service whenever a response is produced by specific endpoints.

Added

  • open_webui/utils/callback.py containing:
    • CallbackPayload (Pydantic model)
    • send_callback() async helper
    • CallbackRoute class for automatic callback dispatch
  • test/utils/test_callback.py unit tests for callback behavior
  • Integration of CallbackRoute into the following route modules:
    • knowledge
    • notes
    • files
    • feedback

Changed

  • Routers updated to inherit from CallbackRoute for automatic callback handling.
  • Two new environment variables introduced:
    • CALLBACK_URL
    • CALLBACK_TOKEN

Fixed

  • Proper JSON serialization for Pydantic models via payload.model_dump().

Security

  • Callback requests use a Bearer token header for authentication.

Additional Information

This feature enables external systems (e.g., monitoring dashboards, automation tools) to receive live response data from the Open WebUI API for synchronization or analytics purposes.
Unit tests validate correct async behavior and ensure no external calls occur when environment variables are missing.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
CONTRIBUTING


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/18050 **Author:** [@mitchou10](https://github.com/mitchou10) **Created:** 10/4/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/route-callback` --- ### 📝 Commits (1) - [`f1aa79c`](https://github.com/open-webui/open-webui/commit/f1aa79cac8611be583ba1b4a31a98915226de078) feat: implement CallbackRoute for enhanced request handling across routers ### 📊 Changes **6 files changed** (+134 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/evaluations.py` (+2 -1) 📝 `backend/open_webui/routers/files.py` (+2 -1) 📝 `backend/open_webui/routers/knowledge.py` (+2 -1) 📝 `backend/open_webui/routers/notes.py` (+2 -1) ➕ `backend/open_webui/test/util/test_callback.py` (+70 -0) ➕ `backend/open_webui/utils/callback.py` (+56 -0) </details> ### 📄 Description # Pull Request Checklist ### [Discussions 18017](https://github.com/open-webui/open-webui/discussions/18017) **Before submitting, make sure you've checked the following:** - [x] **Target branch:** dev - [x] **Description:** Added asynchronous callback mechanism with unit tests. - [x] **Changelog:** Entry added below. - [x] **Documentation:** Added inline docstrings and clarified environment variables. - [x] **Testing:** Implemented pytest unit tests for send_callback. - [x] **Code review:** Self-reviewed for async safety and mocking consistency. - [x] **Prefix:** feat # Changelog Entry ### Description Introduce an asynchronous callback system for selected API routes. This allows Open WebUI to notify an external service whenever a response is produced by specific endpoints. ### Added - `open_webui/utils/callback.py` containing: - `CallbackPayload` (Pydantic model) - `send_callback()` async helper - `CallbackRoute` class for automatic callback dispatch - `test/utils/test_callback.py` unit tests for callback behavior - Integration of `CallbackRoute` into the following route modules: - `knowledge` - `notes` - `files` - `feedback` ### Changed - Routers updated to inherit from `CallbackRoute` for automatic callback handling. - Two new environment variables introduced: - `CALLBACK_URL` - `CALLBACK_TOKEN` ### Fixed - Proper JSON serialization for Pydantic models via `payload.model_dump()`. ### Security - Callback requests use a Bearer token header for authentication. --- ### Additional Information This feature enables external systems (e.g., monitoring dashboards, automation tools) to receive live response data from the Open WebUI API for synchronization or analytics purposes. Unit tests validate correct async behavior and ensure no external calls occur when environment variables are missing. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. [CONTRIBUTING](https://github.com/open-webui/open-webui/blob/4d7fddaf7e434bf59fdd879ef11d712a503b7863/docs/CONTRIBUTING.md) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 08:20:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#63510