[GH-ISSUE #12423] issue: Unable to Modify Error Responses from API OpenAI via Functions #55261

Closed
opened 2026-05-05 17:23:08 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @TechBeme on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12423

I'm encountering an issue where I'm unable to modify or intercept error responses returned by any OpenAI API.

My goal is to customize the error messages that are generated. It seems that the function outlet is not executed if the API response is an error (400, 429 etc).

I need assistance in determining if it's possible to access and modify these error responses within the functions and, if so, how to implement it correctly. Any insights or alternative approaches would be greatly appreciated.

My code:

from pydantic import BaseModel, Field
from typing import Optional


class Filter:
    class Valves(BaseModel):
        priority: int = Field(
            default=0, description="Priority level for the filter operations."
        )

    def init(self):
        self.valves = self.Valves()

    def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
        try:
            print(f"inlet:{name}")
            print(f"inlet:body:{body}")
            print(f"inlet:user:{user}")
            return body

        except Exception as err:
            print("[Error logs] inlet error:", err)
            raise Exception(f"[Error logs] inlet error: {err}") from err

    def outlet(self, body: dict, user: Optional[dict] = None) -> dict:
        try:
            print(f"outlet:{name}")
            print(f"outlet:body:{body}")
            print(f"outlet:user:{user}")
            return body

        except Exception as err:
            print("[Error logs] outlet error:", err)
            raise Exception(f"[Error logs] outlet error: {err}") from err
Originally created by @TechBeme on GitHub (Apr 3, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12423 I'm encountering an issue where I'm unable to modify or intercept error responses returned by any OpenAI API. My goal is to customize the error messages that are generated. It seems that the function `outlet` is not executed if the API response is an error (400, 429 etc). I need assistance in determining if it's possible to access and modify these error responses within the functions and, if so, how to implement it correctly. Any insights or alternative approaches would be greatly appreciated. My code: ``` from pydantic import BaseModel, Field from typing import Optional class Filter: class Valves(BaseModel): priority: int = Field( default=0, description="Priority level for the filter operations." ) def init(self): self.valves = self.Valves() def inlet(self, body: dict, user: Optional[dict] = None) -> dict: try: print(f"inlet:{name}") print(f"inlet:body:{body}") print(f"inlet:user:{user}") return body except Exception as err: print("[Error logs] inlet error:", err) raise Exception(f"[Error logs] inlet error: {err}") from err def outlet(self, body: dict, user: Optional[dict] = None) -> dict: try: print(f"outlet:{name}") print(f"outlet:body:{body}") print(f"outlet:user:{user}") return body except Exception as err: print("[Error logs] outlet error:", err) raise Exception(f"[Error logs] outlet error: {err}") from err ```
GiteaMirror added the bug label 2026-05-05 17:23:08 -05:00
Author
Owner

@rgaricano commented on GitHub (Apr 4, 2025):

no, outlet isn't proccesed on api calls: https://github.com/open-webui/open-webui/discussions/8722#discussioncomment-12193783

<!-- gh-comment-id:2777292610 --> @rgaricano commented on GitHub (Apr 4, 2025): no, outlet isn't proccesed on api calls: https://github.com/open-webui/open-webui/discussions/8722#discussioncomment-12193783
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#55261