Pipe Function Executes Before Inlet in Latest OWUI Version
Hi all, with the latest version of OWUI, it seems that the pipe function is called before the inlet, and I can no longer handle this situation.
async def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
chat_id = body.get("chat_id")
# openwebui > 5.1 compatibility
if chat_id is None:
chat_id = body.get("metadata") ["chat_id"]
body["chat_id"] = chat_id
return body
def pipe(
self, user_message: str, model_id: str, messages: List[dict], body: dict
) -> Union[str, Generator, Iterator]:
chat_id = body.get('chat_id', 'no chat id')
... omitted code ...
any suggestions ?
I'm seeing the same issue and it is causing all sorts of problems.
Yes! Especially if you have based your agents on that for retrieving information about the chat_id, as we do. I have also opened an issue here: https://github.com/open-webui/open-webui/issues/9515, but it has been closed. I need to find time to document the scenario because the response doesn’t seem related to the behavior observed.
I understand that the pipe function is not asynchronous, but the issue originates from the invocation of the FastAPI endpoint of the pipeline service, which is asynchronous. If you run version 0.5.7, the flow works correctly: the inlet endpoint (FastAPI route) is invoked, followed by the completion endpoint (FastAPI route). However, starting from version 0.5.8, the inlet endpoint is not invoked properly.
I try to mention @tjbck to have more info about that maybe he can give us feedback how to manage the scenario.
We cannot migrate beyond version 0.5.7 due to this issue, which I believe is caused by some inversion of the invocation on the OpenWebUI side but correct me if I'm wrong.
Thanks a lot!
I'm seeing the same thing. For me, I don't see inlet running at all, but that has the same effect as inlet running after pipe. It really shouldn't do that according to the documentation, and didn't do that throughout all the previous versions. We are stuck on prior versions as well.
Could we get backend logs for this issue? Issue templates exist for a reason 😅
@NTTLuke Latest Open WebUI dev might've addressed the issue. Testing wanted here!
Love you, man! I see now since I’m in a different tz than yours I’ll do it when I’m back home … even before I take shower 😜 I’ll keep u posted !
Hi @tjbck, I have tested the dev.
Here are my thoughts:
Test 1: Using my actual pipeline (aka PipelineA) doesn't work. Test 2: I created a new pipeline from scratch (PipelineB) with just a print, and it works fine. Test 3: I copied the exact same code (identical) from my PipelineA into PipelineB, and it works.
However, PipelineA continues to not work. Strange behavior but in conclusion, if I need to copy the old code into new pipelines, it's ok.
Let's just say that starting from scratch with a new pipeline the dev branch resolves the issue.
Thanks a lot !!!
@pfedasullivan any feedback on your side ?
I've confirmed that I had to delete the original pipeline, and create a new pipeline with the same code for it to start working.
Unfortunately recreating the pipeline did not work for us. (Using v0.5.12). More detail:
- We are trying to integrate langfuse using these instructions: https://langfuse.com/docs/integrations/openwebui
- We are currently aware of issues/PRs: https://github.com/open-webui/pipelines/pull/403
Let’s try changing the pipeline name , the id and the file name (your_pipeline.py ) in order to have different values compared to the actual one you are using . With this trick my old pipelines work fine with the 0.5.12 and the dev branch .
I will give that a go! @NTTLuke thanks! Will revert back
@NTTLuke unfortunately, still doesn't work. I tried readding the pipeline using different names and config, still same problem. Inlet is not being called. I tried using the original langfuse pipeline as mentioned above and the updated/fixed langfuse pipeline in the PR mentioned above. Neither worked. Interestingly, I do get the autocompletion task traces in langfuse, which does hit the inlet. I will investigate more and get back on this as the actual chat does not get logged, as a result of the inlet not firing.
OMG ! Very strange Last try : use the “dev” branch
Same thing happens to me. I tried to create a new filter from scratch but I couldn't make it work.
Initial testing shows that issue is not fixed in dev branch.
Test cases tried so far on dev branch,
- Delete old filter and create new filter from scratch with same code : Not working
- Remove pipeline configuration and reconfigure pipeline and create filter again : Not working
- Removed pipeline docker, started new pipeline docker, reconfigure on on opern webui with new filter with same code : Not working
- Run OWUI:v0.5.7 with same same pipeline and filter : Working fine as expected
NOTE: I have kept docker persistant volume using "-v open-webui:/app/backend/data" for all of the above test cases.
I confirm same issue, everything was working properly till 0.5.7. @tjbck any news?
Hi, i opened that issue yesterday: https://github.com/open-webui/open-webui/issues/10632
It's an issue related to filter functions (not pipelines) where I noticed that modifying the body in inlet and outputting it resulted in no changes (the body seemed reset somehow to its original state).
I reproduced it, found other non working turn limiting filters and still had the issue. It somehow was not here anymore after restarting the docker compose.
So, i don't know if this is related to the issue here but encourage everyone to restart the app every time before actually testing anything because I suspect there are stateful issues in open-webui.
And btw: i made a debug filter that simply prints what goes through it, it's pretty useful! With priorities you can even sandwich another filter with it. Here's the link: https://github.com/thiswillbeyourgithub/openwebui_custom_pipes_filters/blob/main/filters/debug_filter.py
Hope it helps.
On the latest OWUI v0.5.20 this is how to reproduce (the inlet and outlet is not working at all for me):
Note this is a Function, which is added in the OWUI interface:
"""
title: Example Pipe
version: 0.1
"""
from pydantic import BaseModel, Field
from typing import Optional
class Pipe:
class Valves(BaseModel):
pass
def __init__(self):
self.valves = self.Valves()
def inlet(self, body: dict, __user__: Optional[dict] = None) -> dict:
print(f"\n REACHED THE INLET")
print(f"inlet:{__name__}")
print(f"inlet:body:{body}")
print(f"inlet:user:{__user__}")
return body
def pipe(self, body: dict):
print(f"\n REACHED THE PIPE")
print(f"pipe:body:{body}")
return "Hello World!"
def outlet(self, body: dict, __user__: Optional[dict] = None) -> dict:
print(f"\n REACHED THE OUTLET")
print(f"outlet:{__name__}")
print(f"outlet:body:{body}")
print(f"outlet:user:{__user__}")
return body
If I type a message to the function, this is the output of the container logs:
The environment used for OWUI:
environment:
- DATABASE_URL=postgresql://myusername:mypassword@postgres-db:5432/open-webui-db
- ENABLE_WEBSOCKET_SUPPORT=true
- WEBSOCKET_MANAGER=redis
- WEBSOCKET_REDIS_URL=redis://redis:6379/1
- GLOBAL_LOG_LEVEL=DEBUG