mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-22 06:02:06 -05:00
issue: Nuisance re-instantiation of Valves causing multiple triggering's of Valves.__init__(). #4904
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lord-Mercury on GitHub (Apr 19, 2025).
Check Existing Issues
Installation Method
Docker
Open WebUI Version
0.6.5
Ollama Version (if applicable)
No response
Operating System
Window 10
Browser (if applicable)
Chrome 135.0.7049.96
Confirmation
README.md.Expected Behavior
Pipe.Valves instantiated once and init() triggered only when Valves actually updated.
Actual Behavior
open-webui/functions.py
def get_function_module_by_id(request: Request, pipe_id: str):
# Check if function is already loaded
if pipe_id not in request.app.state.FUNCTIONS:
function_module, _, _ = load_function_module_by_id(pipe_id)
request.app.state.FUNCTIONS[pipe_id] = function_module
else:
function_module = request.app.state.FUNCTIONS[pipe_id]
The hasattr section at the bottom re-instantiates Valves as self.valves if the Pipe module uses self.valves every time get_function_module_by_id() is called.
Steps to Reproduce
Numerous ways to trigger this line of code unnecessarily.
Simple Pipe function with Valves and isntantiate self.valves =self.Valves() in Pipe.init or even Pipe.pipe(). Open
Pipe.Valves.init(self):
print("Valves.init was here")
Admin panel and open models section
Logs & Screenshots
2025-04-18 18:51:20.441 | 2025-04-19 01:51:20.440 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:56838 - "GET /api/v1/retrieval/config HTTP/1.1" 200 - {}
2025-04-18 18:51:21.570 | 2025-04-19 01:51:21.570 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:56838 - "GET /api/v1/retrieval/embedding HTTP/1.1" 200 - {}
2025-04-18 18:51:21.590 | 2025-04-19 01:51:21.589 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:56838 - "GET /api/v1/retrieval/reranking HTTP/1.1" 200 - {}
2025-04-18 18:51:21.601 | 2025-04-19 01:51:21.601 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:56838 - "GET /api/v1/retrieval/config HTTP/1.1" 200 - {}
2025-04-18 18:51:28.880 | 2025-04-19 01:51:28.880 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:37044 - "GET /api/v1/models/base HTTP/1.1" 200 - {}
2025-04-18 18:51:28.881 | 2025-04-19 01:51:28.880 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:37030 - "GET /api/v1/configs/models HTTP/1.1" 200 - {}
2025-04-18 18:51:28.883 | 2025-04-19 01:51:28.883 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:37038 - "GET /ollama/config HTTP/1.1" 200 - {}
2025-04-18 18:51:28.897 | 2025-04-19 01:51:28.897 | INFO | open_webui.routers.openai:get_all_models:389 - get_all_models() - {}
2025-04-18 18:51:29.340 | 2025-04-19 01:51:29.339 | INFO | open_webui.routers.ollama:get_all_models:300 - get_all_models() - {}
2025-04-18 18:51:29.383 | [function_grokedinstantiation] Valves initialized at 2025-04-19 01:51:29.373882
2025-04-18 18:51:29.383 | Function ID: grokedinstantiation
2025-04-18 18:51:29.383 | Stack trace:
2025-04-18 18:51:29.383 | File "/usr/local/bin/uvicorn", line 10, in
2025-04-18 18:51:29.383 | sys.exit(main())
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1161, in call
2025-04-18 18:51:29.383 | return self.main(*args, **kwargs)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1082, in main
2025-04-18 18:51:29.383 | rv = self.invoke(ctx)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1443, in invoke
2025-04-18 18:51:29.383 | return ctx.invoke(self.callback, **ctx.params)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/click/core.py", line 788, in invoke
2025-04-18 18:51:29.383 | return __callback(*args, **kwargs)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 412, in main
2025-04-18 18:51:29.383 | run(
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 579, in run
2025-04-18 18:51:29.383 | server.run()
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 66, in run
2025-04-18 18:51:29.383 | return asyncio.run(self.serve(sockets=sockets))
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
2025-04-18 18:51:29.383 | return runner.run(main)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
2025-04-18 18:51:29.383 | return self._loop.run_until_complete(task)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro
2025-04-18 18:51:29.383 | await self.app(scope, receive_or_disconnect, send_no_error)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
2025-04-18 18:51:29.383 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
2025-04-18 18:51:29.383 | await app(scope, receive, sender)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
2025-04-18 18:51:29.383 | await self.middleware_stack(scope, receive, send)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
2025-04-18 18:51:29.383 | await route.handle(scope, receive, send)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
2025-04-18 18:51:29.383 | await self.app(scope, receive, send)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
2025-04-18 18:51:29.383 | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
2025-04-18 18:51:29.383 | await app(scope, receive, sender)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
2025-04-18 18:51:29.383 | response = await f(request)
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
2025-04-18 18:51:29.383 | raw_response = await run_endpoint_function(
2025-04-18 18:51:29.383 | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
2025-04-18 18:51:29.383 | return await dependant.call(values)
2025-04-18 18:51:29.383 | File "/app/backend/open_webui/main.py", line 1064, in get_base_models
2025-04-18 18:51:29.383 | models = await get_all_base_models(request, user=user)
2025-04-18 18:51:29.383 | File "/app/backend/open_webui/utils/models.py", line 57, in get_all_base_models
2025-04-18 18:51:29.383 | function_models = await get_function_models(request)
2025-04-18 18:51:29.383 | File "/app/backend/open_webui/functions.py", line 74, in get_function_models
2025-04-18 18:51:29.383 | function_module = get_function_module_by_id(request, pipe.id)
2025-04-18 18:51:29.383 | File "/app/backend/open_webui/functions.py", line 65, in get_function_module_by_id
2025-04-18 18:51:29.383 | function_module.valves = function_module.Valves((valves if valves else {}))
2025-04-18 18:51:29.383 | File "", line 36, in init
2025-04-18 18:51:29.383 |
2025-04-18 18:51:29.383 | 2025-04-19 01:51:29.382 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:37044 - "GET /api/models/base HTTP/1.1" 200 - {}
2025-04-18 19:32:45.838 | 2025-04-19 02:32:45.838 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:55414 - "GET /api/v1/chats/bb434674-7999-4339-a0c4-d45294b51c0c HTTP/1.1" 200 - {}
2025-04-18 19:32:45.871 | 2025-04-19 02:32:45.871 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:55414 - "GET /api/v1/chats/bb434674-7999-4339-a0c4-d45294b51c0c HTTP/1.1" 200 - {}
2025-04-18 19:32:46.704 | 2025-04-19 02:32:46.703 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:55414 - "GET /api/v1/chats/6f8c26f3-12bf-4e07-9701-cf5f3b56b6f4 HTTP/1.1" 200 - {}
2025-04-18 19:32:50.043 | 2025-04-19 02:32:50.043 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:55414 - "GET /ollama/api/version HTTP/1.1" 200 - {}
2025-04-18 19:32:50.466 | 2025-04-19 02:32:50.466 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 172.17.0.1:55414 - "GET /api/version/updates HTTP/1.1" 200 - {}
Additional Information
I was trying to determine when exactly init is triggered for Valves and UserValves while learning Pipe functions.
At first my testing seemed to indicate what I expected of an init but when loading certain pages or reloading the page in chrome. And in some circumstances, sending a new message in a chat, init would trigger.