[PR #3627] [CLOSED] 👀 Supports bad words filtering of message #124960

Closed
opened 2026-05-21 05:15:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/3627
Author: @Yanyutin753
Created: 7/4/2024
Status: ❌ Closed

Base: dev ← Head: new_filter


📝 Commits (7)

  • 0a4901d 👀 Supports bad words filtering of message
  • b62762f 🤯 feat global message check for bad words replacement
  • b363863 🤖 fix format and test
  • 9753dd7 🤖 fix format
  • e8a159c 🤖 fix format and test
  • f431b21 🤖 fix format
  • b6c1e76 🤖 fix format

📊 Changes

50 files changed (+1024 additions, -43 deletions)

View changed files

➕ backend/apps/filter/hashNode.py (+29 -0)
➕ backend/apps/filter/main.py (+153 -0)
➕ backend/apps/filter/trieNode.py (+25 -0)
➕ backend/apps/filter/wordsSearch.py (+181 -0)
📝 backend/apps/openai/main.py (+22 -25)
📝 backend/config.py (+35 -0)
📝 backend/main.py (+2 -1)
➕ src/lib/apis/filter/index.ts (+66 -0)
📝 src/lib/components/admin/Settings.svelte (+33 -0)
➕ src/lib/components/admin/Settings/Filter.svelte (+149 -0)
📝 src/lib/constants.ts (+1 -0)
📝 src/lib/i18n/locales/ar-BH/translation.json (+8 -0)
📝 src/lib/i18n/locales/bg-BG/translation.json (+8 -0)
📝 src/lib/i18n/locales/bn-BD/translation.json (+8 -0)
📝 src/lib/i18n/locales/ca-ES/translation.json (+8 -0)
📝 src/lib/i18n/locales/ceb-PH/translation.json (+8 -0)
📝 src/lib/i18n/locales/de-DE/translation.json (+8 -0)
📝 src/lib/i18n/locales/dg-DG/translation.json (+8 -0)
📝 src/lib/i18n/locales/en-GB/translation.json (+8 -0)
📝 src/lib/i18n/locales/en-US/translation.json (+8 -0)

...and 30 more files

📄 Description

👀 Supports bad words filtering of message

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?

Changelog Entry

Description

  • Sometimes, I want to filter messagess by keywords so that we can better use the service. So that, I white this.

1. I create 5 environment variables

Variable Name Description Function
ENABLE_MESSAGE_FILTER Enables message filtering functionality When set to true, the system filters all incoming and outgoing messages to ensure they do not contain any prohibited content.
CHAT_FILTER_WORDS_FILE File containing the list of words to filter The system reads the words to be filtered from the badwords.txt file and checks them against message content.
CHAT_FILTER_WORDS List of specific words to be filtered, separated by commas The system checks message content against these words and filters them if they are found.
ENABLE_REPLACE_FILTER_WORDS Enables the replacement functionality When set to true, the system replaces filtered words with a preset replacement word. When set to false, it does not replace and send a error.
REPLACE_FILTER_WORDS Content to replace filtered words with If ENABLE_REPLACE_FILTER_WORDS is set to true, filtered words will be replaced with the content specified by this variable.

2. and I add the page in admin panel so that we can manage it very easy

image

3. we can manage its switches and add all the bad words we need to desable or replace

image

image

4. Global message check for bad words replacement

image
image
image

5. Efficient inspection efficiency

image

image

Passed the self-test


🔄 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/3627 **Author:** [@Yanyutin753](https://github.com/Yanyutin753) **Created:** 7/4/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `new_filter` --- ### 📝 Commits (7) - [`0a4901d`](https://github.com/open-webui/open-webui/commit/0a4901db82bf5c30b4c12e325b054a37ca7cfbdf) 👀 Supports bad words filtering of message - [`b62762f`](https://github.com/open-webui/open-webui/commit/b62762fded76c43e4c03df86fb8149c0c0fb86f5) 🤯 feat global message check for bad words replacement - [`b363863`](https://github.com/open-webui/open-webui/commit/b3638639f30f4ca140652d3310277544aaeb8d39) 🤖 fix format and test - [`9753dd7`](https://github.com/open-webui/open-webui/commit/9753dd7b40a7d35cf47a7fa05dd0c6a778d52074) 🤖 fix format - [`e8a159c`](https://github.com/open-webui/open-webui/commit/e8a159cd96d0d9947310beca313687135b431f42) 🤖 fix format and test - [`f431b21`](https://github.com/open-webui/open-webui/commit/f431b21bfb531f0d6f9cb337f5ae67f2f6c97c23) 🤖 fix format - [`b6c1e76`](https://github.com/open-webui/open-webui/commit/b6c1e76b274858b4386983eeaf092bb7c625c1d0) 🤖 fix format ### 📊 Changes **50 files changed** (+1024 additions, -43 deletions) <details> <summary>View changed files</summary> ➕ `backend/apps/filter/hashNode.py` (+29 -0) ➕ `backend/apps/filter/main.py` (+153 -0) ➕ `backend/apps/filter/trieNode.py` (+25 -0) ➕ `backend/apps/filter/wordsSearch.py` (+181 -0) 📝 `backend/apps/openai/main.py` (+22 -25) 📝 `backend/config.py` (+35 -0) 📝 `backend/main.py` (+2 -1) ➕ `src/lib/apis/filter/index.ts` (+66 -0) 📝 `src/lib/components/admin/Settings.svelte` (+33 -0) ➕ `src/lib/components/admin/Settings/Filter.svelte` (+149 -0) 📝 `src/lib/constants.ts` (+1 -0) 📝 `src/lib/i18n/locales/ar-BH/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/bg-BG/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/bn-BD/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/ca-ES/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/ceb-PH/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/de-DE/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/dg-DG/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/en-GB/translation.json` (+8 -0) 📝 `src/lib/i18n/locales/en-US/translation.json` (+8 -0) _...and 30 more files_ </details> ### 📄 Description 👀 Supports bad words filtering of message - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? # Changelog Entry ### Description - Sometimes, I want to filter messagess by keywords so that we can better use the service. So that, I white this. #### 1. I create 5 environment variables | Variable Name | Description | Function | |------------------------------|-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ENABLE_MESSAGE_FILTER | Enables message filtering functionality | When set to `true`, the system filters all incoming and outgoing messages to ensure they do not contain any prohibited content. | | CHAT_FILTER_WORDS_FILE | File containing the list of words to filter | The system reads the words to be filtered from the `badwords.txt` file and checks them against message content. | | CHAT_FILTER_WORDS | List of specific words to be filtered, separated by commas | The system checks message content against these words and filters them if they are found. | | ENABLE_REPLACE_FILTER_WORDS | Enables the replacement functionality | When set to `true`, the system replaces filtered words with a preset replacement word. When set to `false`, it does not replace and send a error. | | REPLACE_FILTER_WORDS | Content to replace filtered words with | If `ENABLE_REPLACE_FILTER_WORDS` is set to `true`, filtered words will be replaced with the content specified by this variable. | #### 2. and I add the page in admin panel so that we can manage it very easy ![image](https://github.com/open-webui/open-webui/assets/132346501/ecd95959-e782-466e-8a76-ef3a345460f1) #### 3. we can manage its switches and add all the bad words we need to desable or replace ![image](https://github.com/open-webui/open-webui/assets/132346501/8a55524a-5f27-4cd4-802b-db9ce30d7260) ![image](https://github.com/open-webui/open-webui/assets/132346501/6973cc60-59db-4235-b949-7dcb162cc579) #### 4. Global message check for bad words replacement ![image](https://github.com/open-webui/open-webui/assets/132346501/1b18f798-a47b-4aa0-b0de-a42cf16381cc) ![image](https://github.com/open-webui/open-webui/assets/132346501/b738890b-52f3-46b0-923c-6e93d3b5a8de) ![image](https://github.com/open-webui/open-webui/assets/132346501/01aa7d0d-8c3b-4fae-8090-145d635ca211) #### 5. Efficient inspection efficiency ![image](https://github.com/open-webui/open-webui/assets/132346501/14701087-0761-4f50-af76-789895fd23a2) ![image](https://github.com/open-webui/open-webui/assets/132346501/cd307317-1df2-47c5-801f-af4f429cb4a9) ### Passed the self-test --- <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-21 05:15:28 -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#124960