mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-24 23:39:52 -05:00
refac
This commit is contained in:
@@ -499,7 +499,7 @@ function findOutputItemIndex(output: OutputItem[], item: OutputItem): number {
|
||||
return output.findIndex(
|
||||
(existing) =>
|
||||
(!!item.id && existing?.id === item.id) ||
|
||||
(!!item.call_id && existing?.call_id === item.call_id)
|
||||
(!!item.call_id && existing?.type === item.type && existing?.call_id === item.call_id)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -522,7 +522,19 @@ export function applyResponseStreamEvent(
|
||||
}
|
||||
|
||||
if (eventType === 'response.completed') {
|
||||
return event.response?.output ? [...event.response.output] : output;
|
||||
if (!event.response?.output?.length) return output;
|
||||
|
||||
// Completion covers one provider response, not the earlier tool-call rounds.
|
||||
const nextOutput = [...output];
|
||||
for (const item of event.response.output) {
|
||||
const index = findOutputItemIndex(nextOutput, item);
|
||||
if (index >= 0) {
|
||||
nextOutput[index] = item;
|
||||
} else {
|
||||
nextOutput.push(item);
|
||||
}
|
||||
}
|
||||
return nextOutput;
|
||||
}
|
||||
|
||||
const nextOutput = [...output];
|
||||
|
||||
Reference in New Issue
Block a user