Skip to content

Commit fc97a30

Browse files
authoredSep 10, 2024
fix: set index: 0 in choices as it is now required in copilot API (copilot-extensions#76)
1 parent c593ba6 commit fc97a30

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
 

‎lib/response.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function createAckEvent() {
55
const data = {
66
choices: [
77
{
8+
index: 0,
89
delta: { content: ``, role: "assistant" },
910
},
1011
],
@@ -17,6 +18,7 @@ export function createTextEvent(message) {
1718
const data = {
1819
choices: [
1920
{
21+
index: 0,
2022
delta: { content: message, role: "assistant" },
2123
},
2224
],
@@ -55,6 +57,7 @@ export function createDoneEvent() {
5557
const data = {
5658
choices: [
5759
{
60+
index: 0,
5861
finish_reason: "stop",
5962
delta: { content: null },
6063
},

‎test/response.test.js.snapshot

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
exports[`response > createAckEvent() 1`] = `
2-
"data: {\\"choices\\":[{\\"delta\\":{\\"content\\":\\"\\",\\"role\\":\\"assistant\\"}}]}\\n\\n"
2+
"data: {\\"choices\\":[{\\"index\\":0,\\"delta\\":{\\"content\\":\\"\\",\\"role\\":\\"assistant\\"}}]}\\n\\n"
33
`;
44

55
exports[`response > createConfirmationEvent() 1`] = `
66
"event: copilot_confirmation\\ndata: {\\"type\\":\\"action\\",\\"title\\":\\"title\\",\\"message\\":\\"message\\",\\"confirmation\\":{\\"id\\":\\"123\\",\\"foo\\":\\"bar\\"}}\\n\\n"
77
`;
88

99
exports[`response > createDoneEvent() 1`] = `
10-
"data: {\\"choices\\":[{\\"finish_reason\\":\\"stop\\",\\"delta\\":{\\"content\\":null}}]}\\n\\ndata: [DONE]\\n\\n"
10+
"data: {\\"choices\\":[{\\"index\\":0,\\"finish_reason\\":\\"stop\\",\\"delta\\":{\\"content\\":null}}]}\\n\\ndata: [DONE]\\n\\n"
1111
`;
1212

1313
exports[`response > createErrorsEvent() 1`] = `
@@ -19,5 +19,5 @@ exports[`response > createReferencesEvent() 1`] = `
1919
`;
2020

2121
exports[`response > createTextEvent() 1`] = `
22-
"data: {\\"choices\\":[{\\"delta\\":{\\"content\\":\\"test\\",\\"role\\":\\"assistant\\"}}]}\\n\\n"
22+
"data: {\\"choices\\":[{\\"index\\":0,\\"delta\\":{\\"content\\":\\"test\\",\\"role\\":\\"assistant\\"}}]}\\n\\n"
2323
`;

0 commit comments

Comments
 (0)
Failed to load comments.