refac
This commit is contained in:
1 parent
3258330729
commit
f7a533cda6
2 files changed
+20
-16
No files matched your search
@@ -121,13 +121,17 @@
|
||||
export let messageId;
|
||||
export let selectedModels = [];
|
||||
|
||||
let message: MessageType = structuredClone(history.messages[messageId]);
|
||||
let messageSource = history.messages[messageId];
|
||||
let message: MessageType = structuredClone(messageSource);
|
||||
$: if (history.messages) {
|
||||
const source = history.messages[messageId];
|
||||
if (source) {
|
||||
// Fast path: O(1) check on the fields that change most often (content during streaming, done at end)
|
||||
// Avoids 2x O(n) JSON.stringify calls that are always true during streaming anyway
|
||||
if (
|
||||
// Fast path for the fields that change most often while streaming.
|
||||
// Responses streams update output even when legacy content is unchanged.
|
||||
if (source !== messageSource) {
|
||||
messageSource = source;
|
||||
message = structuredClone(source);
|
||||
} else if (
|
||||
message.content !== source.content ||
|
||||
message.done !== source.done ||
|
||||
message.output?.length !== source.output?.length
|
||||
|
||||
Reference in new issue
Block a user