Merge pull request #48 from auriti/fix/empty-string-content-delta

fix: handle empty string delta.content in OpenAI streaming
This commit is contained in:
Kevin Codex
2026-04-02 02:31:11 +08:00
committed by GitHub

View File

@@ -373,8 +373,9 @@ async function* openaiStreamToAnthropic(
for (const choice of chunk.choices ?? []) { for (const choice of chunk.choices ?? []) {
const delta = choice.delta const delta = choice.delta
// Text content // Text content — use != null to distinguish absent field from empty string,
if (delta.content) { // some providers send "" as first delta to signal streaming start
if (delta.content != null) {
if (!hasEmittedContentStart) { if (!hasEmittedContentStart) {
yield { yield {
type: 'content_block_start', type: 'content_block_start',