Skip to content

Commit 16e75ce

Browse files
committed
do not invoke transformFinishReason multiple times for stream transforms
1 parent 27065ef commit 16e75ce

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/providers/anthropic/chatComplete.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,6 @@ export const AnthropicChatCompleteStreamChunkTransform: (
768768
};
769769
delete contentBlockObject.delta.type;
770770

771-
const finishReason = parsedChunk.delta?.stop_reason
772-
? transformFinishReason(
773-
parsedChunk.delta?.stop_reason,
774-
strictOpenAiCompliance
775-
)
776-
: null;
777-
778771
return (
779772
`data: ${JSON.stringify({
780773
id: fallbackId,
@@ -794,7 +787,7 @@ export const AnthropicChatCompleteStreamChunkTransform: (
794787
},
795788
index: 0,
796789
logprobs: null,
797-
finish_reason: finishReason,
790+
finish_reason: null,
798791
},
799792
],
800793
})}` + '\n\n'

src/providers/bedrock/chatComplete.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ export const BedrockChatCompleteStreamChunkTransform: (
748748
content_blocks: [contentBlockObject],
749749
}),
750750
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
751+
finish_reason: null,
751752
},
752753
},
753754
],

0 commit comments

Comments
 (0)