@node-llm/core 1.6.2 → 1.7.0
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/aliases.d.ts +2 -0
- package/dist/aliases.d.ts.map +1 -1
- package/dist/aliases.js +3 -1
- package/dist/chat/Chat.d.ts +10 -1
- package/dist/chat/Chat.d.ts.map +1 -1
- package/dist/chat/Chat.js +17 -3
- package/dist/chat/ChatOptions.d.ts +2 -1
- package/dist/chat/ChatOptions.d.ts.map +1 -1
- package/dist/chat/ChatResponse.d.ts +5 -2
- package/dist/chat/ChatResponse.d.ts.map +1 -1
- package/dist/chat/ChatResponse.js +5 -2
- package/dist/chat/ChatStream.d.ts.map +1 -1
- package/dist/chat/ChatStream.js +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/models/models.d.ts.map +1 -1
- package/dist/models/models.js +109 -20
- package/dist/providers/Provider.d.ts +32 -0
- package/dist/providers/Provider.d.ts.map +1 -1
- package/dist/providers/anthropic/Chat.d.ts.map +1 -1
- package/dist/providers/anthropic/Chat.js +23 -1
- package/dist/providers/anthropic/Streaming.d.ts.map +1 -1
- package/dist/providers/anthropic/Streaming.js +15 -0
- package/dist/providers/anthropic/types.d.ts +7 -1
- package/dist/providers/anthropic/types.d.ts.map +1 -1
- package/dist/providers/deepseek/Chat.d.ts.map +1 -1
- package/dist/providers/deepseek/Chat.js +9 -2
- package/dist/providers/deepseek/Streaming.d.ts.map +1 -1
- package/dist/providers/deepseek/Streaming.js +3 -2
- package/dist/providers/gemini/Chat.d.ts.map +1 -1
- package/dist/providers/gemini/Chat.js +18 -2
- package/dist/providers/gemini/Streaming.d.ts.map +1 -1
- package/dist/providers/gemini/Streaming.js +17 -2
- package/dist/providers/gemini/types.d.ts +4 -0
- package/dist/providers/gemini/types.d.ts.map +1 -1
- package/dist/providers/openai/Chat.d.ts.map +1 -1
- package/dist/providers/openai/Chat.js +18 -3
- package/dist/providers/openai/Streaming.d.ts.map +1 -1
- package/dist/providers/openai/Streaming.js +11 -3
- package/package.json +1 -1
package/dist/aliases.d.ts
CHANGED
|
@@ -279,6 +279,7 @@ declare const _default: {
|
|
|
279
279
|
readonly openrouter: "z-ai/glm-4.6:exacto";
|
|
280
280
|
};
|
|
281
281
|
readonly "glm-4.7": {
|
|
282
|
+
readonly gemini: "zai-org/glm-4.7-maas";
|
|
282
283
|
readonly openrouter: "z-ai/glm-4.7";
|
|
283
284
|
};
|
|
284
285
|
readonly "glm-z1-32b-free": {
|
|
@@ -362,6 +363,7 @@ declare const _default: {
|
|
|
362
363
|
};
|
|
363
364
|
readonly "gpt-5.1-codex-max": {
|
|
364
365
|
readonly openai: "gpt-5.1-codex-max";
|
|
366
|
+
readonly openrouter: "openai/gpt-5.1-codex-max";
|
|
365
367
|
};
|
|
366
368
|
readonly "gpt-5.1-codex-mini": {
|
|
367
369
|
readonly openai: "gpt-5.1-codex-mini";
|
package/dist/aliases.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../src/aliases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../src/aliases.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAqnBW"}
|
package/dist/aliases.js
CHANGED
|
@@ -279,6 +279,7 @@ export default {
|
|
|
279
279
|
"openrouter": "z-ai/glm-4.6:exacto"
|
|
280
280
|
},
|
|
281
281
|
"glm-4.7": {
|
|
282
|
+
"gemini": "zai-org/glm-4.7-maas",
|
|
282
283
|
"openrouter": "z-ai/glm-4.7"
|
|
283
284
|
},
|
|
284
285
|
"glm-z1-32b-free": {
|
|
@@ -361,7 +362,8 @@ export default {
|
|
|
361
362
|
"openrouter": "openai/gpt-5.1-codex"
|
|
362
363
|
},
|
|
363
364
|
"gpt-5.1-codex-max": {
|
|
364
|
-
"openai": "gpt-5.1-codex-max"
|
|
365
|
+
"openai": "gpt-5.1-codex-max",
|
|
366
|
+
"openrouter": "openai/gpt-5.1-codex-max"
|
|
365
367
|
},
|
|
366
368
|
"gpt-5.1-codex-mini": {
|
|
367
369
|
"openai": "gpt-5.1-codex-mini",
|
package/dist/chat/Chat.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Message } from "./Message.js";
|
|
2
2
|
import { ContentPart } from "./Content.js";
|
|
3
3
|
import { ChatOptions } from "./ChatOptions.js";
|
|
4
|
-
import { Provider, Usage, ChatChunk } from "../providers/Provider.js";
|
|
4
|
+
import { Provider, Usage, ChatChunk, ThinkingConfig } from "../providers/Provider.js";
|
|
5
5
|
import { Stream } from "../streaming/Stream.js";
|
|
6
6
|
import { ToolResolvable } from "./Tool.js";
|
|
7
7
|
import { Schema } from "../schema/Schema.js";
|
|
@@ -15,6 +15,7 @@ export interface AskOptions {
|
|
|
15
15
|
headers?: Record<string, string>;
|
|
16
16
|
maxToolCalls?: number;
|
|
17
17
|
requestTimeout?: number;
|
|
18
|
+
thinking?: ThinkingConfig;
|
|
18
19
|
signal?: AbortSignal;
|
|
19
20
|
}
|
|
20
21
|
import { ChatResponseString } from "./ChatResponse.js";
|
|
@@ -106,6 +107,14 @@ export declare class Chat {
|
|
|
106
107
|
* Can accept a Schema object or a Zod schema/JSON Schema directly.
|
|
107
108
|
*/
|
|
108
109
|
withSchema(schema: Schema | z.ZodType<unknown> | Record<string, unknown> | null): this;
|
|
110
|
+
/**
|
|
111
|
+
* Enable and configure extended thinking for reasoning models.
|
|
112
|
+
*/
|
|
113
|
+
withThinking(config: ThinkingConfig): this;
|
|
114
|
+
/**
|
|
115
|
+
* Shortcut to set thinking effort.
|
|
116
|
+
*/
|
|
117
|
+
withEffort(effort: "low" | "medium" | "high" | "none"): this;
|
|
109
118
|
onNewMessage(handler: () => void): this;
|
|
110
119
|
onEndMessage(handler: (message: ChatResponseString) => void): this;
|
|
111
120
|
onToolCall(handler: (toolCall: unknown) => void): this;
|
package/dist/chat/Chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../src/chat/Chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../src/chat/Chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,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,aAAa,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;IAKhF;;;OAGG;IACH,aAAa,CACX,OAAO,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAC5E,IAAI;IAKP;;OAEG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuQ7F;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,OAAO,GAAE,UAAe,GAAG,MAAM,CAAC,SAAS,CAAC;IAWpF;;OAEG;IACH,OAAO,CAAC,aAAa;CAoDtB"}
|
package/dist/chat/Chat.js
CHANGED
|
@@ -203,6 +203,19 @@ export class Chat {
|
|
|
203
203
|
}
|
|
204
204
|
return this;
|
|
205
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Enable and configure extended thinking for reasoning models.
|
|
208
|
+
*/
|
|
209
|
+
withThinking(config) {
|
|
210
|
+
this.options.thinking = { ...this.options.thinking, ...config };
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Shortcut to set thinking effort.
|
|
215
|
+
*/
|
|
216
|
+
withEffort(effort) {
|
|
217
|
+
return this.withThinking({ effort });
|
|
218
|
+
}
|
|
206
219
|
// --- Event Handlers ---
|
|
207
220
|
onNewMessage(handler) {
|
|
208
221
|
this.options.onNewMessage = handler;
|
|
@@ -313,6 +326,7 @@ export class Chat {
|
|
|
313
326
|
headers: { ...this.options.headers, ...options?.headers },
|
|
314
327
|
response_format: responseFormat, // Pass to provider
|
|
315
328
|
requestTimeout: options?.requestTimeout ?? this.options.requestTimeout ?? config.requestTimeout,
|
|
329
|
+
thinking: options?.thinking ?? this.options.thinking,
|
|
316
330
|
signal: options?.signal,
|
|
317
331
|
...this.options.params
|
|
318
332
|
};
|
|
@@ -344,7 +358,7 @@ export class Chat {
|
|
|
344
358
|
this.options.onNewMessage();
|
|
345
359
|
let response = await this.executor.executeChat(executeOptions);
|
|
346
360
|
trackUsage(response.usage);
|
|
347
|
-
let assistantMessage = new ChatResponseString(response.content ?? "", response.usage ?? { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, this.model, this.provider.id, response.reasoning, response.tool_calls);
|
|
361
|
+
let assistantMessage = new ChatResponseString(response.content ?? "", response.usage ?? { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, this.model, this.provider.id, response.thinking, response.reasoning, response.tool_calls);
|
|
348
362
|
// --- Content Policy Hooks (Output - Turn 1) ---
|
|
349
363
|
if (this.options.onAfterResponse) {
|
|
350
364
|
const result = await this.options.onAfterResponse(assistantMessage);
|
|
@@ -428,7 +442,7 @@ export class Chat {
|
|
|
428
442
|
...this.options.params
|
|
429
443
|
});
|
|
430
444
|
trackUsage(response.usage);
|
|
431
|
-
assistantMessage = new ChatResponseString(response.content ?? "", response.usage ?? { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, this.model, this.provider.id, response.reasoning);
|
|
445
|
+
assistantMessage = new ChatResponseString(response.content ?? "", response.usage ?? { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, this.model, this.provider.id, response.thinking, response.reasoning);
|
|
432
446
|
// --- Content Policy Hooks (Output - Tool Turns) ---
|
|
433
447
|
if (this.options.onAfterResponse) {
|
|
434
448
|
const result = await this.options.onAfterResponse(assistantMessage);
|
|
@@ -448,7 +462,7 @@ export class Chat {
|
|
|
448
462
|
}
|
|
449
463
|
// For the final return, we might want to aggregate reasoning too if it happened in multiple turns?
|
|
450
464
|
// Usually reasoning only happens once or we just want the last one.
|
|
451
|
-
return new ChatResponseString(assistantMessage.toString() || "", totalUsage, this.model, this.provider.id, assistantMessage.reasoning, response.tool_calls);
|
|
465
|
+
return new ChatResponseString(assistantMessage.toString() || "", totalUsage, this.model, this.provider.id, assistantMessage.thinking, assistantMessage.reasoning, response.tool_calls);
|
|
452
466
|
}
|
|
453
467
|
/**
|
|
454
468
|
* Streams the model's response to a user question.
|
|
@@ -3,7 +3,7 @@ import { ToolResolvable } from "./Tool.js";
|
|
|
3
3
|
import { Schema } from "../schema/Schema.js";
|
|
4
4
|
import { ChatResponseString } from "./ChatResponse.js";
|
|
5
5
|
import { ToolExecutionMode } from "../constants.js";
|
|
6
|
-
import { ResponseFormat } from "../providers/Provider.js";
|
|
6
|
+
import { ResponseFormat, ThinkingConfig } from "../providers/Provider.js";
|
|
7
7
|
export interface ChatOptions {
|
|
8
8
|
systemPrompt?: string;
|
|
9
9
|
messages?: Message[];
|
|
@@ -23,6 +23,7 @@ export interface ChatOptions {
|
|
|
23
23
|
provider?: string;
|
|
24
24
|
maxToolCalls?: number;
|
|
25
25
|
requestTimeout?: number;
|
|
26
|
+
thinking?: ThinkingConfig;
|
|
26
27
|
toolExecution?: ToolExecutionMode;
|
|
27
28
|
onConfirmToolCall?: (toolCall: unknown) => Promise<boolean> | boolean;
|
|
28
29
|
onBeforeRequest?: (messages: Message[]) => Promise<Message[] | void>;
|
|
@@ -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,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatOptions.d.ts","sourceRoot":"","sources":["../../src/chat/ChatOptions.ts"],"names":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,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACtE,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,4 +1,4 @@
|
|
|
1
|
-
import { Usage } from "../providers/Provider.js";
|
|
1
|
+
import { Usage, ThinkingResult } from "../providers/Provider.js";
|
|
2
2
|
import { ToolCall } from "./Tool.js";
|
|
3
3
|
/**
|
|
4
4
|
* Enhanced string that includes token usage metadata.
|
|
@@ -8,9 +8,10 @@ export declare class ChatResponseString extends String {
|
|
|
8
8
|
readonly usage: Usage;
|
|
9
9
|
readonly model: string;
|
|
10
10
|
readonly provider: string;
|
|
11
|
+
readonly thinking?: ThinkingResult | undefined;
|
|
11
12
|
readonly reasoning?: string | null | undefined;
|
|
12
13
|
readonly tool_calls?: ToolCall[] | undefined;
|
|
13
|
-
constructor(content: string, usage: Usage, model: string, provider: string, reasoning?: string | null | undefined, tool_calls?: ToolCall[] | undefined);
|
|
14
|
+
constructor(content: string, usage: Usage, model: string, provider: string, thinking?: ThinkingResult | undefined, reasoning?: string | null | undefined, tool_calls?: ToolCall[] | undefined);
|
|
14
15
|
get input_tokens(): number;
|
|
15
16
|
get output_tokens(): number;
|
|
16
17
|
get total_tokens(): number;
|
|
@@ -32,6 +33,7 @@ export declare class ChatResponseString extends String {
|
|
|
32
33
|
usage: Usage;
|
|
33
34
|
model: string;
|
|
34
35
|
provider: string;
|
|
36
|
+
thinking: ThinkingResult | undefined;
|
|
35
37
|
reasoning: string | null | undefined;
|
|
36
38
|
tool_calls: ToolCall[] | undefined;
|
|
37
39
|
};
|
|
@@ -42,6 +44,7 @@ export declare class ChatResponseString extends String {
|
|
|
42
44
|
usage: Usage;
|
|
43
45
|
model: string;
|
|
44
46
|
provider: string;
|
|
47
|
+
thinking: ThinkingResult | undefined;
|
|
45
48
|
reasoning: string | null | undefined;
|
|
46
49
|
tool_calls: ToolCall[] | undefined;
|
|
47
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatResponse.d.ts","sourceRoot":"","sources":["../../src/chat/ChatResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatResponse.d.ts","sourceRoot":"","sources":["../../src/chat/ChatResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,MAAM;aAG1B,KAAK,EAAE,KAAK;aACZ,KAAK,EAAE,MAAM;aACb,QAAQ,EAAE,MAAM;aAChB,QAAQ,CAAC,EAAE,cAAc;aACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;aACzB,UAAU,CAAC,EAAE,QAAQ,EAAE;gBANvC,OAAO,EAAE,MAAM,EACC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,cAAc,YAAA,EACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,YAAA,EACzB,UAAU,CAAC,EAAE,QAAQ,EAAE,YAAA;IAKzC,IAAI,YAAY,WAEf;IACD,IAAI,aAAa,WAEhB;IACD,IAAI,YAAY,WAEf;IACD,IAAI,aAAa,uBAEhB;IACD,IAAI,IAAI,uBAEP;IACD,IAAI,UAAU,uBAEb;IACD,IAAI,WAAW,uBAEd;IAGD,IAAI,WAAW,WAEd;IACD,IAAI,YAAY,WAEf;IACD,IAAI,WAAW,WAEd;IACD,IAAI,YAAY,uBAEf;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;OAGG;IACH,IAAI,IAAI;;;;;;;MASP;IAED;;OAEG;IACH,IAAI,GAAG;;;;;;;MAEN;IAED,QAAQ;IAIR;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB;IAYnD;;;OAGG;IACH,IAAI,MAAM,IAAI,OAAO,CAMpB;CACF"}
|
|
@@ -6,13 +6,15 @@ export class ChatResponseString extends String {
|
|
|
6
6
|
usage;
|
|
7
7
|
model;
|
|
8
8
|
provider;
|
|
9
|
+
thinking;
|
|
9
10
|
reasoning;
|
|
10
11
|
tool_calls;
|
|
11
|
-
constructor(content, usage, model, provider, reasoning, tool_calls) {
|
|
12
|
+
constructor(content, usage, model, provider, thinking, reasoning, tool_calls) {
|
|
12
13
|
super(content);
|
|
13
14
|
this.usage = usage;
|
|
14
15
|
this.model = model;
|
|
15
16
|
this.provider = provider;
|
|
17
|
+
this.thinking = thinking;
|
|
16
18
|
this.reasoning = reasoning;
|
|
17
19
|
this.tool_calls = tool_calls;
|
|
18
20
|
}
|
|
@@ -65,6 +67,7 @@ export class ChatResponseString extends String {
|
|
|
65
67
|
usage: this.usage,
|
|
66
68
|
model: this.model,
|
|
67
69
|
provider: this.provider,
|
|
70
|
+
thinking: this.thinking,
|
|
68
71
|
reasoning: this.reasoning,
|
|
69
72
|
tool_calls: this.tool_calls
|
|
70
73
|
};
|
|
@@ -82,7 +85,7 @@ export class ChatResponseString extends String {
|
|
|
82
85
|
* Return a new ChatResponseString with modified content but preserved metadata.
|
|
83
86
|
*/
|
|
84
87
|
withContent(newContent) {
|
|
85
|
-
return new ChatResponseString(newContent, this.usage, this.model, this.provider, this.reasoning, this.tool_calls);
|
|
88
|
+
return new ChatResponseString(newContent, this.usage, this.model, this.provider, this.thinking, this.reasoning, this.tool_calls);
|
|
86
89
|
}
|
|
87
90
|
/**
|
|
88
91
|
* Attempt to parse the content as JSON.
|
|
@@ -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,EACL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,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,EACL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAyB,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AASvC;;;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;CA4QrF"}
|
package/dist/chat/ChatStream.js
CHANGED
|
@@ -112,6 +112,7 @@ export class ChatStream {
|
|
|
112
112
|
}
|
|
113
113
|
let fullContent = "";
|
|
114
114
|
let fullReasoning = "";
|
|
115
|
+
const thinking = { text: "" };
|
|
115
116
|
let toolCalls;
|
|
116
117
|
let currentTurnUsage;
|
|
117
118
|
try {
|
|
@@ -131,6 +132,7 @@ export class ChatStream {
|
|
|
131
132
|
response_format: responseFormat,
|
|
132
133
|
headers: options.headers,
|
|
133
134
|
requestTimeout: options.requestTimeout ?? config.requestTimeout,
|
|
135
|
+
thinking: options.thinking,
|
|
134
136
|
signal: abortController.signal,
|
|
135
137
|
...options.params
|
|
136
138
|
})) {
|
|
@@ -147,6 +149,18 @@ export class ChatStream {
|
|
|
147
149
|
fullReasoning += chunk.reasoning;
|
|
148
150
|
yield { content: "", reasoning: chunk.reasoning };
|
|
149
151
|
}
|
|
152
|
+
if (chunk.thinking) {
|
|
153
|
+
if (chunk.thinking.text) {
|
|
154
|
+
thinking.text += chunk.thinking.text;
|
|
155
|
+
}
|
|
156
|
+
if (chunk.thinking.signature) {
|
|
157
|
+
thinking.signature = chunk.thinking.signature;
|
|
158
|
+
}
|
|
159
|
+
if (chunk.thinking.tokens) {
|
|
160
|
+
thinking.tokens = (thinking.tokens ?? 0) + chunk.thinking.tokens;
|
|
161
|
+
}
|
|
162
|
+
yield chunk;
|
|
163
|
+
}
|
|
150
164
|
if (chunk.tool_calls) {
|
|
151
165
|
toolCalls = chunk.tool_calls;
|
|
152
166
|
}
|
|
@@ -155,7 +169,7 @@ export class ChatStream {
|
|
|
155
169
|
trackUsage(currentTurnUsage);
|
|
156
170
|
}
|
|
157
171
|
}
|
|
158
|
-
let assistantResponse = new ChatResponseString(fullContent || "", currentTurnUsage || { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, model, provider.id, fullReasoning || undefined);
|
|
172
|
+
let assistantResponse = new ChatResponseString(fullContent || "", currentTurnUsage || { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, model, provider.id, thinking.text || thinking.signature ? thinking : undefined, fullReasoning || undefined);
|
|
159
173
|
if (options.onAfterResponse) {
|
|
160
174
|
const result = await options.onAfterResponse(assistantResponse);
|
|
161
175
|
if (result) {
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type { NodeLLMConfig } from "./config.js";
|
|
|
13
13
|
export { providerRegistry } from "./providers/registry.js";
|
|
14
14
|
export { Schema } from "./schema/Schema.js";
|
|
15
15
|
export { BaseProvider } from "./providers/BaseProvider.js";
|
|
16
|
+
export { ChatRequest, ChatResponse, ChatChunk, ThinkingConfig, ThinkingResult, Usage } from "./providers/Provider.js";
|
|
16
17
|
export { resolveModelAlias } from "./model_aliases.js";
|
|
17
18
|
export { default as MODEL_ALIASES } from "./aliases.js";
|
|
18
19
|
export { ToolExecutionMode, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MAX_RETRIES, DEFAULT_TOOL_EXECUTION, DEFAULT_OLLAMA_BASE_URL, DEFAULT_MODELS } from "./constants.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAA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E,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,EACN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models/models.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models/models.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAi4VtB,CAAC"}
|
package/dist/models/models.js
CHANGED
|
@@ -2362,16 +2362,16 @@ export const modelsData = [
|
|
|
2362
2362
|
"pricing": {
|
|
2363
2363
|
"text_tokens": {
|
|
2364
2364
|
"standard": {
|
|
2365
|
-
"input_per_million": 0.
|
|
2366
|
-
"output_per_million": 0.
|
|
2365
|
+
"input_per_million": 0.15,
|
|
2366
|
+
"output_per_million": 0.6,
|
|
2367
2367
|
"cached_input_per_million": 0.025,
|
|
2368
|
-
"reasoning_output_per_million": 0.
|
|
2368
|
+
"reasoning_output_per_million": 0.6
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
2371
2371
|
},
|
|
2372
2372
|
"metadata": {
|
|
2373
2373
|
"source": "models.dev",
|
|
2374
|
-
"input": 0.
|
|
2374
|
+
"input": 0.15,
|
|
2375
2375
|
"output": 8192,
|
|
2376
2376
|
"cache_read": 0.025,
|
|
2377
2377
|
"context": 1048576
|
|
@@ -5504,16 +5504,16 @@ export const modelsData = [
|
|
|
5504
5504
|
"standard": {
|
|
5505
5505
|
"input_per_million": 1.25,
|
|
5506
5506
|
"output_per_million": 10,
|
|
5507
|
-
"cached_input_per_million": 0.
|
|
5507
|
+
"cached_input_per_million": 0.125,
|
|
5508
5508
|
"reasoning_output_per_million": 10
|
|
5509
5509
|
}
|
|
5510
5510
|
}
|
|
5511
5511
|
},
|
|
5512
5512
|
"metadata": {
|
|
5513
5513
|
"source": "models.dev",
|
|
5514
|
-
"input":
|
|
5514
|
+
"input": 272000,
|
|
5515
5515
|
"output": 128000,
|
|
5516
|
-
"cache_read": 0.
|
|
5516
|
+
"cache_read": 0.125,
|
|
5517
5517
|
"context": 400000
|
|
5518
5518
|
}
|
|
5519
5519
|
},
|
|
@@ -5552,7 +5552,7 @@ export const modelsData = [
|
|
|
5552
5552
|
},
|
|
5553
5553
|
"metadata": {
|
|
5554
5554
|
"source": "models.dev",
|
|
5555
|
-
"input":
|
|
5555
|
+
"input": 272000,
|
|
5556
5556
|
"output": 128000,
|
|
5557
5557
|
"context": 400000
|
|
5558
5558
|
}
|
|
@@ -5597,7 +5597,7 @@ export const modelsData = [
|
|
|
5597
5597
|
},
|
|
5598
5598
|
"metadata": {
|
|
5599
5599
|
"source": "models.dev",
|
|
5600
|
-
"input":
|
|
5600
|
+
"input": 272000,
|
|
5601
5601
|
"output": 128000,
|
|
5602
5602
|
"cache_read": 0.125,
|
|
5603
5603
|
"context": 400000
|
|
@@ -5636,16 +5636,16 @@ export const modelsData = [
|
|
|
5636
5636
|
"standard": {
|
|
5637
5637
|
"input_per_million": 0.25,
|
|
5638
5638
|
"output_per_million": 2,
|
|
5639
|
-
"cached_input_per_million": 0.
|
|
5639
|
+
"cached_input_per_million": 0.025,
|
|
5640
5640
|
"reasoning_output_per_million": 2
|
|
5641
5641
|
}
|
|
5642
5642
|
}
|
|
5643
5643
|
},
|
|
5644
5644
|
"metadata": {
|
|
5645
5645
|
"source": "models.dev",
|
|
5646
|
-
"input":
|
|
5646
|
+
"input": 272000,
|
|
5647
5647
|
"output": 128000,
|
|
5648
|
-
"cache_read": 0.
|
|
5648
|
+
"cache_read": 0.025,
|
|
5649
5649
|
"context": 400000
|
|
5650
5650
|
}
|
|
5651
5651
|
},
|
|
@@ -5682,16 +5682,16 @@ export const modelsData = [
|
|
|
5682
5682
|
"standard": {
|
|
5683
5683
|
"input_per_million": 0.05,
|
|
5684
5684
|
"output_per_million": 0.4,
|
|
5685
|
-
"cached_input_per_million": 0.
|
|
5685
|
+
"cached_input_per_million": 0.005,
|
|
5686
5686
|
"reasoning_output_per_million": 0.4
|
|
5687
5687
|
}
|
|
5688
5688
|
}
|
|
5689
5689
|
},
|
|
5690
5690
|
"metadata": {
|
|
5691
5691
|
"source": "models.dev",
|
|
5692
|
-
"input":
|
|
5692
|
+
"input": 272000,
|
|
5693
5693
|
"output": 128000,
|
|
5694
|
-
"cache_read": 0.
|
|
5694
|
+
"cache_read": 0.005,
|
|
5695
5695
|
"context": 400000
|
|
5696
5696
|
}
|
|
5697
5697
|
},
|
|
@@ -5734,7 +5734,7 @@ export const modelsData = [
|
|
|
5734
5734
|
},
|
|
5735
5735
|
"metadata": {
|
|
5736
5736
|
"source": "models.dev",
|
|
5737
|
-
"input":
|
|
5737
|
+
"input": 272000,
|
|
5738
5738
|
"output": 272000,
|
|
5739
5739
|
"context": 400000
|
|
5740
5740
|
}
|
|
@@ -5779,7 +5779,7 @@ export const modelsData = [
|
|
|
5779
5779
|
},
|
|
5780
5780
|
"metadata": {
|
|
5781
5781
|
"source": "models.dev",
|
|
5782
|
-
"input":
|
|
5782
|
+
"input": 272000,
|
|
5783
5783
|
"output": 128000,
|
|
5784
5784
|
"cache_read": 0.13,
|
|
5785
5785
|
"context": 400000
|
|
@@ -6009,7 +6009,7 @@ export const modelsData = [
|
|
|
6009
6009
|
},
|
|
6010
6010
|
"metadata": {
|
|
6011
6011
|
"source": "models.dev",
|
|
6012
|
-
"input":
|
|
6012
|
+
"input": 272000,
|
|
6013
6013
|
"output": 128000,
|
|
6014
6014
|
"cache_read": 0.175,
|
|
6015
6015
|
"context": 400000
|
|
@@ -6073,7 +6073,8 @@ export const modelsData = [
|
|
|
6073
6073
|
"modalities": {
|
|
6074
6074
|
"input": [
|
|
6075
6075
|
"text",
|
|
6076
|
-
"image"
|
|
6076
|
+
"image",
|
|
6077
|
+
"pdf"
|
|
6077
6078
|
],
|
|
6078
6079
|
"output": [
|
|
6079
6080
|
"text"
|
|
@@ -6146,7 +6147,7 @@ export const modelsData = [
|
|
|
6146
6147
|
},
|
|
6147
6148
|
"metadata": {
|
|
6148
6149
|
"source": "models.dev",
|
|
6149
|
-
"input":
|
|
6150
|
+
"input": 272000,
|
|
6150
6151
|
"output": 128000,
|
|
6151
6152
|
"context": 400000
|
|
6152
6153
|
}
|
|
@@ -8553,6 +8554,52 @@ export const modelsData = [
|
|
|
8553
8554
|
"context": 400000
|
|
8554
8555
|
}
|
|
8555
8556
|
},
|
|
8557
|
+
{
|
|
8558
|
+
"id": "openai/gpt-5.1-codex-max",
|
|
8559
|
+
"name": "GPT-5.1-Codex-Max",
|
|
8560
|
+
"provider": "openrouter",
|
|
8561
|
+
"family": "gpt-codex",
|
|
8562
|
+
"created_at": "2025-11-13 00:00:00 UTC",
|
|
8563
|
+
"context_window": 400000,
|
|
8564
|
+
"max_output_tokens": 128000,
|
|
8565
|
+
"knowledge_cutoff": "2024-09-30",
|
|
8566
|
+
"modalities": {
|
|
8567
|
+
"input": [
|
|
8568
|
+
"text",
|
|
8569
|
+
"image"
|
|
8570
|
+
],
|
|
8571
|
+
"output": [
|
|
8572
|
+
"text"
|
|
8573
|
+
]
|
|
8574
|
+
},
|
|
8575
|
+
"capabilities": [
|
|
8576
|
+
"streaming",
|
|
8577
|
+
"reasoning",
|
|
8578
|
+
"chat",
|
|
8579
|
+
"vision",
|
|
8580
|
+
"function_calling",
|
|
8581
|
+
"tools",
|
|
8582
|
+
"structured_output",
|
|
8583
|
+
"json_mode"
|
|
8584
|
+
],
|
|
8585
|
+
"pricing": {
|
|
8586
|
+
"text_tokens": {
|
|
8587
|
+
"standard": {
|
|
8588
|
+
"input_per_million": 1.1,
|
|
8589
|
+
"output_per_million": 9,
|
|
8590
|
+
"cached_input_per_million": 0.11,
|
|
8591
|
+
"reasoning_output_per_million": 9
|
|
8592
|
+
}
|
|
8593
|
+
}
|
|
8594
|
+
},
|
|
8595
|
+
"metadata": {
|
|
8596
|
+
"source": "models.dev",
|
|
8597
|
+
"input": 1.1,
|
|
8598
|
+
"output": 128000,
|
|
8599
|
+
"cache_read": 0.11,
|
|
8600
|
+
"context": 400000
|
|
8601
|
+
}
|
|
8602
|
+
},
|
|
8556
8603
|
{
|
|
8557
8604
|
"id": "openai/gpt-5.1-codex-mini",
|
|
8558
8605
|
"name": "GPT-5.1-Codex-Mini",
|
|
@@ -11045,5 +11092,47 @@ export const modelsData = [
|
|
|
11045
11092
|
"cache_read": 0.11,
|
|
11046
11093
|
"context": 204800
|
|
11047
11094
|
}
|
|
11095
|
+
},
|
|
11096
|
+
{
|
|
11097
|
+
"id": "zai-org/glm-4.7-maas",
|
|
11098
|
+
"name": "GLM-4.7",
|
|
11099
|
+
"provider": "gemini",
|
|
11100
|
+
"family": "glm",
|
|
11101
|
+
"created_at": "2025-12-22 00:00:00 UTC",
|
|
11102
|
+
"context_window": 204800,
|
|
11103
|
+
"max_output_tokens": 131072,
|
|
11104
|
+
"knowledge_cutoff": "2025-04",
|
|
11105
|
+
"modalities": {
|
|
11106
|
+
"input": [
|
|
11107
|
+
"text"
|
|
11108
|
+
],
|
|
11109
|
+
"output": [
|
|
11110
|
+
"text"
|
|
11111
|
+
]
|
|
11112
|
+
},
|
|
11113
|
+
"capabilities": [
|
|
11114
|
+
"streaming",
|
|
11115
|
+
"reasoning",
|
|
11116
|
+
"chat",
|
|
11117
|
+
"function_calling",
|
|
11118
|
+
"tools",
|
|
11119
|
+
"structured_output",
|
|
11120
|
+
"json_mode"
|
|
11121
|
+
],
|
|
11122
|
+
"pricing": {
|
|
11123
|
+
"text_tokens": {
|
|
11124
|
+
"standard": {
|
|
11125
|
+
"input_per_million": 0.6,
|
|
11126
|
+
"output_per_million": 2.2,
|
|
11127
|
+
"reasoning_output_per_million": 2.2
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
11130
|
+
},
|
|
11131
|
+
"metadata": {
|
|
11132
|
+
"source": "models.dev",
|
|
11133
|
+
"input": 0.6,
|
|
11134
|
+
"output": 131072,
|
|
11135
|
+
"context": 204800
|
|
11136
|
+
}
|
|
11048
11137
|
}
|
|
11049
11138
|
];
|
|
@@ -11,10 +11,37 @@ export interface ResponseFormat {
|
|
|
11
11
|
};
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}
|
|
14
|
+
export interface ThinkingConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Effort level for thinking-capable models.
|
|
17
|
+
* 'low', 'medium', 'high' map to provider-specific qualitative settings.
|
|
18
|
+
* 'none' disables thinking if the model allows it.
|
|
19
|
+
*/
|
|
20
|
+
effort?: "low" | "medium" | "high" | "none";
|
|
21
|
+
/**
|
|
22
|
+
* Maximum budget (in tokens) dedicated to thinking.
|
|
23
|
+
*/
|
|
24
|
+
budget?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ThinkingResult {
|
|
27
|
+
/**
|
|
28
|
+
* The thinking text (chain of thought).
|
|
29
|
+
*/
|
|
30
|
+
text?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Cryptographic signature or provider-specific trace ID.
|
|
33
|
+
*/
|
|
34
|
+
signature?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Tokens consumed during thinking.
|
|
37
|
+
*/
|
|
38
|
+
tokens?: number;
|
|
39
|
+
}
|
|
14
40
|
export interface ChatRequest {
|
|
15
41
|
model: string;
|
|
16
42
|
messages: Message[];
|
|
17
43
|
tools?: ToolDefinition[];
|
|
44
|
+
thinking?: ThinkingConfig;
|
|
18
45
|
temperature?: number;
|
|
19
46
|
max_tokens?: number;
|
|
20
47
|
response_format?: ResponseFormat;
|
|
@@ -24,6 +51,8 @@ export interface ChatRequest {
|
|
|
24
51
|
}
|
|
25
52
|
export interface ChatChunk {
|
|
26
53
|
content: string;
|
|
54
|
+
thinking?: ThinkingResult;
|
|
55
|
+
/** @deprecated use thinking.text */
|
|
27
56
|
reasoning?: string;
|
|
28
57
|
tool_calls?: ToolCall[];
|
|
29
58
|
done?: boolean;
|
|
@@ -33,6 +62,7 @@ export interface Usage {
|
|
|
33
62
|
input_tokens: number;
|
|
34
63
|
output_tokens: number;
|
|
35
64
|
total_tokens: number;
|
|
65
|
+
reasoning_tokens?: number;
|
|
36
66
|
cached_tokens?: number;
|
|
37
67
|
cache_creation_tokens?: number;
|
|
38
68
|
cost?: number;
|
|
@@ -41,6 +71,8 @@ export interface Usage {
|
|
|
41
71
|
}
|
|
42
72
|
export interface ChatResponse {
|
|
43
73
|
content: string | null;
|
|
74
|
+
thinking?: ThinkingResult;
|
|
75
|
+
/** @deprecated use thinking.text */
|
|
44
76
|
reasoning?: string | null;
|
|
45
77
|
tool_calls?: ToolCall[];
|
|
46
78
|
usage?: Usage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/providers/Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC;IAC7C,WAAW,CAAC,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC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CAAC;CACZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAU3E,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAyJ3D"}
|
|
@@ -27,7 +27,7 @@ export class AnthropicChat {
|
|
|
27
27
|
const instruction = `CRITICAL: Respond ONLY with a valid JSON object matching the requested schema.${schemaText}\n\nDo not include any other text or explanation.`;
|
|
28
28
|
system = system ? `${system}\n\n${instruction}` : instruction;
|
|
29
29
|
}
|
|
30
|
-
const { model: _model, messages: _messages, tools: _tools, temperature: _temp, max_tokens: _max, response_format: _format, headers: _headers, requestTimeout, ...rest } = request;
|
|
30
|
+
const { model: _model, messages: _messages, tools: _tools, temperature: _temp, max_tokens: _max, response_format: _format, thinking: _thinking, headers: _headers, requestTimeout, ...rest } = request;
|
|
31
31
|
const body = {
|
|
32
32
|
model: model,
|
|
33
33
|
messages: messages,
|
|
@@ -36,6 +36,16 @@ export class AnthropicChat {
|
|
|
36
36
|
stream: false,
|
|
37
37
|
...rest
|
|
38
38
|
};
|
|
39
|
+
if (_thinking?.budget) {
|
|
40
|
+
body.thinking = {
|
|
41
|
+
type: "enabled",
|
|
42
|
+
budget_tokens: _thinking.budget
|
|
43
|
+
};
|
|
44
|
+
// Extended thinking models require a larger max_tokens
|
|
45
|
+
if (!request.max_tokens) {
|
|
46
|
+
body.max_tokens = Math.max(maxTokens, _thinking.budget + 1024);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
if (request.temperature !== undefined) {
|
|
40
50
|
body.temperature = request.temperature;
|
|
41
51
|
}
|
|
@@ -73,6 +83,7 @@ export class AnthropicChat {
|
|
|
73
83
|
const contentBlocks = json.content;
|
|
74
84
|
// Extract text content and tool calls
|
|
75
85
|
let content = null;
|
|
86
|
+
let thinkingResult = undefined;
|
|
76
87
|
const toolCalls = [];
|
|
77
88
|
for (const block of contentBlocks) {
|
|
78
89
|
if (block.type === "text") {
|
|
@@ -80,6 +91,16 @@ export class AnthropicChat {
|
|
|
80
91
|
content = "";
|
|
81
92
|
content += block.text;
|
|
82
93
|
}
|
|
94
|
+
else if (block.type === "thinking") {
|
|
95
|
+
// Handle thinking block (Claude 3.7)
|
|
96
|
+
if (!thinkingResult)
|
|
97
|
+
thinkingResult = { text: "" };
|
|
98
|
+
if (block.thinking) {
|
|
99
|
+
thinkingResult.text = (thinkingResult.text || "") + block.thinking;
|
|
100
|
+
}
|
|
101
|
+
if (block.signature)
|
|
102
|
+
thinkingResult.signature = block.signature;
|
|
103
|
+
}
|
|
83
104
|
else if (block.type === "tool_use") {
|
|
84
105
|
toolCalls.push({
|
|
85
106
|
id: block.id,
|
|
@@ -106,6 +127,7 @@ export class AnthropicChat {
|
|
|
106
127
|
return {
|
|
107
128
|
content,
|
|
108
129
|
usage: calculatedUsage,
|
|
130
|
+
thinking: thinkingResult,
|
|
109
131
|
tool_calls: toolCalls.length > 0 ? toolCalls : undefined
|
|
110
132
|
};
|
|
111
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQxD,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQxD,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;CAyN9F"}
|
|
@@ -44,6 +44,15 @@ export class AnthropicStreaming {
|
|
|
44
44
|
input_schema: tool.function.parameters
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
|
+
if (request.thinking?.budget) {
|
|
48
|
+
body.thinking = {
|
|
49
|
+
type: "enabled",
|
|
50
|
+
budget_tokens: request.thinking.budget
|
|
51
|
+
};
|
|
52
|
+
if (!request.max_tokens) {
|
|
53
|
+
body.max_tokens = Math.max(maxTokens, request.thinking.budget + 1024);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
47
56
|
// Check if any message contains PDF content to add beta header
|
|
48
57
|
const hasPdf = messages.some((msg) => Array.isArray(msg.content) && msg.content.some((block) => block.type === "document"));
|
|
49
58
|
const headers = {
|
|
@@ -128,6 +137,12 @@ export class AnthropicStreaming {
|
|
|
128
137
|
if (data.delta && data.delta.type === "text_delta") {
|
|
129
138
|
yield { content: data.delta.text };
|
|
130
139
|
}
|
|
140
|
+
else if (data.delta && data.delta.type === "thinking_delta") {
|
|
141
|
+
yield { content: "", thinking: { text: data.delta.thinking } };
|
|
142
|
+
}
|
|
143
|
+
else if (data.delta && data.delta.type === "signature_delta") {
|
|
144
|
+
yield { content: "", thinking: { signature: data.delta.signature } };
|
|
145
|
+
}
|
|
131
146
|
else if (data.delta && data.delta.type === "input_json_delta") {
|
|
132
147
|
// Accumulate tool arguments
|
|
133
148
|
const index = data.index;
|
|
@@ -3,7 +3,7 @@ export interface AnthropicMessage {
|
|
|
3
3
|
content: string | Array<AnthropicContentBlock>;
|
|
4
4
|
}
|
|
5
5
|
export interface AnthropicContentBlock {
|
|
6
|
-
type: "text" | "image" | "tool_use" | "tool_result" | "document";
|
|
6
|
+
type: "text" | "image" | "tool_use" | "tool_result" | "document" | "thinking" | "redacted_thinking";
|
|
7
7
|
text?: string;
|
|
8
8
|
source?: {
|
|
9
9
|
type: "base64";
|
|
@@ -16,6 +16,8 @@ export interface AnthropicContentBlock {
|
|
|
16
16
|
tool_use_id?: string;
|
|
17
17
|
content?: string | Array<AnthropicContentBlock>;
|
|
18
18
|
is_error?: boolean;
|
|
19
|
+
thinking?: string;
|
|
20
|
+
signature?: string;
|
|
19
21
|
}
|
|
20
22
|
export interface AnthropicMessageRequest {
|
|
21
23
|
model: string;
|
|
@@ -37,6 +39,10 @@ export interface AnthropicMessageRequest {
|
|
|
37
39
|
type: string;
|
|
38
40
|
name?: string;
|
|
39
41
|
};
|
|
42
|
+
thinking?: {
|
|
43
|
+
type: "enabled" | "disabled";
|
|
44
|
+
budget_tokens: number;
|
|
45
|
+
};
|
|
40
46
|
}
|
|
41
47
|
export interface AnthropicUsage {
|
|
42
48
|
input_tokens: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,KAAK,CA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oot":"","sources":["../../../src/providers/deepseek/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAS,MAAM,gBAAgB,CAAC;AAgClE,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/deepseek/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAS,MAAM,gBAAgB,CAAC;AAgClE,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAoH3D"}
|
|
@@ -10,7 +10,7 @@ export class DeepSeekChat {
|
|
|
10
10
|
this.apiKey = apiKey;
|
|
11
11
|
}
|
|
12
12
|
async execute(request) {
|
|
13
|
-
const { model, messages, tools, max_tokens, response_format, headers: _headers, requestTimeout, ...rest } = request;
|
|
13
|
+
const { model, messages, tools, max_tokens, response_format, thinking: _thinking, headers: _headers, requestTimeout, ...rest } = request;
|
|
14
14
|
const mappedMessages = mapSystemMessages(messages, false);
|
|
15
15
|
const body = {
|
|
16
16
|
model,
|
|
@@ -89,6 +89,13 @@ export class DeepSeekChat {
|
|
|
89
89
|
}
|
|
90
90
|
// deepseek cost calculation if needed, otherwise just return usage
|
|
91
91
|
const calculatedUsage = ModelRegistry.calculateCost(usage, model, "deepseek");
|
|
92
|
-
|
|
92
|
+
const thinkingResult = reasoning ? { text: reasoning } : undefined;
|
|
93
|
+
return {
|
|
94
|
+
content,
|
|
95
|
+
reasoning,
|
|
96
|
+
usage: calculatedUsage,
|
|
97
|
+
thinking: thinkingResult,
|
|
98
|
+
tool_calls: toolCalls
|
|
99
|
+
};
|
|
93
100
|
}
|
|
94
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/deepseek/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMxD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/deepseek/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMxD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;CAkL9F"}
|
|
@@ -11,7 +11,7 @@ export class DeepSeekStreaming {
|
|
|
11
11
|
}
|
|
12
12
|
async *execute(request, controller) {
|
|
13
13
|
const abortController = controller || new AbortController();
|
|
14
|
-
const { model, messages, tools, max_tokens, response_format, headers: _headers, requestTimeout, ...rest } = request;
|
|
14
|
+
const { model, messages, tools, max_tokens, response_format, thinking: _thinking, headers: _headers, requestTimeout, ...rest } = request;
|
|
15
15
|
const mappedMessages = mapSystemMessages(messages, false);
|
|
16
16
|
const body = {
|
|
17
17
|
model,
|
|
@@ -100,7 +100,8 @@ export class DeepSeekStreaming {
|
|
|
100
100
|
if (deltaContent || deltaReasoning) {
|
|
101
101
|
yield {
|
|
102
102
|
content: deltaContent || "",
|
|
103
|
-
reasoning: deltaReasoning || ""
|
|
103
|
+
reasoning: deltaReasoning || "",
|
|
104
|
+
thinking: deltaReasoning ? { text: deltaReasoning } : undefined
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
// Handle tool calls delta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS3D,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS3D,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAuI1D,OAAO,CAAC,cAAc;CAyBvB"}
|
|
@@ -37,6 +37,11 @@ export class GeminiChat {
|
|
|
37
37
|
},
|
|
38
38
|
...rest
|
|
39
39
|
};
|
|
40
|
+
if (request.thinking) {
|
|
41
|
+
payload.thinkingConfig = {
|
|
42
|
+
includeThoughts: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
40
45
|
if (systemInstructionParts.length > 0) {
|
|
41
46
|
payload.systemInstruction = { parts: systemInstructionParts };
|
|
42
47
|
}
|
|
@@ -65,8 +70,12 @@ export class GeminiChat {
|
|
|
65
70
|
const json = (await response.json());
|
|
66
71
|
logger.logResponse("Gemini", response.status, response.statusText, json);
|
|
67
72
|
const candidate = json.candidates?.[0];
|
|
73
|
+
const reasoningText = candidate?.content?.parts
|
|
74
|
+
?.filter((p) => p.thought)
|
|
75
|
+
.map((p) => p.text)
|
|
76
|
+
.join("\n") || null;
|
|
68
77
|
const content = candidate?.content?.parts
|
|
69
|
-
?.filter((p) => p.text)
|
|
78
|
+
?.filter((p) => !p.thought && p.text)
|
|
70
79
|
.map((p) => p.text)
|
|
71
80
|
.join("\n") || null;
|
|
72
81
|
const tool_calls = candidate?.content?.parts
|
|
@@ -89,7 +98,14 @@ export class GeminiChat {
|
|
|
89
98
|
const calculatedUsage = usage
|
|
90
99
|
? ModelRegistry.calculateCost(usage, request.model, "gemini")
|
|
91
100
|
: undefined;
|
|
92
|
-
|
|
101
|
+
const thinkingResult = reasoningText ? { text: reasoningText } : undefined;
|
|
102
|
+
return {
|
|
103
|
+
content,
|
|
104
|
+
tool_calls,
|
|
105
|
+
usage: calculatedUsage,
|
|
106
|
+
thinking: thinkingResult,
|
|
107
|
+
reasoning: reasoningText
|
|
108
|
+
};
|
|
93
109
|
}
|
|
94
110
|
sanitizeSchema(schema) {
|
|
95
111
|
if (typeof schema !== "object" || schema === null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AASxD,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AASxD,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;IA+K7F,OAAO,CAAC,cAAc;CAyBvB"}
|
|
@@ -28,10 +28,20 @@ export class GeminiStreaming {
|
|
|
28
28
|
generationConfig.responseSchema = this.sanitizeSchema(request.response_format.json_schema.schema);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
const { model: _model, messages: _messages, tools: _tools, temperature: _temp, max_tokens: _max, response_format: _format, headers: _headers, requestTimeout: _requestTimeout, thinking: _thinking, ...rest } = request;
|
|
31
32
|
const payload = {
|
|
32
33
|
contents,
|
|
33
|
-
generationConfig
|
|
34
|
+
generationConfig: {
|
|
35
|
+
...generationConfig,
|
|
36
|
+
...(rest.generationConfig || {})
|
|
37
|
+
},
|
|
38
|
+
...rest
|
|
34
39
|
};
|
|
40
|
+
if (_thinking) {
|
|
41
|
+
payload.thinkingConfig = {
|
|
42
|
+
includeThoughts: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
35
45
|
if (systemInstructionParts.length > 0) {
|
|
36
46
|
payload.systemInstruction = { parts: systemInstructionParts };
|
|
37
47
|
}
|
|
@@ -98,7 +108,12 @@ export class GeminiStreaming {
|
|
|
98
108
|
const parts = json.candidates?.[0]?.content?.parts || [];
|
|
99
109
|
for (const part of parts) {
|
|
100
110
|
if (part.text) {
|
|
101
|
-
|
|
111
|
+
if (part.thought) {
|
|
112
|
+
yield { content: "", thinking: { text: part.text } };
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
yield { content: part.text };
|
|
116
|
+
}
|
|
102
117
|
}
|
|
103
118
|
// Handle function calls
|
|
104
119
|
if (part.functionCall) {
|
|
@@ -12,6 +12,7 @@ export interface GeminiPart {
|
|
|
12
12
|
name: string;
|
|
13
13
|
response: Record<string, unknown>;
|
|
14
14
|
};
|
|
15
|
+
thought?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export interface GeminiContent {
|
|
17
18
|
role?: "user" | "model";
|
|
@@ -42,6 +43,9 @@ export interface GeminiGenerateContentRequest {
|
|
|
42
43
|
category: string;
|
|
43
44
|
threshold: string;
|
|
44
45
|
}>;
|
|
46
|
+
thinkingConfig?: {
|
|
47
|
+
includeThoughts: boolean;
|
|
48
|
+
};
|
|
45
49
|
}
|
|
46
50
|
export interface GeminiGenerateContentResponse {
|
|
47
51
|
candidates?: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,CAAC;IACF,gBAAgB,CAAC,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,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AAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAGd,aAAa,EAAE,cAAc,GAAG,MAAM,EACtC,MAAM,EAAE,MAAM;IAK3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAGd,aAAa,EAAE,cAAc,GAAG,MAAM,EACtC,MAAM,EAAE,MAAM;IAK3B,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CA+G3D"}
|
|
@@ -21,7 +21,7 @@ export class OpenAIChat {
|
|
|
21
21
|
(typeof this.providerOrUrl === "string"
|
|
22
22
|
? Capabilities.supportsDeveloperRole(request.model)
|
|
23
23
|
: this.providerOrUrl.capabilities?.supportsDeveloperRole(request.model));
|
|
24
|
-
const { model, messages, tools, temperature: _, max_tokens, response_format, headers: _headers, requestTimeout: _requestTimeout, signal, ...rest } = request;
|
|
24
|
+
const { model, messages, tools, temperature: _, max_tokens, response_format, thinking, headers: _headers, requestTimeout: _requestTimeout, signal, ...rest } = request;
|
|
25
25
|
const mappedMessages = mapSystemMessages(messages, !!supportsDeveloperRole);
|
|
26
26
|
const body = {
|
|
27
27
|
model,
|
|
@@ -42,6 +42,9 @@ export class OpenAIChat {
|
|
|
42
42
|
body.tools = tools;
|
|
43
43
|
if (response_format)
|
|
44
44
|
body.response_format = response_format;
|
|
45
|
+
if (thinking?.effort && thinking.effort !== "none") {
|
|
46
|
+
body.reasoning_effort = thinking.effort;
|
|
47
|
+
}
|
|
45
48
|
const url = buildUrl(this.baseUrl, "/chat/completions");
|
|
46
49
|
logger.logRequest("OpenAI", "POST", url, body);
|
|
47
50
|
const response = await fetchWithTimeout(url, {
|
|
@@ -62,7 +65,7 @@ export class OpenAIChat {
|
|
|
62
65
|
const message = json.choices[0]?.message;
|
|
63
66
|
const content = message?.content ?? null;
|
|
64
67
|
const tool_calls = message?.tool_calls;
|
|
65
|
-
const
|
|
68
|
+
const reasoningText = message?.reasoning_content || null;
|
|
66
69
|
const usage = json.usage
|
|
67
70
|
? {
|
|
68
71
|
input_tokens: json.usage.prompt_tokens,
|
|
@@ -72,10 +75,22 @@ export class OpenAIChat {
|
|
|
72
75
|
reasoning_tokens: json.usage.completion_tokens_details?.reasoning_tokens
|
|
73
76
|
}
|
|
74
77
|
: undefined;
|
|
78
|
+
const thinkingResult = reasoningText || usage?.reasoning_tokens
|
|
79
|
+
? {
|
|
80
|
+
text: reasoningText || undefined,
|
|
81
|
+
tokens: usage?.reasoning_tokens
|
|
82
|
+
}
|
|
83
|
+
: undefined;
|
|
75
84
|
if (!content && !tool_calls) {
|
|
76
85
|
throw new Error("OpenAI returned empty response");
|
|
77
86
|
}
|
|
78
87
|
const calculatedUsage = usage ? ModelRegistry.calculateCost(usage, model, "openai") : undefined;
|
|
79
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
content,
|
|
90
|
+
tool_calls,
|
|
91
|
+
usage: calculatedUsage,
|
|
92
|
+
thinking: thinkingResult,
|
|
93
|
+
reasoning: reasoningText
|
|
94
|
+
};
|
|
80
95
|
}
|
|
81
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAGd,aAAa,EAAE,cAAc,GAAG,MAAM,EACtC,MAAM,EAAE,MAAM;IAK1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Streaming.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/Streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAGd,aAAa,EAAE,cAAc,GAAG,MAAM,EACtC,MAAM,EAAE,MAAM;IAK1B,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,CAAC;CAoM9F"}
|
|
@@ -15,8 +15,9 @@ export class OpenAIStreaming {
|
|
|
15
15
|
this.baseUrl = typeof providerOrUrl === "string" ? providerOrUrl : providerOrUrl.apiBase();
|
|
16
16
|
}
|
|
17
17
|
async *execute(request, controller) {
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const internalController = new AbortController();
|
|
19
|
+
const abortController = controller || internalController;
|
|
20
|
+
const signal = request.signal ? request.signal : abortController.signal;
|
|
20
21
|
const temperature = Capabilities.normalizeTemperature(request.temperature, request.model);
|
|
21
22
|
const isMainOpenAI = this.baseUrl.includes("api.openai.com");
|
|
22
23
|
const supportsDeveloperRole = isMainOpenAI &&
|
|
@@ -46,6 +47,9 @@ export class OpenAIStreaming {
|
|
|
46
47
|
if (request.tools && request.tools.length > 0) {
|
|
47
48
|
body.tools = request.tools;
|
|
48
49
|
}
|
|
50
|
+
if (request.thinking?.effort && request.thinking.effort !== "none") {
|
|
51
|
+
body.reasoning_effort = request.thinking.effort;
|
|
52
|
+
}
|
|
49
53
|
let done = false;
|
|
50
54
|
// Track tool calls being built across chunks
|
|
51
55
|
const toolCallsMap = new Map();
|
|
@@ -60,7 +64,7 @@ export class OpenAIStreaming {
|
|
|
60
64
|
...request.headers
|
|
61
65
|
},
|
|
62
66
|
body: JSON.stringify(body),
|
|
63
|
-
signal
|
|
67
|
+
signal
|
|
64
68
|
}, request.requestTimeout);
|
|
65
69
|
if (!response.ok) {
|
|
66
70
|
await handleOpenAIError(response, request.model);
|
|
@@ -119,6 +123,10 @@ export class OpenAIStreaming {
|
|
|
119
123
|
if (delta?.content) {
|
|
120
124
|
yield { content: delta.content };
|
|
121
125
|
}
|
|
126
|
+
// Handle reasoning content delta
|
|
127
|
+
if (delta?.reasoning_content) {
|
|
128
|
+
yield { content: "", thinking: { text: delta.reasoning_content } };
|
|
129
|
+
}
|
|
122
130
|
// Handle tool calls delta
|
|
123
131
|
if (delta?.tool_calls) {
|
|
124
132
|
for (const toolCallDelta of delta.tool_calls) {
|