Commit Graph

1476 Commits

Author SHA1 Message Date
Timothy Jaeryang Baek a9617ca218 refac 2026-07-14 01:15:29 -04:00
Timothy Jaeryang Baek f1ded9409a refac 2026-07-14 01:13:40 -04:00
Timothy Jaeryang Baek 4ed19d504b refac 2026-07-14 00:42:57 -04:00
Timothy Jaeryang Baek caa2457c17 refac 2026-07-14 00:42:47 -04:00
Timothy Jaeryang Baek f730733bc4 refac 2026-07-14 00:30:47 -04:00
Timothy Jaeryang Baek 797293c749 refac 2026-07-14 00:19:41 -04:00
Timothy Jaeryang Baek 7088d245bb refac 2026-07-14 00:10:28 -04:00
Timothy Jaeryang Baek 0c23466a3e refac 2026-07-13 23:46:28 -04:00
Timothy Jaeryang Baek 17e6496538 refac 2026-07-13 23:28:43 -04:00
Timothy Jaeryang Baek 959558fd82 refac 2026-07-13 23:27:54 -04:00
Timothy Jaeryang Baek e8b59b2ef3 refac 2026-07-13 22:50:24 -04:00
Timothy Jaeryang Baek 09d4cccb79 refac 2026-07-10 18:32:21 -05:00
Timothy Jaeryang Baek 9a772f42c8 refac 2026-07-10 16:41:35 -05:00
Classic298 0f8846b7fc fix: convert SecurityHeadersMiddleware to pure ASGI (#26924)
SecurityHeadersMiddleware was the last middleware in the stack still
subclassing BaseHTTPMiddleware, after CommitSession, AuthToken,
WebsocketUpgradeGuard and Redirect were all moved to pure ASGI in
utils/asgi_middleware.py. BaseHTTPMiddleware re-buffers the response
body through an anyio task group, which has known issues with
streaming and Content-Length-bearing responses (e.g. the FileResponse
returned by /api/v1/audio/speech).

Reimplement it as a pure-ASGI middleware that stamps the configured
security headers onto the http.response.start message via
MutableHeaders and forwards all body chunks untouched, matching the
pattern already used by its four siblings. set_security_headers() and
all its helpers are unchanged.

Co-authored-by: classic298 <classic298@users.noreply.github.com>
2026-07-10 13:29:14 -05:00
Timothy Jaeryang Baek d3ea8eb7e7 refac 2026-07-09 17:38:19 -05:00
Timothy Jaeryang Baek 9951fbe549 refac 2026-07-09 17:37:04 -05:00
Timothy Jaeryang Baek 5c389ad93f refac 2026-07-09 17:33:30 -05:00
Timothy Jaeryang Baek 8e46450acd refac 2026-07-09 17:28:34 -05:00
Timothy Jaeryang Baek 44c2a27ce0 refac 2026-07-09 16:20:19 -05:00
Timothy Jaeryang Baek 90eca2ac25 refac 2026-07-01 03:37:35 -05:00
Timothy Jaeryang Baek 80af65c24a refac 2026-07-01 03:35:46 -05:00
Timothy Jaeryang Baek fa2abe4cb6 refac 2026-07-01 03:17:06 -05:00
Timothy Jaeryang Baek 9562f036f8 refac 2026-07-01 02:57:29 -05:00
Timothy Jaeryang Baek 0016266c06 refac 2026-07-01 02:49:33 -05:00
Timothy Jaeryang Baek 650b817925 refac 2026-07-01 02:49:28 -05:00
Timothy Jaeryang Baek 64b92ff08a refac 2026-07-01 02:48:29 -05:00
Timothy Jaeryang Baek 0b75445ff9 refac 2026-06-30 20:20:10 -05:00
Timothy Jaeryang Baek 4067e357b2 refac 2026-06-29 21:31:49 -05:00
Timothy Jaeryang Baek 0443ab3a61 refac 2026-06-29 13:30:28 -05:00
Timothy Jaeryang Baek 37d45fdee3 refac 2026-06-29 13:14:13 -05:00
Timothy Jaeryang Baek 517cd8d102 refac 2026-06-29 13:03:14 -05:00
Shirasawa 91aea7fe8c fix: Fixed the error message display for non-standard SSE (#23228) 2026-06-29 12:31:41 -05:00
Timothy Jaeryang Baek b4073f6378 refac 2026-06-29 12:29:10 -05:00
Timothy Jaeryang Baek 75db531c12 refac 2026-06-29 12:16:58 -05:00
Timothy Jaeryang Baek d6cda4a04b refac 2026-06-29 12:12:12 -05:00
Timothy Jaeryang Baek fe3300bd65 refac 2026-06-29 12:10:39 -05:00
Timothy Jaeryang Baek 783205a965 refac 2026-06-29 12:09:16 -05:00
Timothy Jaeryang Baek ff5cec43bd refac 2026-06-29 11:56:00 -05:00
Timothy Jaeryang Baek 10558173fb refac 2026-06-29 11:53:29 -05:00
Timothy Jaeryang Baek 2c4e1fce8f refac 2026-06-29 11:13:36 -05:00
Juan Calderon-Perez 51246bcb31 perf(backend): offload blocking calls in async paths to threads (#26381)
Audit of asyncio.sleep vs time.sleep and event-loop-blocking calls:

- utils/plugin.py: run pip `install_frontmatter_requirements`
  (subprocess.check_call) via asyncio.to_thread in load_tool_module_by_id,
  load_function_module_by_id, and install_tool_and_function_dependencies.
- retrieval/utils.py: move the synchronous SSRF-guarded requests probe and
  loader.load() in get_content_from_url into a sync helper run via
  asyncio.to_thread.
- routers/audio.py: write uploaded audio to disk off the event loop in
  transcription().
- routers/pipelines.py: write uploaded pipeline file off the event loop in
  upload_pipeline().

The existing time.sleep call sites are all in genuinely synchronous
functions (sync requests/DB drivers/daemon threads) with async
counterparts that already use asyncio.sleep, so no time.sleep -> asyncio.sleep
changes were needed.


Claude-Session: https://claude.ai/code/session_01LXR5bYfsfSS42RGHQZu2Ta

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-29 10:42:26 -05:00
Timothy Jaeryang Baek eb53281c9a refac
Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
2026-06-29 06:08:31 -05:00
Timothy Jaeryang Baek a285a390c1 refac 2026-06-29 06:01:05 -05:00
Classic298 75df948f34 feat: forward client User-Agent to model backends via {{USER_AGENT}} placeholder (#26333)
Adds a {{USER_AGENT}} custom-header placeholder that relays the inbound
client's User-Agent to upstream model backends, so providers see the real
client instead of Open WebUI's internal aiohttp UA. This makes upstream
usage/cost attribution and backend telemetry possible, and is opt-in
per-connection (no global flag): admins add {{USER_AGENT}} to a connection's
custom headers in Admin > Settings > Connections.

The placeholder is sourced from the live inbound request (with a metadata
fallback for detached RAG/tool calls), so it resolves on every prompt-sending
path, not just chat completions:

- OpenAI completions, Responses API, and proxy — all route through
  get_headers_and_cookies, which now passes the request into get_custom_headers.
- Anthropic Messages API (/api/v1/messages) — already covered, it delegates
  to the chat completion handler.
- Ollama (/api/chat, /v1/completions, /v1/chat/completions, /v1/messages,
  /v1/responses) — previously had no custom-header support at all; send_request
  now applies per-connection custom headers (with templating) for every
  Ollama prompt endpoint.

Custom headers are applied after the built-in user-info headers so explicit
admin-configured headers take precedence. The other existing placeholders
({{CHAT_ID}}, {{USER_ID}}, ...) now also work on the newly covered paths.

Frontend: the connection editor's Headers field is now shown for Ollama
connections too (previously gated to non-Ollama), so the placeholder can be
configured there.

Ref: open-webui/open-webui#26159
2026-06-29 05:58:19 -05:00
Timothy Jaeryang Baek 260f3c3a22 refac 2026-06-29 05:56:08 -05:00
Timothy Jaeryang Baek ee5de69e37 refac 2026-06-29 05:46:55 -05:00
Timothy Jaeryang Baek 44b9463498 refac 2026-06-29 05:44:47 -05:00
Timothy Jaeryang Baek 396d9ac181 refac 2026-06-29 05:27:51 -05:00
Timothy Jaeryang Baek 83ec36cd38 refac 2026-06-29 05:15:55 -05:00
Timothy Jaeryang Baek cdd7b88bec refac 2026-06-29 05:14:57 -05:00