@mariozechner/pi-ai 0.5.14 → 0.5.15
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/models.generated.js +2 -2
- package/dist/models.generated.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +89 -58
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +94 -90
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/openai-completions.d.ts.map +1 -1
- package/dist/providers/openai-completions.js +154 -73
- package/dist/providers/openai-completions.js.map +1 -1
- package/dist/providers/openai-responses.d.ts.map +1 -1
- package/dist/providers/openai-responses.js +111 -56
- package/dist/providers/openai-responses.js.map +1 -1
- package/dist/types.d.ts +44 -38
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/providers/google.js
CHANGED
|
@@ -55,10 +55,8 @@ export class GoogleLLM {
|
|
|
55
55
|
config,
|
|
56
56
|
};
|
|
57
57
|
const stream = await this.client.models.generateContentStream(params);
|
|
58
|
-
|
|
59
|
-
let
|
|
60
|
-
let thoughtSignature;
|
|
61
|
-
const toolCalls = [];
|
|
58
|
+
const blocks = [];
|
|
59
|
+
let currentBlock = null;
|
|
62
60
|
let usage = {
|
|
63
61
|
input: 0,
|
|
64
62
|
output: 0,
|
|
@@ -67,66 +65,84 @@ export class GoogleLLM {
|
|
|
67
65
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
68
66
|
};
|
|
69
67
|
let stopReason = "stop";
|
|
70
|
-
let inTextBlock = false;
|
|
71
|
-
let inThinkingBlock = false;
|
|
72
68
|
// Process the stream
|
|
73
69
|
for await (const chunk of stream) {
|
|
74
70
|
// Extract parts from the chunk
|
|
75
71
|
const candidate = chunk.candidates?.[0];
|
|
76
72
|
if (candidate?.content?.parts) {
|
|
77
73
|
for (const part of candidate.content.parts) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
if (part.text !== undefined) {
|
|
75
|
+
const isThinking = part.thought === true;
|
|
76
|
+
// Check if we need to switch blocks
|
|
77
|
+
if (!currentBlock ||
|
|
78
|
+
(isThinking && currentBlock.type !== "thinking") ||
|
|
79
|
+
(!isThinking && currentBlock.type !== "text")) {
|
|
80
|
+
// Save and finalize current block
|
|
81
|
+
if (currentBlock) {
|
|
82
|
+
if (currentBlock.type === "text") {
|
|
83
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
87
|
+
}
|
|
88
|
+
blocks.push(currentBlock);
|
|
86
89
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (partWithThinking.thoughtSignature) {
|
|
92
|
-
thoughtSignature = partWithThinking.thoughtSignature;
|
|
90
|
+
// Start new block
|
|
91
|
+
if (isThinking) {
|
|
92
|
+
currentBlock = { type: "thinking", thinking: "", thinkingSignature: undefined };
|
|
93
|
+
options?.onEvent?.({ type: "thinking_start" });
|
|
93
94
|
}
|
|
95
|
+
else {
|
|
96
|
+
currentBlock = { type: "text", text: "" };
|
|
97
|
+
options?.onEvent?.({ type: "text_start" });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Append content to current block
|
|
101
|
+
if (currentBlock.type === "thinking") {
|
|
102
|
+
currentBlock.thinking += part.text;
|
|
103
|
+
currentBlock.thinkingSignature = part.thoughtSignature;
|
|
104
|
+
options?.onEvent?.({
|
|
105
|
+
type: "thinking_delta",
|
|
106
|
+
content: currentBlock.thinking,
|
|
107
|
+
delta: part.text,
|
|
108
|
+
});
|
|
94
109
|
}
|
|
95
110
|
else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
inThinkingBlock = false;
|
|
99
|
-
}
|
|
100
|
-
content += partWithThinking.text;
|
|
101
|
-
options?.onText?.(partWithThinking.text, false);
|
|
102
|
-
inTextBlock = true;
|
|
111
|
+
currentBlock.text += part.text;
|
|
112
|
+
options?.onEvent?.({ type: "text_delta", content: currentBlock.text, delta: part.text });
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
// Handle function calls
|
|
106
116
|
if (part.functionCall) {
|
|
107
|
-
if
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
// Save current block if exists
|
|
118
|
+
if (currentBlock) {
|
|
119
|
+
if (currentBlock.type === "text") {
|
|
120
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
124
|
+
}
|
|
125
|
+
blocks.push(currentBlock);
|
|
126
|
+
currentBlock = null;
|
|
114
127
|
}
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
128
|
+
// Add tool call
|
|
129
|
+
const toolCallId = part.functionCall.id || `${part.functionCall.name}_${Date.now()}`;
|
|
130
|
+
const toolCall = {
|
|
131
|
+
type: "toolCall",
|
|
119
132
|
id: toolCallId,
|
|
120
133
|
name: part.functionCall.name || "",
|
|
121
134
|
arguments: part.functionCall.args,
|
|
122
|
-
}
|
|
135
|
+
};
|
|
136
|
+
blocks.push(toolCall);
|
|
137
|
+
options?.onEvent?.({ type: "toolCall", toolCall });
|
|
123
138
|
}
|
|
124
139
|
}
|
|
125
140
|
}
|
|
126
141
|
// Map finish reason
|
|
127
142
|
if (candidate?.finishReason) {
|
|
128
143
|
stopReason = this.mapStopReason(candidate.finishReason);
|
|
129
|
-
if
|
|
144
|
+
// Check if we have tool calls in blocks
|
|
145
|
+
if (blocks.some((b) => b.type === "toolCall")) {
|
|
130
146
|
stopReason = "toolUse";
|
|
131
147
|
}
|
|
132
148
|
}
|
|
@@ -147,43 +163,32 @@ export class GoogleLLM {
|
|
|
147
163
|
};
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
|
-
//
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (thinking && !thoughtSignature) {
|
|
160
|
-
// Create a base64-encoded signature as Gemini expects
|
|
161
|
-
// In production, Gemini API should provide this
|
|
162
|
-
const encoder = new TextEncoder();
|
|
163
|
-
const data = encoder.encode(thinking);
|
|
164
|
-
// Create a simple hash-like signature and encode to base64
|
|
165
|
-
const signature = `gemini_thinking_${data.length}_${Date.now()}`;
|
|
166
|
-
thoughtSignature = Buffer.from(signature).toString("base64");
|
|
166
|
+
// Save final block if exists
|
|
167
|
+
if (currentBlock) {
|
|
168
|
+
if (currentBlock.type === "text") {
|
|
169
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
173
|
+
}
|
|
174
|
+
blocks.push(currentBlock);
|
|
167
175
|
}
|
|
168
|
-
// Calculate cost
|
|
169
176
|
calculateCost(this.model, usage);
|
|
170
|
-
|
|
171
|
-
// Already captured during streaming
|
|
172
|
-
return {
|
|
177
|
+
const output = {
|
|
173
178
|
role: "assistant",
|
|
174
|
-
content:
|
|
175
|
-
thinking: thinking || undefined,
|
|
176
|
-
thinkingSignature: thoughtSignature,
|
|
177
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
179
|
+
content: blocks,
|
|
178
180
|
provider: this.model.provider,
|
|
179
181
|
model: this.model.id,
|
|
180
182
|
usage,
|
|
181
183
|
stopReason,
|
|
182
184
|
};
|
|
185
|
+
options?.onEvent?.({ type: "done", reason: stopReason, message: output });
|
|
186
|
+
return output;
|
|
183
187
|
}
|
|
184
188
|
catch (error) {
|
|
185
|
-
|
|
189
|
+
const output = {
|
|
186
190
|
role: "assistant",
|
|
191
|
+
content: [],
|
|
187
192
|
provider: this.model.provider,
|
|
188
193
|
model: this.model.id,
|
|
189
194
|
usage: {
|
|
@@ -194,8 +199,10 @@ export class GoogleLLM {
|
|
|
194
199
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
195
200
|
},
|
|
196
201
|
stopReason: "error",
|
|
197
|
-
error: error instanceof Error ? error.message :
|
|
202
|
+
error: error instanceof Error ? error.message : JSON.stringify(error),
|
|
198
203
|
};
|
|
204
|
+
options?.onEvent?.({ type: "error", error: output.error });
|
|
205
|
+
return output;
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
convertMessages(messages) {
|
|
@@ -233,26 +240,25 @@ export class GoogleLLM {
|
|
|
233
240
|
}
|
|
234
241
|
else if (msg.role === "assistant") {
|
|
235
242
|
const parts = [];
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (msg.toolCalls) {
|
|
251
|
-
for (const toolCall of msg.toolCalls) {
|
|
243
|
+
// Process content blocks
|
|
244
|
+
for (const block of msg.content) {
|
|
245
|
+
if (block.type === "text") {
|
|
246
|
+
parts.push({ text: block.text });
|
|
247
|
+
}
|
|
248
|
+
else if (block.type === "thinking") {
|
|
249
|
+
const thinkingPart = {
|
|
250
|
+
thought: true,
|
|
251
|
+
thoughtSignature: block.thinkingSignature,
|
|
252
|
+
text: block.thinking,
|
|
253
|
+
};
|
|
254
|
+
parts.push(thinkingPart);
|
|
255
|
+
}
|
|
256
|
+
else if (block.type === "toolCall") {
|
|
252
257
|
parts.push({
|
|
253
258
|
functionCall: {
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
id: block.id,
|
|
260
|
+
name: block.name,
|
|
261
|
+
args: block.arguments,
|
|
256
262
|
},
|
|
257
263
|
});
|
|
258
264
|
}
|
|
@@ -265,18 +271,16 @@ export class GoogleLLM {
|
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
273
|
else if (msg.role === "toolResult") {
|
|
268
|
-
// Tool results are sent as function responses
|
|
269
|
-
// Extract function name from the tool call ID (format: "functionName_timestamp")
|
|
270
|
-
const functionName = msg.toolCallId.substring(0, msg.toolCallId.lastIndexOf("_"));
|
|
271
274
|
contents.push({
|
|
272
275
|
role: "user",
|
|
273
276
|
parts: [
|
|
274
277
|
{
|
|
275
278
|
functionResponse: {
|
|
276
|
-
|
|
279
|
+
id: msg.toolCallId,
|
|
280
|
+
name: msg.toolName,
|
|
277
281
|
response: {
|
|
278
282
|
result: msg.content,
|
|
279
|
-
isError: msg.isError
|
|
283
|
+
isError: msg.isError,
|
|
280
284
|
},
|
|
281
285
|
},
|
|
282
286
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,yBAAyB,EAGzB,WAAW,GAEX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAsB7C,MAAM,OAAO,SAAS;IACb,MAAM,CAAc;IACpB,KAAK,CAAQ;IAErB,YAAY,KAAY,EAAE,MAAe;QACxC,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CACd,gGAAgG,CAChG,CAAC;YACH,CAAC;YACD,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC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ACC,OAAO,MAAM,CAAC;QAChB,CAAC;IACF,CAAC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/providers/openai-completions.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,UAAU,EAEV,KAAK,
|
|
1
|
+
{"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/providers/openai-completions.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,UAAU,EAEV,KAAK,EAOL,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,2BAA4B,SAAQ,UAAU;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC7F,eAAe,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C;AAED,qBAAa,oBAAqB,YAAW,GAAG,CAAC,2BAA2B,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAQ;gBAEb,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM;IAazC,QAAQ,IAAI,KAAK;IAIX,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgRlG,OAAO,CAAC,eAAe;IA8FvB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,aAAa;CAerB"}
|
|
@@ -49,10 +49,8 @@ export class OpenAICompletionsLLM {
|
|
|
49
49
|
const stream = await this.client.chat.completions.create(params, {
|
|
50
50
|
signal: options?.signal,
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
let reasoningField = null;
|
|
55
|
-
const parsedToolCalls = [];
|
|
52
|
+
const blocks = [];
|
|
53
|
+
let currentBlock = null;
|
|
56
54
|
let usage = {
|
|
57
55
|
input: 0,
|
|
58
56
|
output: 0,
|
|
@@ -61,7 +59,6 @@ export class OpenAICompletionsLLM {
|
|
|
61
59
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
62
60
|
};
|
|
63
61
|
let finishReason = null;
|
|
64
|
-
let blockType = null;
|
|
65
62
|
for await (const chunk of stream) {
|
|
66
63
|
if (chunk.usage) {
|
|
67
64
|
usage = {
|
|
@@ -87,103 +84,173 @@ export class OpenAICompletionsLLM {
|
|
|
87
84
|
if (choice.delta.content !== null &&
|
|
88
85
|
choice.delta.content !== undefined &&
|
|
89
86
|
choice.delta.content.length > 0) {
|
|
90
|
-
if
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
// Check if we need to switch to text block
|
|
88
|
+
if (!currentBlock || currentBlock.type !== "text") {
|
|
89
|
+
// Save current block if exists
|
|
90
|
+
if (currentBlock) {
|
|
91
|
+
if (currentBlock.type === "thinking") {
|
|
92
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
93
|
+
}
|
|
94
|
+
else if (currentBlock.type === "toolCall") {
|
|
95
|
+
currentBlock.arguments = JSON.parse(currentBlock.partialArgs || "{}");
|
|
96
|
+
delete currentBlock.partialArgs;
|
|
97
|
+
options?.onEvent?.({ type: "toolCall", toolCall: currentBlock });
|
|
98
|
+
}
|
|
99
|
+
blocks.push(currentBlock);
|
|
100
|
+
}
|
|
101
|
+
// Start new text block
|
|
102
|
+
currentBlock = { type: "text", text: "" };
|
|
103
|
+
options?.onEvent?.({ type: "text_start" });
|
|
104
|
+
}
|
|
105
|
+
// Append to text block
|
|
106
|
+
if (currentBlock.type === "text") {
|
|
107
|
+
currentBlock.text += choice.delta.content;
|
|
108
|
+
options?.onEvent?.({
|
|
109
|
+
type: "text_delta",
|
|
110
|
+
content: currentBlock.text,
|
|
111
|
+
delta: choice.delta.content,
|
|
112
|
+
});
|
|
93
113
|
}
|
|
94
|
-
content += choice.delta.content;
|
|
95
|
-
options?.onText?.(choice.delta.content, false);
|
|
96
|
-
blockType = "text";
|
|
97
114
|
}
|
|
98
115
|
// Handle reasoning_content field
|
|
99
116
|
if (choice.delta.reasoning_content !== null &&
|
|
100
|
-
choice.delta.reasoning_content !== undefined
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
117
|
+
choice.delta.reasoning_content !== undefined &&
|
|
118
|
+
choice.delta.reasoning_content.length > 0) {
|
|
119
|
+
// Check if we need to switch to thinking block
|
|
120
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
121
|
+
// Save current block if exists
|
|
122
|
+
if (currentBlock) {
|
|
123
|
+
if (currentBlock.type === "text") {
|
|
124
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
125
|
+
}
|
|
126
|
+
else if (currentBlock.type === "toolCall") {
|
|
127
|
+
currentBlock.arguments = JSON.parse(currentBlock.partialArgs || "{}");
|
|
128
|
+
delete currentBlock.partialArgs;
|
|
129
|
+
options?.onEvent?.({ type: "toolCall", toolCall: currentBlock });
|
|
130
|
+
}
|
|
131
|
+
blocks.push(currentBlock);
|
|
132
|
+
}
|
|
133
|
+
// Start new thinking block
|
|
134
|
+
currentBlock = { type: "thinking", thinking: "", thinkingSignature: "reasoning_content" };
|
|
135
|
+
options?.onEvent?.({ type: "thinking_start" });
|
|
136
|
+
}
|
|
137
|
+
// Append to thinking block
|
|
138
|
+
if (currentBlock.type === "thinking") {
|
|
139
|
+
const delta = choice.delta.reasoning_content;
|
|
140
|
+
currentBlock.thinking += delta;
|
|
141
|
+
options?.onEvent?.({ type: "thinking_delta", content: currentBlock.thinking, delta });
|
|
104
142
|
}
|
|
105
|
-
reasoningContent += choice.delta.reasoning_content;
|
|
106
|
-
reasoningField = "reasoning_content";
|
|
107
|
-
options?.onThinking?.(choice.delta.reasoning_content, false);
|
|
108
|
-
blockType = "thinking";
|
|
109
143
|
}
|
|
110
144
|
// Handle reasoning field
|
|
111
|
-
if (choice.delta.reasoning !== null &&
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
145
|
+
if (choice.delta.reasoning !== null &&
|
|
146
|
+
choice.delta.reasoning !== undefined &&
|
|
147
|
+
choice.delta.reasoning.length > 0) {
|
|
148
|
+
// Check if we need to switch to thinking block
|
|
149
|
+
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
150
|
+
// Save current block if exists
|
|
151
|
+
if (currentBlock) {
|
|
152
|
+
if (currentBlock.type === "text") {
|
|
153
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
154
|
+
}
|
|
155
|
+
else if (currentBlock.type === "toolCall") {
|
|
156
|
+
currentBlock.arguments = JSON.parse(currentBlock.partialArgs || "{}");
|
|
157
|
+
delete currentBlock.partialArgs;
|
|
158
|
+
options?.onEvent?.({ type: "toolCall", toolCall: currentBlock });
|
|
159
|
+
}
|
|
160
|
+
blocks.push(currentBlock);
|
|
161
|
+
}
|
|
162
|
+
// Start new thinking block
|
|
163
|
+
currentBlock = { type: "thinking", thinking: "", thinkingSignature: "reasoning" };
|
|
164
|
+
options?.onEvent?.({ type: "thinking_start" });
|
|
165
|
+
}
|
|
166
|
+
// Append to thinking block
|
|
167
|
+
if (currentBlock.type === "thinking") {
|
|
168
|
+
const delta = choice.delta.reasoning;
|
|
169
|
+
currentBlock.thinking += delta;
|
|
170
|
+
options?.onEvent?.({ type: "thinking_delta", content: currentBlock.thinking, delta });
|
|
115
171
|
}
|
|
116
|
-
reasoningContent += choice.delta.reasoning;
|
|
117
|
-
reasoningField = "reasoning";
|
|
118
|
-
options?.onThinking?.(choice.delta.reasoning, false);
|
|
119
|
-
blockType = "thinking";
|
|
120
172
|
}
|
|
121
173
|
// Handle tool calls
|
|
122
174
|
if (choice?.delta?.tool_calls) {
|
|
123
|
-
if (blockType === "text") {
|
|
124
|
-
options?.onText?.("", true);
|
|
125
|
-
blockType = null;
|
|
126
|
-
}
|
|
127
|
-
if (blockType === "thinking") {
|
|
128
|
-
options?.onThinking?.("", true);
|
|
129
|
-
blockType = null;
|
|
130
|
-
}
|
|
131
175
|
for (const toolCall of choice.delta.tool_calls) {
|
|
132
|
-
if
|
|
133
|
-
|
|
134
|
-
|
|
176
|
+
// Check if we need a new tool call block
|
|
177
|
+
if (!currentBlock ||
|
|
178
|
+
currentBlock.type !== "toolCall" ||
|
|
179
|
+
(toolCall.id && currentBlock.id !== toolCall.id)) {
|
|
180
|
+
// Save current block if exists
|
|
181
|
+
if (currentBlock) {
|
|
182
|
+
if (currentBlock.type === "text") {
|
|
183
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
184
|
+
}
|
|
185
|
+
else if (currentBlock.type === "thinking") {
|
|
186
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
187
|
+
}
|
|
188
|
+
else if (currentBlock.type === "toolCall") {
|
|
189
|
+
currentBlock.arguments = JSON.parse(currentBlock.partialArgs || "{}");
|
|
190
|
+
delete currentBlock.partialArgs;
|
|
191
|
+
options?.onEvent?.({ type: "toolCall", toolCall: currentBlock });
|
|
192
|
+
}
|
|
193
|
+
blocks.push(currentBlock);
|
|
194
|
+
}
|
|
195
|
+
// Start new tool call block
|
|
196
|
+
currentBlock = {
|
|
197
|
+
type: "toolCall",
|
|
135
198
|
id: toolCall.id || "",
|
|
136
199
|
name: toolCall.function?.name || "",
|
|
137
|
-
arguments:
|
|
138
|
-
|
|
200
|
+
arguments: {},
|
|
201
|
+
partialArgs: "",
|
|
202
|
+
};
|
|
139
203
|
}
|
|
140
|
-
|
|
141
|
-
if (toolCall
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
204
|
+
// Accumulate tool call data
|
|
205
|
+
if (currentBlock.type === "toolCall") {
|
|
206
|
+
if (toolCall.id)
|
|
207
|
+
currentBlock.id = toolCall.id;
|
|
208
|
+
if (toolCall.function?.name)
|
|
209
|
+
currentBlock.name = toolCall.function.name;
|
|
210
|
+
if (toolCall.function?.arguments) {
|
|
211
|
+
currentBlock.partialArgs += toolCall.function.arguments;
|
|
212
|
+
}
|
|
147
213
|
}
|
|
148
214
|
}
|
|
149
215
|
}
|
|
150
216
|
}
|
|
151
217
|
// Capture finish reason
|
|
152
218
|
if (choice.finish_reason) {
|
|
153
|
-
if (blockType === "text") {
|
|
154
|
-
options?.onText?.("", true);
|
|
155
|
-
blockType = null;
|
|
156
|
-
}
|
|
157
|
-
if (blockType === "thinking") {
|
|
158
|
-
options?.onThinking?.("", true);
|
|
159
|
-
blockType = null;
|
|
160
|
-
}
|
|
161
219
|
finishReason = choice.finish_reason;
|
|
162
220
|
}
|
|
163
221
|
}
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
222
|
+
// Save final block if exists
|
|
223
|
+
if (currentBlock) {
|
|
224
|
+
if (currentBlock.type === "text") {
|
|
225
|
+
options?.onEvent?.({ type: "text_end", content: currentBlock.text });
|
|
226
|
+
}
|
|
227
|
+
else if (currentBlock.type === "thinking") {
|
|
228
|
+
options?.onEvent?.({ type: "thinking_end", content: currentBlock.thinking });
|
|
229
|
+
}
|
|
230
|
+
else if (currentBlock.type === "toolCall") {
|
|
231
|
+
currentBlock.arguments = JSON.parse(currentBlock.partialArgs || "{}");
|
|
232
|
+
delete currentBlock.partialArgs;
|
|
233
|
+
options?.onEvent?.({ type: "toolCall", toolCall: currentBlock });
|
|
234
|
+
}
|
|
235
|
+
blocks.push(currentBlock);
|
|
236
|
+
}
|
|
170
237
|
// Calculate cost
|
|
171
238
|
calculateCost(this.modelInfo, usage);
|
|
172
|
-
|
|
239
|
+
const output = {
|
|
173
240
|
role: "assistant",
|
|
174
|
-
content:
|
|
175
|
-
thinking: reasoningContent || undefined,
|
|
176
|
-
thinkingSignature: reasoningField || undefined,
|
|
177
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
241
|
+
content: blocks,
|
|
178
242
|
provider: this.modelInfo.provider,
|
|
179
243
|
model: this.modelInfo.id,
|
|
180
244
|
usage,
|
|
181
245
|
stopReason: this.mapStopReason(finishReason),
|
|
182
246
|
};
|
|
247
|
+
options?.onEvent?.({ type: "done", reason: output.stopReason, message: output });
|
|
248
|
+
return output;
|
|
183
249
|
}
|
|
184
250
|
catch (error) {
|
|
185
|
-
|
|
251
|
+
const output = {
|
|
186
252
|
role: "assistant",
|
|
253
|
+
content: [],
|
|
187
254
|
provider: this.modelInfo.provider,
|
|
188
255
|
model: this.modelInfo.id,
|
|
189
256
|
usage: {
|
|
@@ -196,6 +263,8 @@ export class OpenAICompletionsLLM {
|
|
|
196
263
|
stopReason: "error",
|
|
197
264
|
error: error instanceof Error ? error.message : String(error),
|
|
198
265
|
};
|
|
266
|
+
options?.onEvent?.({ type: "error", error: output.error || "Unknown error" });
|
|
267
|
+
return output;
|
|
199
268
|
}
|
|
200
269
|
}
|
|
201
270
|
convertMessages(messages, systemPrompt) {
|
|
@@ -247,14 +316,26 @@ export class OpenAICompletionsLLM {
|
|
|
247
316
|
else if (msg.role === "assistant") {
|
|
248
317
|
const assistantMsg = {
|
|
249
318
|
role: "assistant",
|
|
250
|
-
content:
|
|
319
|
+
content: null,
|
|
251
320
|
};
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
321
|
+
// Build content from blocks
|
|
322
|
+
const textBlocks = msg.content.filter((b) => b.type === "text");
|
|
323
|
+
if (textBlocks.length > 0) {
|
|
324
|
+
assistantMsg.content = textBlocks.map((b) => b.text).join("");
|
|
325
|
+
}
|
|
326
|
+
// Handle thinking blocks for llama.cpp server + gpt-oss
|
|
327
|
+
const thinkingBlocks = msg.content.filter((b) => b.type === "thinking");
|
|
328
|
+
if (thinkingBlocks.length > 0) {
|
|
329
|
+
// Use the signature from the first thinking block if available
|
|
330
|
+
const signature = thinkingBlocks[0].thinkingSignature;
|
|
331
|
+
if (signature && signature.length > 0) {
|
|
332
|
+
assistantMsg[signature] = thinkingBlocks.map((b) => b.thinking).join("");
|
|
333
|
+
}
|
|
255
334
|
}
|
|
256
|
-
|
|
257
|
-
|
|
335
|
+
// Handle tool calls
|
|
336
|
+
const toolCalls = msg.content.filter((b) => b.type === "toolCall");
|
|
337
|
+
if (toolCalls.length > 0) {
|
|
338
|
+
assistantMsg.tool_calls = toolCalls.map((tc) => ({
|
|
258
339
|
id: tc.id,
|
|
259
340
|
type: "function",
|
|
260
341
|
function: {
|