feat: enhance filterVisibleParts to conditionally handle synthetic parts based on non-synthetic presence
This commit is contained in:
@@ -28,10 +28,18 @@ interface VisibleFilterOptions {
|
|||||||
export const filterVisibleParts = (parts: Part[], options: VisibleFilterOptions = {}): Part[] => {
|
export const filterVisibleParts = (parts: Part[], options: VisibleFilterOptions = {}): Part[] => {
|
||||||
const { includeReasoning = true } = options;
|
const { includeReasoning = true } = options;
|
||||||
|
|
||||||
|
// Check if there are any non-synthetic parts
|
||||||
|
const hasNonSynthetic = parts.some((part) => {
|
||||||
|
const partWithSynthetic = part as PartWithSynthetic;
|
||||||
|
return !partWithSynthetic.synthetic;
|
||||||
|
});
|
||||||
|
|
||||||
return parts.filter((part) => {
|
return parts.filter((part) => {
|
||||||
const partWithSynthetic = part as PartWithSynthetic;
|
const partWithSynthetic = part as PartWithSynthetic;
|
||||||
const isSynthetic = Boolean(partWithSynthetic.synthetic);
|
const isSynthetic = Boolean(partWithSynthetic.synthetic);
|
||||||
if (isSynthetic) {
|
// Only filter out synthetic parts if there are non-synthetic parts present
|
||||||
|
// Otherwise, show synthetic parts so the message is displayed
|
||||||
|
if (isSynthetic && hasNonSynthetic) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!includeReasoning && part.type === 'reasoning') {
|
if (!includeReasoning && part.type === 'reasoning') {
|
||||||
|
|||||||
Reference in New Issue
Block a user