58 Commits

Author SHA1 Message Date
Classic298
dc4924b66e Enforce per-model access on arena fallback before bypass_filter dispatch (#26046)
generate_chat_completion() checks model access on line 200 only when bypass_filter is
False. When an arena model reaches this function without a pre-resolved selected_model_id,
which is the task and background path (the /api/v1/tasks/* endpoints call
generate_chat_completion directly rather than through process_chat_payload), the fallback
resolves the arena to an underlying model and recurses with bypass_filter=True, so the
resolved model's access check is skipped. An authenticated user with access to an arena
could therefore reach a model they are denied directly, and for the default or exclude
arena, whose candidate pool is every non-arena model, any model on the instance (CWE-862).
The normal chat path resolves the arena in process_chat_payload before this function, so its
resolved model is checked on line 200; the task path was not, which is the inconsistency.

Enforce check_model_access() on the resolved model in the fallback, before the
bypass_filter=True recursion, mirroring the normal-path check. Admins and already-bypassed
recursive calls are unaffected, and legitimate arena use of accessible models is unchanged.

Co-authored-by: rexpository <30176934+rexpository@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 22:45:42 +02:00
Classic298
4719881105 fix: move bypass_system_prompt off query parameter onto request.state (#25156)
bypass_system_prompt is an internal flag used by utils/middleware.py and utils/chat.py to skip applying the model system prompt on recursive base-model calls, but it was still declared as a positional argument on the openai/ollama chat-completion route handlers, so FastAPI bound it from the query string. Move it to request.state so external clients cannot set it, matching how bypass_filter is handled.

Drop the argument from both route signatures and read getattr(request.state, 'bypass_system_prompt', False); utils/chat.py sets request.state.bypass_system_prompt alongside bypass_filter and drops the kwarg from the two route-handler calls (the recursive self-calls keep it). Mirrors c0385f60b.

Co-authored-by: anishgirianish <161533316+anishgirianish@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 14:53:53 -07:00
Timothy Jaeryang Baek
6d0295588e refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
Timothy Jaeryang Baek
005df577fe refac 2026-05-09 04:36:43 +09:00
Timothy Jaeryang Baek
d5e69f182c refac 2026-04-20 08:53:06 +09:00
Timothy Jaeryang Baek
27169124f2 refac: async db 2026-04-12 14:22:11 -05:00
Shirasawa
d7a5a903a6 fix: guard completed API with message id (#23184) 2026-04-01 05:39:34 -05:00
Timothy Jaeryang Baek
857d7e6f37 refac 2026-03-25 02:49:34 -05:00
Timothy Jaeryang Baek
ade617efa8 refac 2026-03-24 04:49:48 -05:00
Timothy Jaeryang Baek
de3317e26b refac 2026-03-17 17:58:01 -05:00
Timothy Jaeryang Baek
c0385f60ba refac 2026-03-17 16:52:14 -05:00
Timothy Jaeryang Baek
15b893e651 refac 2026-02-16 15:32:28 -06:00
Timothy Jaeryang Baek
2a11175f22 chore: format 2026-02-12 16:13:48 -06:00
Timothy Jaeryang Baek
60ada21c15 refac 2026-02-11 16:40:40 -06:00
Classic298
ab20745ee5 Enable Rich UI embed support for action functions (#21294)
Action functions can now return HTMLResponse objects or (html, headers)
tuples with Content-Disposition: inline to render rich UI iframes in
chat, matching the existing tool behavior.

https://claude.ai/code/session_01KCZKQXj1uqgPjqjMd4U2NF

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-11 16:27:00 -06:00
Timothy Jaeryang Baek
f376d4f378 chore: format 2026-02-11 16:24:11 -06:00
Classic298
aac98120c8 perf: batch fetch filter functions to eliminate N+1 queries (#21018) 2026-01-30 00:50:04 +04:00
Timothy Jaeryang Baek
b377e5ff4c chore: format 2026-01-09 02:46:04 +04:00
Timothy Jaeryang Baek
9223efaff0 fix: native function calling system prompt duplication 2026-01-08 23:08:47 +04:00
Classic298
b91e8b73ab fix: properly raise exceptions instead of returning them in chat.py (#20276)
Change 'return Exception(...)' to 'raise Exception(...)' in chat_completed() and chat_action() functions. Returning an exception object instead of raising it causes errors to be silently swallowed, breaking error propagation.
2025-12-31 17:38:47 +04:00
Classic298
823b9a6dd9 chore/perf: Remove old SRC level log env vars with no impact (#20045)
* Update openai.py

* Update env.py

* Merge pull request open-webui#19030 from open-webui/dev (#119)

Co-authored-by: Tim Baek <tim@openwebui.com>
Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: Tim Baek <tim@openwebui.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-20 08:16:14 -05:00
Timothy Jaeryang Baek
6c4deed37a refac/fix: direct connection floating action buttons 2025-10-02 02:21:21 -05:00
Timothy Jaeryang Baek
0134b5eca4 fix: action reserved user param 2025-06-18 10:50:49 +04:00
Timothy Jaeryang Baek
bbafeca495 refac: reserved __user__ param format 2025-06-04 15:53:07 +04:00
Gunwoo Hur
14c3d0c2d1 Prevent duplicate function module loads with caching helper and refactor 2025-05-27 18:08:58 +09:00
Timothy Jaeryang Baek
74ace200fe fix/refac: functions multi-replica issue 2025-05-20 20:20:27 +04:00
Timothy Jaeryang Baek
359bcb837d refac 2025-05-17 00:08:03 +04:00
Timothy Jaeryang Baek
1f38350128 feat: toggle filter middleware 2025-05-16 23:33:02 +04:00
Timothy Jaeryang Baek
3b74431ea3 refac: filters 2025-03-04 18:04:55 -08:00
MeteorSky
a01ef6cfa0 fix: allow error returns None 2025-03-04 00:08:49 +08:00
Timothy Jaeryang Baek
3be5e3129b Merge pull request #10752 from NovoNordisk-OpenSource/yvedeng/standardize-logging
refactor: replace print statements with logging
2025-02-25 10:53:02 -08:00
Yifang Deng
0e5d5ecb81 refactor: replace print statements with logging for better error tracking 2025-02-25 15:53:55 +01:00
Timothy Jaeryang Baek
d8bc3098db Merge pull request #9918 from df-cgdm/main
feat: Add  X-OpenWebUI when forwarding to ollama servers
2025-02-24 11:55:04 -08:00
Timothy Jaeryang Baek
a5fa1cd835 Merge pull request #10209 from i-infra/iinf/fix-for-openrouter
[fix] no unambiguous indexing on "owned_by" - fix OpenRouter.ai
2025-02-17 15:24:21 -08:00
Timothy Jaeryang Baek
19c340d3fb refac: pipelines 2025-02-15 22:25:18 -08:00
i-infra
fb12ee3f52 fix exception where openrouter doesn't populate - no longer index without fallback 2025-02-15 19:41:41 -05:00
Timothy Jaeryang Baek
da757069de refac 2025-02-13 17:06:55 -08:00
Timothy Jaeryang Baek
e1435501aa fix 2025-02-13 15:17:41 -08:00
Timothy Jaeryang Baek
f20b7c2f33 fix: user direct connections 2025-02-13 14:21:34 -08:00
Didier FOURNOUT
6d62e71c34 Add x-Open-Webui headers for ollama + more for openai 2025-02-13 15:29:26 +00:00
Timothy Jaeryang Baek
6d899b80d0 refac: direct connections 2025-02-13 00:34:45 -08:00
Timothy Jaeryang Baek
a1dc2664c2 refac 2025-02-12 23:49:00 -08:00
Timothy Jaeryang Baek
83e5db7be7 refac 2025-02-12 23:26:47 -08:00
Timothy Jaeryang Baek
2b7f9d14d0 refac 2025-02-12 23:21:16 -08:00
Timothy Jaeryang Baek
c83e68282d feat: direct connections integration 2025-02-12 22:56:33 -08:00
Timothy Jaeryang Baek
9be8bea6f4 fix: filter 2025-02-08 01:07:05 -08:00
Timothy Jaeryang Baek
3dde2f67cf refac 2025-02-07 22:57:39 -08:00
Xingjian Xie
89669a21fc Refactor common code between inlet and outlet 2025-02-06 23:07:47 +00:00
Timothy Jaeryang Baek
f3a4d61f81 fix: actions 2025-01-03 21:31:24 -08:00
Timothy Jaeryang Baek
54daf3b765 fix: outlet filter hook 2024-12-28 18:05:07 -08:00