Skip to content

Commit 9b31a19

Browse files
committed
refactor: render from output and derive content at save
1 parent 5822c6d commit 9b31a19

4 files changed

Lines changed: 506 additions & 32 deletions

File tree

backend/open_webui/utils/middleware.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4069,7 +4069,6 @@ async def flush_pending_delta_data(threshold: int = 0):
40694069

40704070
processed_data = {
40714071
'output': full_output(),
4072-
'content': serialize_output(full_output()),
40734072
}
40744073

40754074
# print(data)
@@ -4235,7 +4234,7 @@ async def flush_pending_delta_data(threshold: int = 0):
42354234
{
42364235
'type': 'chat:completion',
42374236
'data': {
4238-
'content': serialize_output(full_output() + pending_fc_items),
4237+
'output': full_output() + pending_fc_items,
42394238
},
42404239
}
42414240
)
@@ -4313,7 +4312,7 @@ async def flush_pending_delta_data(threshold: int = 0):
43134312
_pending_reasoning_details.extend(items)
43144313

43154314
if reasoning_content or reasoning_details_chunk:
4316-
data = {'content': serialize_output(full_output())}
4315+
data = {'output': full_output()}
43174316

43184317
if value:
43194318
if (
@@ -4470,7 +4469,7 @@ async def flush_pending_delta_data(threshold: int = 0):
44704469
)
44714470
else:
44724471
data = {
4473-
'content': serialize_output(full_output()),
4472+
'output': full_output(),
44744473
}
44754474

44764475
if delta:

src/lib/components/chat/Chat.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,9 @@
18131813
message.sources = sources;
18141814
}
18151815
1816-
if (choices) {
1816+
// Only accumulate content from choices when there's no structured output
1817+
// (output-based rendering takes priority — avoids redundant serialize/parse round-trip)
1818+
if (choices && !output) {
18171819
if (choices[0]?.message?.content) {
18181820
// Non-stream response
18191821
message.content += choices[0]?.message?.content;

0 commit comments

Comments
 (0)