diff --git a/lib/response.js b/lib/response.js index caf226d..43e98bb 100644 --- a/lib/response.js +++ b/lib/response.js @@ -5,6 +5,7 @@ export function createAckEvent() { const data = { choices: [ { + index: 0, delta: { content: ``, role: "assistant" }, }, ], @@ -17,6 +18,7 @@ export function createTextEvent(message) { const data = { choices: [ { + index: 0, delta: { content: message, role: "assistant" }, }, ], @@ -55,6 +57,7 @@ export function createDoneEvent() { const data = { choices: [ { + index: 0, finish_reason: "stop", delta: { content: null }, }, diff --git a/test/response.test.js.snapshot b/test/response.test.js.snapshot index ef81396..d87b943 100644 --- a/test/response.test.js.snapshot +++ b/test/response.test.js.snapshot @@ -1,5 +1,5 @@ exports[`response > createAckEvent() 1`] = ` -"data: {\\"choices\\":[{\\"delta\\":{\\"content\\":\\"\\",\\"role\\":\\"assistant\\"}}]}\\n\\n" +"data: {\\"choices\\":[{\\"index\\":0,\\"delta\\":{\\"content\\":\\"\\",\\"role\\":\\"assistant\\"}}]}\\n\\n" `; exports[`response > createConfirmationEvent() 1`] = ` @@ -7,7 +7,7 @@ exports[`response > createConfirmationEvent() 1`] = ` `; exports[`response > createDoneEvent() 1`] = ` -"data: {\\"choices\\":[{\\"finish_reason\\":\\"stop\\",\\"delta\\":{\\"content\\":null}}]}\\n\\ndata: [DONE]\\n\\n" +"data: {\\"choices\\":[{\\"index\\":0,\\"finish_reason\\":\\"stop\\",\\"delta\\":{\\"content\\":null}}]}\\n\\ndata: [DONE]\\n\\n" `; exports[`response > createErrorsEvent() 1`] = ` @@ -19,5 +19,5 @@ exports[`response > createReferencesEvent() 1`] = ` `; exports[`response > createTextEvent() 1`] = ` -"data: {\\"choices\\":[{\\"delta\\":{\\"content\\":\\"test\\",\\"role\\":\\"assistant\\"}}]}\\n\\n" +"data: {\\"choices\\":[{\\"index\\":0,\\"delta\\":{\\"content\\":\\"test\\",\\"role\\":\\"assistant\\"}}]}\\n\\n" `;