@node-llm/core 1.5.1 → 1.5.4
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/README.md +42 -84
- package/dist/chat/Chat.d.ts +9 -21
- package/dist/chat/Chat.d.ts.map +1 -1
- package/dist/chat/Chat.js +83 -122
- package/dist/chat/ChatOptions.d.ts +3 -3
- package/dist/chat/ChatOptions.d.ts.map +1 -1
- package/dist/chat/ChatStream.d.ts +3 -21
- package/dist/chat/ChatStream.d.ts.map +1 -1
- package/dist/chat/ChatStream.js +96 -97
- package/dist/chat/Content.d.ts +10 -0
- package/dist/chat/Content.d.ts.map +1 -1
- package/dist/chat/Content.js +34 -1
- package/dist/chat/Tool.d.ts +6 -0
- package/dist/chat/Tool.d.ts.map +1 -1
- package/dist/chat/ToolHandler.d.ts +11 -0
- package/dist/chat/ToolHandler.d.ts.map +1 -0
- package/dist/chat/ToolHandler.js +42 -0
- package/dist/chat/Validation.d.ts +10 -0
- package/dist/chat/Validation.d.ts.map +1 -0
- package/dist/chat/Validation.js +33 -0
- package/dist/config.d.ts +43 -14
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +58 -13
- package/dist/errors/index.d.ts +8 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +13 -0
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +18 -7
- package/dist/providers/gemini/Image.js +1 -1
- package/dist/providers/openai/Capabilities.d.ts +1 -0
- package/dist/providers/openai/Capabilities.d.ts.map +1 -1
- package/dist/providers/openai/Capabilities.js +3 -0
- package/dist/providers/openai/Chat.d.ts.map +1 -1
- package/dist/providers/openai/Chat.js +13 -4
- package/dist/providers/openai/Streaming.d.ts.map +1 -1
- package/dist/providers/openai/Streaming.js +7 -2
- package/dist/providers/openai/types.d.ts +4 -0
- package/dist/providers/openai/types.d.ts.map +1 -1
- package/dist/utils/Binary.d.ts.map +1 -1
- package/dist/utils/Binary.js +10 -11
- package/dist/utils/audio.js +1 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +15 -4
- package/dist/utils/logger.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatOptions.d.ts","sourceRoot":"","sources":["../../src/chat/ChatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatOptions.d.ts","sourceRoot":"","sources":["../../src/chat/ChatOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAkB,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC;IACpH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE;QAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAA;KAAE,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAClE,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACrE,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACxF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Message } from "./Message.js";
|
|
2
|
+
import { ContentPart } from "./Content.js";
|
|
2
3
|
import { ChatOptions } from "./ChatOptions.js";
|
|
3
4
|
import { Provider, ChatChunk } from "../providers/Provider.js";
|
|
4
5
|
import { Stream } from "../streaming/Stream.js";
|
|
6
|
+
import { AskOptions } from "./Chat.js";
|
|
5
7
|
/**
|
|
6
8
|
* Internal handler for chat streaming logic.
|
|
7
9
|
* Wraps the provider's stream with side effects like history updates and events.
|
|
@@ -13,27 +15,7 @@ export declare class ChatStream {
|
|
|
13
15
|
private messages;
|
|
14
16
|
private systemMessages;
|
|
15
17
|
constructor(provider: Provider, model: string, options?: ChatOptions, messages?: Message[], systemMessages?: Message[]);
|
|
16
|
-
/**
|
|
17
|
-
* Read-only access to message history
|
|
18
|
-
*/
|
|
19
18
|
get history(): readonly Message[];
|
|
20
|
-
|
|
21
|
-
* Creates a high-level Stream object for the chat response.
|
|
22
|
-
* @param content The user's question.
|
|
23
|
-
*/
|
|
24
|
-
create(content: string): Stream<ChatChunk>;
|
|
25
|
-
/**
|
|
26
|
-
* Check if tool execution should proceed based on the current mode.
|
|
27
|
-
*/
|
|
28
|
-
private shouldExecuteTools;
|
|
29
|
-
/**
|
|
30
|
-
* Request user confirmation for a tool call in "confirm" mode.
|
|
31
|
-
* Returns true if approved, false if rejected.
|
|
32
|
-
*/
|
|
33
|
-
private requestToolConfirmation;
|
|
34
|
-
/**
|
|
35
|
-
* Execute a single tool call and return the result message.
|
|
36
|
-
*/
|
|
37
|
-
private executeToolCall;
|
|
19
|
+
create(content: string | ContentPart[], options?: AskOptions): Stream<ChatChunk>;
|
|
38
20
|
}
|
|
39
21
|
//# sourceMappingURL=ChatStream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatStream.d.ts","sourceRoot":"","sources":["../../src/chat/ChatStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"ChatStream.d.ts","sourceRoot":"","sources":["../../src/chat/ChatStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAA4C,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAS,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQvC;;;GAGG;AACH,qBAAa,UAAU;IAKnB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,cAAc,CAAY;gBAGf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,WAAgB,EAC1C,QAAQ,CAAC,EAAE,OAAO,EAAE,EACpB,cAAc,CAAC,EAAE,OAAO,EAAE;IA6B5B,IAAI,OAAO,IAAI,SAAS,OAAO,EAAE,CAEhC;IAED,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,OAAO,GAAE,UAAe,GAAG,MAAM,CAAC,SAAS,CAAC;CAsOrF"}
|
package/dist/chat/ChatStream.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { isBinaryContent, formatMultimodalContent } from "./Content.js";
|
|
1
2
|
import { ChatResponseString } from "./ChatResponse.js";
|
|
2
3
|
import { Stream } from "../streaming/Stream.js";
|
|
3
4
|
import { config } from "../config.js";
|
|
4
5
|
import { ToolExecutionMode } from "../constants.js";
|
|
6
|
+
import { FileLoader } from "../utils/FileLoader.js";
|
|
7
|
+
import { toJsonSchema } from "../schema/to-json-schema.js";
|
|
8
|
+
import { ChatValidator } from "./Validation.js";
|
|
9
|
+
import { ToolHandler } from "./ToolHandler.js";
|
|
10
|
+
import { logger } from "../utils/logger.js";
|
|
5
11
|
/**
|
|
6
12
|
* Internal handler for chat streaming logic.
|
|
7
13
|
* Wraps the provider's stream with side effects like history updates and events.
|
|
@@ -18,7 +24,6 @@ export class ChatStream {
|
|
|
18
24
|
this.options = options;
|
|
19
25
|
this.messages = messages ?? [];
|
|
20
26
|
this.systemMessages = systemMessages ?? [];
|
|
21
|
-
// Only initialize if we're starting a new history
|
|
22
27
|
if (this.messages.length === 0 && this.systemMessages.length === 0) {
|
|
23
28
|
if (options.systemPrompt) {
|
|
24
29
|
this.systemMessages.push({
|
|
@@ -41,39 +46,74 @@ export class ChatStream {
|
|
|
41
46
|
this.options.toolExecution = config.toolExecution || ToolExecutionMode.AUTO;
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Read-only access to message history
|
|
46
|
-
*/
|
|
47
49
|
get history() {
|
|
48
50
|
return [...this.systemMessages, ...this.messages];
|
|
49
51
|
}
|
|
50
|
-
|
|
51
|
-
* Creates a high-level Stream object for the chat response.
|
|
52
|
-
* @param content The user's question.
|
|
53
|
-
*/
|
|
54
|
-
create(content) {
|
|
52
|
+
create(content, options = {}) {
|
|
55
53
|
const controller = new AbortController();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const sideEffectGenerator = async function* (self, provider, model, messages, systemMessages, baseOptions, abortController, content, requestOptions) {
|
|
55
|
+
const options = {
|
|
56
|
+
...baseOptions,
|
|
57
|
+
...requestOptions,
|
|
58
|
+
headers: { ...baseOptions.headers, ...requestOptions.headers }
|
|
59
|
+
};
|
|
60
|
+
// Process Multimodal Content
|
|
61
|
+
let messageContent = content;
|
|
62
|
+
const files = [...(requestOptions.images ?? []), ...(requestOptions.files ?? [])];
|
|
63
|
+
if (files.length > 0) {
|
|
64
|
+
const processedFiles = await Promise.all(files.map((f) => FileLoader.load(f)));
|
|
65
|
+
const hasBinary = processedFiles.some(isBinaryContent);
|
|
66
|
+
ChatValidator.validateVision(provider, model, hasBinary, options);
|
|
67
|
+
messageContent = formatMultimodalContent(content, processedFiles);
|
|
68
|
+
}
|
|
69
|
+
if (options.tools && options.tools.length > 0) {
|
|
70
|
+
ChatValidator.validateTools(provider, model, true, options);
|
|
71
|
+
}
|
|
72
|
+
messages.push({ role: "user", content: messageContent });
|
|
73
|
+
if (!provider.stream) {
|
|
74
|
+
throw new Error("Streaming not supported by provider");
|
|
75
|
+
}
|
|
76
|
+
// Process Schema/Structured Output
|
|
77
|
+
let responseFormat = options.responseFormat;
|
|
78
|
+
if (!responseFormat && options.schema) {
|
|
79
|
+
ChatValidator.validateStructuredOutput(provider, model, true, options);
|
|
80
|
+
const jsonSchema = toJsonSchema(options.schema.definition.schema);
|
|
81
|
+
responseFormat = {
|
|
82
|
+
type: "json_schema",
|
|
83
|
+
json_schema: {
|
|
84
|
+
name: options.schema.definition.name,
|
|
85
|
+
description: options.schema.definition.description,
|
|
86
|
+
strict: options.schema.definition.strict ?? true,
|
|
87
|
+
schema: jsonSchema,
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
59
91
|
if (!provider.stream) {
|
|
60
92
|
throw new Error("Streaming not supported by provider");
|
|
61
93
|
}
|
|
62
|
-
let fullContent = "";
|
|
63
|
-
let fullReasoning = "";
|
|
64
|
-
let toolCalls;
|
|
65
94
|
let isFirst = true;
|
|
66
95
|
const maxToolCalls = options.maxToolCalls ?? 5;
|
|
67
96
|
let stepCount = 0;
|
|
68
|
-
|
|
97
|
+
let totalUsage = { input_tokens: 0, output_tokens: 0, total_tokens: 0 };
|
|
98
|
+
const trackUsage = (u) => {
|
|
99
|
+
if (u) {
|
|
100
|
+
totalUsage.input_tokens += u.input_tokens;
|
|
101
|
+
totalUsage.output_tokens += u.output_tokens;
|
|
102
|
+
totalUsage.total_tokens += u.total_tokens;
|
|
103
|
+
if (u.cached_tokens) {
|
|
104
|
+
totalUsage.cached_tokens = (totalUsage.cached_tokens ?? 0) + u.cached_tokens;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
69
108
|
while (true) {
|
|
70
109
|
stepCount++;
|
|
71
110
|
if (stepCount > maxToolCalls) {
|
|
72
111
|
throw new Error(`[NodeLLM] Maximum tool execution calls (${maxToolCalls}) exceeded during streaming.`);
|
|
73
112
|
}
|
|
74
|
-
fullContent = "";
|
|
75
|
-
fullReasoning = "";
|
|
76
|
-
toolCalls
|
|
113
|
+
let fullContent = "";
|
|
114
|
+
let fullReasoning = "";
|
|
115
|
+
let toolCalls;
|
|
116
|
+
let currentTurnUsage;
|
|
77
117
|
try {
|
|
78
118
|
let requestMessages = [...systemMessages, ...messages];
|
|
79
119
|
if (options.onBeforeRequest) {
|
|
@@ -88,8 +128,11 @@ export class ChatStream {
|
|
|
88
128
|
tools: options.tools,
|
|
89
129
|
temperature: options.temperature,
|
|
90
130
|
max_tokens: options.maxTokens ?? config.maxTokens,
|
|
131
|
+
response_format: responseFormat,
|
|
132
|
+
headers: options.headers,
|
|
91
133
|
requestTimeout: options.requestTimeout ?? config.requestTimeout,
|
|
92
134
|
signal: abortController.signal,
|
|
135
|
+
...options.params,
|
|
93
136
|
})) {
|
|
94
137
|
if (isFirst) {
|
|
95
138
|
if (options.onNewMessage)
|
|
@@ -104,43 +147,40 @@ export class ChatStream {
|
|
|
104
147
|
fullReasoning += chunk.reasoning;
|
|
105
148
|
yield { content: "", reasoning: chunk.reasoning };
|
|
106
149
|
}
|
|
107
|
-
// Accumulate tool calls from the final chunk
|
|
108
150
|
if (chunk.tool_calls) {
|
|
109
151
|
toolCalls = chunk.tool_calls;
|
|
110
152
|
}
|
|
153
|
+
if (chunk.usage) {
|
|
154
|
+
currentTurnUsage = chunk.usage;
|
|
155
|
+
trackUsage(currentTurnUsage);
|
|
156
|
+
}
|
|
111
157
|
}
|
|
112
|
-
|
|
113
|
-
let assistantResponse = new ChatResponseString(fullContent || "", { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, model, provider.id, fullReasoning || undefined);
|
|
114
|
-
// --- Content Policy Hooks (Output) ---
|
|
158
|
+
let assistantResponse = new ChatResponseString(fullContent || "", currentTurnUsage || { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, model, provider.id, fullReasoning || undefined);
|
|
115
159
|
if (options.onAfterResponse) {
|
|
116
160
|
const result = await options.onAfterResponse(assistantResponse);
|
|
117
161
|
if (result) {
|
|
118
162
|
assistantResponse = result;
|
|
119
163
|
}
|
|
120
164
|
}
|
|
121
|
-
// Add assistant message to history (now potentially redacted)
|
|
122
165
|
messages.push({
|
|
123
166
|
role: "assistant",
|
|
124
167
|
content: assistantResponse || null,
|
|
125
168
|
tool_calls: toolCalls,
|
|
126
|
-
reasoning: fullReasoning || undefined
|
|
169
|
+
reasoning: fullReasoning || undefined,
|
|
170
|
+
usage: currentTurnUsage
|
|
127
171
|
});
|
|
128
|
-
// If no tool calls, we're done
|
|
129
172
|
if (!toolCalls || toolCalls.length === 0) {
|
|
130
173
|
if (options.onEndMessage) {
|
|
131
174
|
options.onEndMessage(assistantResponse);
|
|
132
175
|
}
|
|
133
176
|
break;
|
|
134
177
|
}
|
|
135
|
-
|
|
136
|
-
if (!self.shouldExecuteTools(toolCalls, options.toolExecution)) {
|
|
178
|
+
if (!ToolHandler.shouldExecuteTools(toolCalls, options.toolExecution)) {
|
|
137
179
|
break;
|
|
138
180
|
}
|
|
139
|
-
// Execute tool calls
|
|
140
181
|
for (const toolCall of toolCalls) {
|
|
141
|
-
// Confirm mode: request approval
|
|
142
182
|
if (options.toolExecution === ToolExecutionMode.CONFIRM) {
|
|
143
|
-
const approved = await
|
|
183
|
+
const approved = await ToolHandler.requestToolConfirmation(toolCall, options.onConfirmToolCall);
|
|
144
184
|
if (!approved) {
|
|
145
185
|
messages.push({
|
|
146
186
|
role: "tool",
|
|
@@ -150,80 +190,39 @@ export class ChatStream {
|
|
|
150
190
|
continue;
|
|
151
191
|
}
|
|
152
192
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
193
|
+
try {
|
|
194
|
+
const toolResult = await ToolHandler.execute(toolCall, options.tools, options.onToolCallStart, options.onToolCallEnd);
|
|
195
|
+
messages.push(toolResult);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
const directive = await options.onToolCallError?.(toolCall, error);
|
|
199
|
+
if (directive === 'STOP') {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
messages.push({
|
|
203
|
+
role: "tool",
|
|
204
|
+
tool_call_id: toolCall.id,
|
|
205
|
+
content: `Fatal error executing tool '${toolCall.function.name}': ${error.message}`,
|
|
206
|
+
});
|
|
207
|
+
if (directive === 'CONTINUE') {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const isFatal = error.fatal === true || error.status === 401 || error.status === 403;
|
|
211
|
+
if (isFatal) {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
logger.error(`Tool execution failed for '${toolCall.function.name}':`, error);
|
|
215
|
+
}
|
|
156
216
|
}
|
|
157
|
-
// Continue loop to stream the next response after tool execution
|
|
158
217
|
}
|
|
159
218
|
catch (error) {
|
|
160
219
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
161
|
-
//
|
|
220
|
+
// Aborted
|
|
162
221
|
}
|
|
163
222
|
throw error;
|
|
164
223
|
}
|
|
165
224
|
}
|
|
166
225
|
};
|
|
167
|
-
return new Stream(() => sideEffectGenerator(this, this.provider, this.model, this.messages, this.systemMessages, this.options, controller), controller);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Check if tool execution should proceed based on the current mode.
|
|
171
|
-
*/
|
|
172
|
-
shouldExecuteTools(toolCalls, mode) {
|
|
173
|
-
if (!toolCalls || toolCalls.length === 0)
|
|
174
|
-
return false;
|
|
175
|
-
if (mode === ToolExecutionMode.DRY_RUN)
|
|
176
|
-
return false;
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Request user confirmation for a tool call in "confirm" mode.
|
|
181
|
-
* Returns true if approved, false if rejected.
|
|
182
|
-
*/
|
|
183
|
-
async requestToolConfirmation(toolCall, onConfirm) {
|
|
184
|
-
if (!onConfirm)
|
|
185
|
-
return true;
|
|
186
|
-
const confirmed = await onConfirm(toolCall);
|
|
187
|
-
return confirmed !== false;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Execute a single tool call and return the result message.
|
|
191
|
-
*/
|
|
192
|
-
async executeToolCall(toolCall, tools, onStart, onEnd, onError) {
|
|
193
|
-
if (onStart)
|
|
194
|
-
onStart(toolCall);
|
|
195
|
-
const tool = tools?.find((t) => t.function.name === toolCall.function.name);
|
|
196
|
-
if (tool?.handler) {
|
|
197
|
-
try {
|
|
198
|
-
const args = JSON.parse(toolCall.function.arguments);
|
|
199
|
-
const result = await tool.handler(args);
|
|
200
|
-
if (onEnd)
|
|
201
|
-
onEnd(toolCall, result);
|
|
202
|
-
return {
|
|
203
|
-
role: "tool",
|
|
204
|
-
tool_call_id: toolCall.id,
|
|
205
|
-
content: result,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
if (onError)
|
|
210
|
-
onError(toolCall, error);
|
|
211
|
-
return {
|
|
212
|
-
role: "tool",
|
|
213
|
-
tool_call_id: toolCall.id,
|
|
214
|
-
content: `Error executing tool: ${error.message}`,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
const error = new Error("Tool not found or no handler provided");
|
|
220
|
-
if (onError)
|
|
221
|
-
onError(toolCall, error);
|
|
222
|
-
return {
|
|
223
|
-
role: "tool",
|
|
224
|
-
tool_call_id: toolCall.id,
|
|
225
|
-
content: "Error: Tool not found or no handler provided",
|
|
226
|
-
};
|
|
227
|
-
}
|
|
226
|
+
return new Stream(() => sideEffectGenerator(this, this.provider, this.model, this.messages, this.systemMessages, this.options, controller, content, options), controller);
|
|
228
227
|
}
|
|
229
228
|
}
|
package/dist/chat/Content.d.ts
CHANGED
|
@@ -18,5 +18,15 @@ export type ContentPart = {
|
|
|
18
18
|
url: string;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
export declare const isBinaryContent: (part: ContentPart) => boolean;
|
|
22
|
+
export declare const isTextContent: (part: ContentPart) => boolean;
|
|
23
|
+
export declare const partitionContentParts: (parts: ContentPart[]) => {
|
|
24
|
+
textParts: ({
|
|
25
|
+
type: "text";
|
|
26
|
+
text: string;
|
|
27
|
+
})[];
|
|
28
|
+
binaryParts: ContentPart[];
|
|
29
|
+
};
|
|
30
|
+
export declare const formatMultimodalContent: (content: string | ContentPart[], parts: ContentPart[]) => MessageContent;
|
|
21
31
|
export type MessageContent = string | String | ContentPart[];
|
|
22
32
|
//# sourceMappingURL=Content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.d.ts","sourceRoot":"","sources":["../../src/chat/Content.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"Content.d.ts","sourceRoot":"","sources":["../../src/chat/Content.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,eAAe,GAAI,MAAM,WAAW,KAAG,OACmC,CAAC;AAExF,eAAO,MAAM,aAAa,GAAI,MAAM,WAAW,KAAG,OAC5B,CAAC;AAEvB,eAAO,MAAM,qBAAqB,GAAI,OAAO,WAAW,EAAE;eAEZ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;;CAG/E,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,SAAS,MAAM,GAAG,WAAW,EAAE,EAAE,OAAO,WAAW,EAAE,KAAG,cA2B/F,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,EAAE,CAAC"}
|
package/dist/chat/Content.js
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const isBinaryContent = (part) => part.type === "image_url" || part.type === "input_audio" || part.type === "video_url";
|
|
2
|
+
export const isTextContent = (part) => part.type === "text";
|
|
3
|
+
export const partitionContentParts = (parts) => {
|
|
4
|
+
return {
|
|
5
|
+
textParts: parts.filter(isTextContent),
|
|
6
|
+
binaryParts: parts.filter(isBinaryContent)
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export const formatMultimodalContent = (content, parts) => {
|
|
10
|
+
const { textParts, binaryParts } = partitionContentParts(parts);
|
|
11
|
+
let fullText = typeof content === "string" ? content : "";
|
|
12
|
+
let currentParts = typeof content === "string" ? [] : content;
|
|
13
|
+
if (textParts.length > 0) {
|
|
14
|
+
const additionalText = textParts.map(f => f.text).join("\n");
|
|
15
|
+
if (typeof content === "string") {
|
|
16
|
+
fullText += "\n" + additionalText;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
currentParts.push({ type: "text", text: additionalText });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (binaryParts.length > 0) {
|
|
23
|
+
if (typeof content === "string") {
|
|
24
|
+
return [
|
|
25
|
+
{ type: "text", text: fullText },
|
|
26
|
+
...binaryParts
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return [...currentParts, ...binaryParts];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return typeof content === "string" ? fullText : currentParts;
|
|
34
|
+
};
|
package/dist/chat/Tool.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ export interface ToolDefinition {
|
|
|
16
16
|
};
|
|
17
17
|
handler?: (args: any) => Promise<string>;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Anything that can be resolved into a ToolDefinition.
|
|
21
|
+
*/
|
|
22
|
+
export type ToolResolvable = Tool | {
|
|
23
|
+
new (): Tool;
|
|
24
|
+
} | ToolDefinition | any;
|
|
19
25
|
/**
|
|
20
26
|
* Subclass this to create tools with auto-generated schemas and type safety.
|
|
21
27
|
*/
|
package/dist/chat/Tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../../src/chat/Tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,E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C,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG;IAAE,QAAO,IAAI,CAAA;CAAE,GAAG,cAAc,GAAG,GAAG,CAAC;AAE3E;;GAEG;AACH,8BAAsB,IAAI,CAAC,CAAC,GAAG,GAAG;IAChC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;;OAGG;IACH,SAAgB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/D;;;OAGG;aACa,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAE9C;;;OAGG;IACU,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAM9C;;;OAGG;IACI,SAAS,IAAI,cAAc;CAoBnC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ToolExecutionMode } from "../constants.js";
|
|
2
|
+
export declare class ToolHandler {
|
|
3
|
+
static shouldExecuteTools(toolCalls: any[] | undefined, mode?: ToolExecutionMode): boolean;
|
|
4
|
+
static requestToolConfirmation(toolCall: any, onConfirm?: (call: any) => Promise<boolean> | boolean): Promise<boolean>;
|
|
5
|
+
static execute(toolCall: any, tools: any[] | undefined, onStart?: (call: any) => void, onEnd?: (call: any, result: any) => void): Promise<{
|
|
6
|
+
role: "tool";
|
|
7
|
+
tool_call_id: string;
|
|
8
|
+
content: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ToolHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolHandler.d.ts","sourceRoot":"","sources":["../../src/chat/ToolHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,qBAAa,WAAW;IACtB,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO;WAM7E,uBAAuB,CAClC,QAAQ,EAAE,GAAG,EACb,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GACpD,OAAO,CAAC,OAAO,CAAC;WAMN,OAAO,CAClB,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,EACxB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,EAC7B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GACvC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAyBpE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ToolExecutionMode } from "../constants.js";
|
|
2
|
+
import { ToolError } from "../errors/index.js";
|
|
3
|
+
export class ToolHandler {
|
|
4
|
+
static shouldExecuteTools(toolCalls, mode) {
|
|
5
|
+
if (!toolCalls || toolCalls.length === 0)
|
|
6
|
+
return false;
|
|
7
|
+
if (mode === ToolExecutionMode.DRY_RUN)
|
|
8
|
+
return false;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
static async requestToolConfirmation(toolCall, onConfirm) {
|
|
12
|
+
if (!onConfirm)
|
|
13
|
+
return true;
|
|
14
|
+
const confirmed = await onConfirm(toolCall);
|
|
15
|
+
return confirmed !== false;
|
|
16
|
+
}
|
|
17
|
+
static async execute(toolCall, tools, onStart, onEnd) {
|
|
18
|
+
if (onStart)
|
|
19
|
+
onStart(toolCall);
|
|
20
|
+
const tool = tools?.find((t) => t.function.name === toolCall.function.name);
|
|
21
|
+
if (tool?.handler) {
|
|
22
|
+
try {
|
|
23
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
24
|
+
const result = await tool.handler(args);
|
|
25
|
+
const safeResult = typeof result === 'string' ? result : JSON.stringify(result);
|
|
26
|
+
if (onEnd)
|
|
27
|
+
onEnd(toolCall, result);
|
|
28
|
+
return {
|
|
29
|
+
role: "tool",
|
|
30
|
+
tool_call_id: toolCall.id,
|
|
31
|
+
content: safeResult,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new ToolError("Tool not found or no handler provided", toolCall.function?.name ?? "unknown");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Provider } from "../providers/Provider.js";
|
|
2
|
+
export interface ValidationOptions {
|
|
3
|
+
assumeModelExists?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class ChatValidator {
|
|
6
|
+
static validateVision(provider: Provider, model: string, hasBinary: boolean, options: ValidationOptions): void;
|
|
7
|
+
static validateTools(provider: Provider, model: string, hasTools: boolean, options: ValidationOptions): void;
|
|
8
|
+
static validateStructuredOutput(provider: Provider, model: string, hasSchema: boolean, options: ValidationOptions): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validation.d.ts","sourceRoot":"","sources":["../../src/chat/Validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,qBAAa,aAAa;IACxB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;IAYvG,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;IAYrG,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;CAWlH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
export class ChatValidator {
|
|
3
|
+
static validateVision(provider, model, hasBinary, options) {
|
|
4
|
+
if (!hasBinary)
|
|
5
|
+
return;
|
|
6
|
+
if (!options.assumeModelExists && provider.capabilities && !provider.capabilities.supportsVision(model)) {
|
|
7
|
+
throw new Error(`Model ${model} does not support vision/binary files.`);
|
|
8
|
+
}
|
|
9
|
+
if (options.assumeModelExists) {
|
|
10
|
+
logger.warn(`Skipping vision capability validation for model ${model}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
static validateTools(provider, model, hasTools, options) {
|
|
14
|
+
if (!hasTools)
|
|
15
|
+
return;
|
|
16
|
+
if (!options.assumeModelExists && provider.capabilities && !provider.capabilities.supportsTools(model)) {
|
|
17
|
+
throw new Error(`Model ${model} does not support tool calling.`);
|
|
18
|
+
}
|
|
19
|
+
if (options.assumeModelExists) {
|
|
20
|
+
logger.warn(`Skipping tool capability validation for model ${model}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
static validateStructuredOutput(provider, model, hasSchema, options) {
|
|
24
|
+
if (!hasSchema)
|
|
25
|
+
return;
|
|
26
|
+
if (!options.assumeModelExists && provider.capabilities && !provider.capabilities.supportsStructuredOutput(model)) {
|
|
27
|
+
throw new Error(`Model ${model} does not support structured output.`);
|
|
28
|
+
}
|
|
29
|
+
if (options.assumeModelExists) {
|
|
30
|
+
logger.warn(`Skipping structured output capability validation for model ${model}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -22,25 +22,54 @@ export interface NodeLLMConfig {
|
|
|
22
22
|
toolExecution?: ToolExecutionMode;
|
|
23
23
|
}
|
|
24
24
|
import { ToolExecutionMode } from "./constants.js";
|
|
25
|
-
declare class Configuration implements NodeLLMConfig {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
export declare class Configuration implements NodeLLMConfig {
|
|
26
|
+
private _openaiApiKey?;
|
|
27
|
+
private _openaiApiBase?;
|
|
28
|
+
private _anthropicApiKey?;
|
|
29
|
+
private _anthropicApiBase?;
|
|
30
|
+
private _geminiApiKey?;
|
|
31
|
+
private _geminiApiBase?;
|
|
32
|
+
private _deepseekApiKey?;
|
|
33
|
+
private _deepseekApiBase?;
|
|
34
|
+
private _ollamaApiBase?;
|
|
35
|
+
private _openrouterApiKey?;
|
|
36
|
+
private _openrouterApiBase?;
|
|
37
|
+
private _debug?;
|
|
38
|
+
get openaiApiKey(): string | undefined;
|
|
39
|
+
set openaiApiKey(v: string | undefined);
|
|
40
|
+
get openaiApiBase(): string | undefined;
|
|
41
|
+
set openaiApiBase(v: string | undefined);
|
|
42
|
+
get anthropicApiKey(): string | undefined;
|
|
43
|
+
set anthropicApiKey(v: string | undefined);
|
|
44
|
+
get anthropicApiBase(): string | undefined;
|
|
45
|
+
set anthropicApiBase(v: string | undefined);
|
|
46
|
+
get geminiApiKey(): string | undefined;
|
|
47
|
+
set geminiApiKey(v: string | undefined);
|
|
48
|
+
get geminiApiBase(): string | undefined;
|
|
49
|
+
set geminiApiBase(v: string | undefined);
|
|
50
|
+
get deepseekApiKey(): string | undefined;
|
|
51
|
+
set deepseekApiKey(v: string | undefined);
|
|
52
|
+
get deepseekApiBase(): string | undefined;
|
|
53
|
+
set deepseekApiBase(v: string | undefined);
|
|
54
|
+
get ollamaApiBase(): string | undefined;
|
|
55
|
+
set ollamaApiBase(v: string | undefined);
|
|
56
|
+
get openrouterApiKey(): string | undefined;
|
|
57
|
+
set openrouterApiKey(v: string | undefined);
|
|
58
|
+
get openrouterApiBase(): string | undefined;
|
|
59
|
+
set openrouterApiBase(v: string | undefined);
|
|
60
|
+
get debug(): boolean | undefined;
|
|
61
|
+
set debug(v: boolean | undefined);
|
|
38
62
|
maxToolCalls: number;
|
|
39
63
|
maxRetries: number;
|
|
40
64
|
requestTimeout: number;
|
|
41
65
|
maxTokens: number;
|
|
42
66
|
toolExecution: ToolExecutionMode;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a plain object with all configuration values.
|
|
69
|
+
* This is useful for cloning or serialization.
|
|
70
|
+
* It handles getters (lazy-loaded values) correctly.
|
|
71
|
+
*/
|
|
72
|
+
toPlainObject(): NodeLLMConfig;
|
|
43
73
|
}
|
|
44
74
|
export declare const config: Configuration;
|
|
45
|
-
export {};
|
|
46
75
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,C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