Skip to content

Commit 09af8bd

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

4 files changed

Lines changed: 508 additions & 29 deletions

File tree

backend/open_webui/utils/middleware.py

Lines changed: 0 additions & 1 deletion
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)

src/lib/components/chat/Chat.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,12 @@
18051805
message.output = output;
18061806
}
18071807
1808+
// When the response is done and content is provided, set it for copy/TTS
1809+
// (the frontend renders from output during streaming, content is the final cache)
1810+
if (done && content) {
1811+
message.content = content;
1812+
}
1813+
18081814
if (error) {
18091815
await handleOpenAIError(error, message);
18101816
}
@@ -1813,7 +1819,9 @@
18131819
message.sources = sources;
18141820
}
18151821
1816-
if (choices) {
1822+
// Only accumulate content from choices when there's no structured output
1823+
// (output-based rendering takes priority — avoids redundant serialize/parse round-trip)
1824+
if (choices && !output) {
18171825
if (choices[0]?.message?.content) {
18181826
// Non-stream response
18191827
message.content += choices[0]?.message?.content;

0 commit comments

Comments
 (0)