open-webui/backend/open_webui
Classic298 006a63e641
perf: use the orjson codec for the Anthropic passthrough request body (#27810)
`passthrough_anthropic_messages` in `main.py` serializes the full request payload with stdlib `json` before sending it upstream. It is the largest single serialization on that path, since the body carries the whole conversation.

It now goes through `JSONCodec`, which selects orjson when `ENABLE_ORJSON` is set. The result is passed to aiohttp as `data=`, which encodes `str` as UTF-8 and sets `Content-Length` from the encoded bytes. The payload originates from a parsed request dict, so it holds only JSON-native types, and the serialized string is never hashed, compared or persisted.

The remaining stdlib `json` calls in this module are left alone: two are a debug log line and a fixed Ollama unload payload, and one parses an upstream error body.

With `ENABLE_ORJSON` unset, which is the default, `JSONCodec` is stdlib `json` and this call site behaves exactly as before.
2026-07-31 17:26:07 -04:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal perf: cut per-request database session overhead (#27385) 2026-07-23 17:49:48 -05:00
migrations chore: format 2026-07-27 04:46:45 -04:00
models chore: remove dead json imports (#27815) 2026-07-31 17:25:40 -04:00
retrieval chore: remove dead json imports (#27815) 2026-07-31 17:25:40 -04:00
routers perf: read the model pool with one HGETALL instead of one HGET per model (#27821) 2026-07-31 17:25:53 -04:00
socket perf: optional orjson JSON codec behind ENABLE_ORJSON (#27583) 2026-07-27 03:45:37 -04:00
static refac 2026-07-27 19:39:36 -04:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools chore: remove dead json imports (#27815) 2026-07-31 17:25:40 -04:00
utils perf: read the model pool with one HGETALL instead of one HGET per model (#27821) 2026-07-31 17:25:53 -04:00
__init__.py refac 2026-07-27 19:39:36 -04:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-07-27 19:39:36 -04:00
constants.py refac 2026-07-27 19:39:36 -04:00
env.py refac 2026-07-27 19:39:36 -04:00
events.py refac 2026-07-27 19:39:36 -04:00
functions.py refac 2026-07-23 03:39:56 -04:00
main.py perf: use the orjson codec for the Anthropic passthrough request body (#27810) 2026-07-31 17:26:07 -04:00
tasks.py refac 2026-07-26 22:45:11 -04:00