Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function createAckEvent() {
const data = {
choices: [
{
index: 0,
delta: { content: ``, role: "assistant" },
},
],
Expand All @@ -17,6 +18,7 @@ export function createTextEvent(message) {
const data = {
choices: [
{
index: 0,
delta: { content: message, role: "assistant" },
},
],
Expand Down Expand Up @@ -55,6 +57,7 @@ export function createDoneEvent() {
const data = {
choices: [
{
index: 0,
finish_reason: "stop",
delta: { content: null },
},
Expand Down
6 changes: 3 additions & 3 deletions test/response.test.js.snapshot
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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`] = `
"event: copilot_confirmation\\ndata: {\\"type\\":\\"action\\",\\"title\\":\\"title\\",\\"message\\":\\"message\\",\\"confirmation\\":{\\"id\\":\\"123\\",\\"foo\\":\\"bar\\"}}\\n\\n"
`;

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`] = `
Expand All @@ -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"
`;