opencode-codebuddy-external-auth 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.js +27 -10
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -53,14 +53,31 @@ function convertMessagesToPrompt(messages) {
|
|
|
53
53
|
*/
|
|
54
54
|
function createOpenAIStreamResponse(text, model) {
|
|
55
55
|
const encoder = new TextEncoder();
|
|
56
|
+
const id = `chatcmpl-${Date.now()}`;
|
|
57
|
+
const created = Math.floor(Date.now() / 1000);
|
|
56
58
|
return new ReadableStream({
|
|
57
59
|
start(controller) {
|
|
58
|
-
//
|
|
59
|
-
const
|
|
60
|
-
id
|
|
60
|
+
// First chunk with role
|
|
61
|
+
const roleChunk = {
|
|
62
|
+
id,
|
|
61
63
|
object: "chat.completion.chunk",
|
|
62
|
-
created
|
|
63
|
-
model
|
|
64
|
+
created,
|
|
65
|
+
model,
|
|
66
|
+
choices: [
|
|
67
|
+
{
|
|
68
|
+
index: 0,
|
|
69
|
+
delta: { role: "assistant" },
|
|
70
|
+
finish_reason: null,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(roleChunk)}\n\n`));
|
|
75
|
+
// Content chunk
|
|
76
|
+
const contentChunk = {
|
|
77
|
+
id,
|
|
78
|
+
object: "chat.completion.chunk",
|
|
79
|
+
created,
|
|
80
|
+
model,
|
|
64
81
|
choices: [
|
|
65
82
|
{
|
|
66
83
|
index: 0,
|
|
@@ -69,13 +86,13 @@ function createOpenAIStreamResponse(text, model) {
|
|
|
69
86
|
},
|
|
70
87
|
],
|
|
71
88
|
};
|
|
72
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify(
|
|
73
|
-
//
|
|
89
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(contentChunk)}\n\n`));
|
|
90
|
+
// Done chunk
|
|
74
91
|
const doneChunk = {
|
|
75
|
-
id
|
|
92
|
+
id,
|
|
76
93
|
object: "chat.completion.chunk",
|
|
77
|
-
created
|
|
78
|
-
model
|
|
94
|
+
created,
|
|
95
|
+
model,
|
|
79
96
|
choices: [
|
|
80
97
|
{
|
|
81
98
|
index: 0,
|