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:
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user