mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-17 23:52:29 +00:00
refac: correct the ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND comments (#30066)
The comments on the opt-in in-place append made it sound like the fast path can lose streamed text under normal operation. The only way the field can be emptied is an allocation failure, which means the host is already out of memory, and the default path (which copies the whole accumulated string on every chunk) raises in that situation as well. Reword both comments to state that condition so the flag is not read as unsafe.
This commit is contained in:
parent
3394a10b76
commit
4611394fa6
2 changed files with 3 additions and 2 deletions
|
|
@ -1043,7 +1043,8 @@ ENABLE_CHAT_RESPONSE_BASE64_IMAGE_URL_CONVERSION = (
|
|||
ENABLE_API_OUTLET_FILTERS = os.getenv('ENABLE_API_OUTLET_FILTERS', 'True').lower() == 'true'
|
||||
|
||||
# Opt in to CPython's in-place string append optimization for streamed responses.
|
||||
# Disabled by default: allocation failure in the fast path can erase accumulated text.
|
||||
# Off by default for a staged rollout. Only a host already out of memory can lose
|
||||
# text here; the default path (a full copy per chunk) raises there too.
|
||||
ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND = os.getenv('ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND', 'False').lower() == 'true'
|
||||
|
||||
# When enabled, uses a hardcoded extension-to-MIME dictionary as a last-resort
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ def append_to_text_field(item: dict, key: str, value: str) -> None:
|
|||
return
|
||||
|
||||
# Opt-in: dropping the dict's reference lets CPython extend an unshared str
|
||||
# in place. An allocation failure can leave the field empty.
|
||||
# in place. Only a host that is already out of memory can leave the field empty.
|
||||
text = item[key]
|
||||
item[key] = ''
|
||||
text += value
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue