mirror of
https://github.com/open-webui/docs
synced 2025-05-19 18:58:41 +00:00
Update filter.mdx
This commit is contained in:
parent
5077d9bde9
commit
9bad6ca5e5
@ -155,19 +155,19 @@ Note: The user feels the same, but the model processes a cleaner and easier-to-u
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🆕 3️⃣ **`stream` Hook (New in Open WebUI 0.5.17)**
|
#### 🆕 3️⃣ **`stream` Hook (New in Open WebUI 0.5.17)**
|
||||||
|
|
||||||
### 🔄 What is the `stream` Hook?
|
##### 🔄 What is the `stream` Hook?
|
||||||
The **`stream` function** is a new feature introduced in Open WebUI **0.5.17** that allows you to **intercept and modify streamed model responses** in real time.
|
The **`stream` function** is a new feature introduced in Open WebUI **0.5.17** that allows you to **intercept and modify streamed model responses** in real time.
|
||||||
|
|
||||||
Unlike `outlet`, which processes an entire completed response, `stream` operates on **individual chunks** as they are received from the model.
|
Unlike `outlet`, which processes an entire completed response, `stream` operates on **individual chunks** as they are received from the model.
|
||||||
|
|
||||||
#### 🛠️ When to Use the Stream Hook?
|
##### 🛠️ When to Use the Stream Hook?
|
||||||
- Modify **streaming responses** before they are displayed to users.
|
- Modify **streaming responses** before they are displayed to users.
|
||||||
- Implement **real-time censorship or cleanup**.
|
- Implement **real-time censorship or cleanup**.
|
||||||
- **Monitor streamed data** for logging/debugging.
|
- **Monitor streamed data** for logging/debugging.
|
||||||
|
|
||||||
### 📜 Example: Logging Streaming Chunks
|
##### 📜 Example: Logging Streaming Chunks
|
||||||
|
|
||||||
Here’s how you can inspect and modify streamed LLM responses:
|
Here’s how you can inspect and modify streamed LLM responses:
|
||||||
```python
|
```python
|
||||||
@ -186,7 +186,7 @@ def stream(self, event: dict) -> dict:
|
|||||||
- Each line represents a **small fragment** of the model's streamed response.
|
- Each line represents a **small fragment** of the model's streamed response.
|
||||||
- The **`delta.content` field** contains the progressively generated text.
|
- The **`delta.content` field** contains the progressively generated text.
|
||||||
|
|
||||||
### 🔄 Example: Filtering Out Emojis from Streamed Data
|
##### 🔄 Example: Filtering Out Emojis from Streamed Data
|
||||||
```python
|
```python
|
||||||
def stream(self, event: dict) -> dict:
|
def stream(self, event: dict) -> dict:
|
||||||
for choice in event.get("choices", []):
|
for choice in event.get("choices", []):
|
||||||
|
Loading…
Reference in New Issue
Block a user