[GH-ISSUE #8168] Issue with __event_emitter__ and Content Persistence in Custom Functions Using Predefined outlet Method #15026

Closed
opened 2026-04-19 21:18:49 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @cr-zhichen on GitHub (Dec 28, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/8168

Originally assigned to: @tjbck on GitHub.

Bug Report

Installation Method

I installed Open WebUI using docker-compose.

Environment

  • Open WebUI Version: v0.5.2
  • Operating System: Windows 10
  • Browser: Edge 131.0.2903.112 (Official Build) (64-bit)

Expected Behavior:

  1. In a custom function, the __event_emitter__ parameter passed to the outlet method should work as expected, allowing events to be emitted successfully.
  2. When modifying body["messages"][-1]["content"] in the outlet method of a custom function, the changes should persist, and the front-end should display the updated content without reverting to the model's original output.

Actual Behavior:

  1. The __event_emitter__ parameter in the outlet method does not function as intended, preventing events from being emitted.
  2. When body["messages"][-1]["content"] is modified in the outlet method, the front-end briefly displays the updated content ("TEST") but then reverts to the model's actual output.

Description

The issue occurs when using custom functions within the outlet method, which is a predefined function provided by the open-source project. The __event_emitter__ parameter fails to emit events, and modifications to the body["messages"][-1]["content"] field are not persisted in the front-end display.

Reproduction Details

  1. Define a custom function that uses the outlet method provided by the open-source project.
  2. Attempt to use the __event_emitter__ parameter to emit events.
  3. Modify the body["messages"][-1]["content"] field in the outlet method.
  4. Observe that the __event_emitter__ does not work and the front-end reverts the modified content to the model's output.

https://github.com/user-attachments/assets/92828329-5df1-4e3d-9a2d-3a757e5895fc

Example Code

  1. When using the function feature, the __event_emitter__ parameter passed in the outlet method cannot be used properly. Below is a reproducible function example.
import asyncio
import random
import re
from typing import Callable, Awaitable, Any, Optional

import aiohttp
from pydantic import BaseModel, Field

class AIOutput(BaseModel):
    success: bool
    prompt: str
    width: int
    height: int
    reason: Optional[str] = None
    seed: int = Field(default=-1)

class Filter:
    async def inlet(
        self,
        body: dict,
        __event_emitter__: None,
        __user__: Optional[dict] = None,
        __model__: Optional[dict] = None,
    ) -> dict:
        await __event_emitter__(
            {
                "type": "status",
                "data": {
                    "description": "inlet",
                    "done": False,
                },
            }
        )
        return body

    async def outlet(
        self,
        body: dict,
        __event_emitter__: None,
        __user__: Optional[dict] = None,
        __model__: Optional[dict] = None,
    ) -> dict:
        await __event_emitter__(
            {
                "type": "status",
                "data": {
                    "description": "outlet",
                    "done": True,
                },
            }
        )
        return body
  1. In the outlet method, using a statement like body["messages"][-1]["content"] = "TEST" will cause the front-end page to update the information to "TEST" after the output is completed, but it will instantly switch back to the actual content output by the model. Below is a reproducible function example.
    async def outlet(
        self,
        body: dict,
        __event_emitter__: None,
        __user__: Optional[dict] = None,
        __model__: Optional[dict] = None,
    ) -> dict:
        body["messages"][-1]["content"] = "TEST"
        return body
Originally created by @cr-zhichen on GitHub (Dec 28, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/8168 Originally assigned to: @tjbck on GitHub. # Bug Report ## Installation Method I installed Open WebUI using `docker-compose`. ## Environment - **Open WebUI Version:** v0.5.2 - **Operating System:** Windows 10 - **Browser:** Edge 131.0.2903.112 (Official Build) (64-bit) ## Expected Behavior: 1. In a custom function, the `__event_emitter__` parameter passed to the `outlet` method should work as expected, allowing events to be emitted successfully. 2. When modifying `body["messages"][-1]["content"]` in the `outlet` method of a custom function, the changes should persist, and the front-end should display the updated content without reverting to the model's original output. ## Actual Behavior: 1. The `__event_emitter__` parameter in the `outlet` method does not function as intended, preventing events from being emitted. 2. When `body["messages"][-1]["content"]` is modified in the `outlet` method, the front-end briefly displays the updated content ("TEST") but then reverts to the model's actual output. ## Description The issue occurs when using custom functions within the `outlet` method, which is a predefined function provided by the open-source project. The `__event_emitter__` parameter fails to emit events, and modifications to the `body["messages"][-1]["content"]` field are not persisted in the front-end display. ## Reproduction Details 1. Define a custom function that uses the `outlet` method provided by the open-source project. 2. Attempt to use the `__event_emitter__` parameter to emit events. 3. Modify the `body["messages"][-1]["content"]` field in the `outlet` method. 4. Observe that the `__event_emitter__` does not work and the front-end reverts the modified content to the model's output. https://github.com/user-attachments/assets/92828329-5df1-4e3d-9a2d-3a757e5895fc ## Example Code 1. When using the function feature, the `__event_emitter__` parameter passed in the `outlet` method cannot be used properly. Below is a reproducible function example. ```python import asyncio import random import re from typing import Callable, Awaitable, Any, Optional import aiohttp from pydantic import BaseModel, Field class AIOutput(BaseModel): success: bool prompt: str width: int height: int reason: Optional[str] = None seed: int = Field(default=-1) class Filter: async def inlet( self, body: dict, __event_emitter__: None, __user__: Optional[dict] = None, __model__: Optional[dict] = None, ) -> dict: await __event_emitter__( { "type": "status", "data": { "description": "inlet", "done": False, }, } ) return body async def outlet( self, body: dict, __event_emitter__: None, __user__: Optional[dict] = None, __model__: Optional[dict] = None, ) -> dict: await __event_emitter__( { "type": "status", "data": { "description": "outlet", "done": True, }, } ) return body ``` 2. In the `outlet` method, using a statement like `body["messages"][-1]["content"] = "TEST"` will cause the front-end page to update the information to "TEST" after the output is completed, but it will instantly switch back to the actual content output by the model. Below is a reproducible function example. ```python async def outlet( self, body: dict, __event_emitter__: None, __user__: Optional[dict] = None, __model__: Optional[dict] = None, ) -> dict: body["messages"][-1]["content"] = "TEST" return body ```
Author
Owner

@tjbck commented on GitHub (Dec 29, 2024):

Thank you for your detailed issue report! Not many people take the time to provide the necessary details in such a clear and systematic manner, so I truly appreciate your effort. You're an exemplary example of how to report issues effectively. That being said, I wanted to let you know that both issues have been addressed in dev!

<!-- gh-comment-id:2564586816 --> @tjbck commented on GitHub (Dec 29, 2024): Thank you for your detailed issue report! Not many people take the time to provide the necessary details in such a clear and systematic manner, so I truly appreciate your effort. You're an exemplary example of how to report issues effectively. That being said, I wanted to let you know that both issues have been addressed in dev!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#15026