@jaypie/llm 1.2.19 → 1.2.21
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/cjs/constants.d.ts +31 -31
- package/dist/cjs/index.cjs +47 -28
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/adapters/AnthropicAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/GeminiAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/OpenAiAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/OpenRouterAdapter.d.ts +1 -1
- package/dist/cjs/operate/adapters/XaiAdapter.d.ts +1 -1
- package/dist/esm/constants.d.ts +31 -31
- package/dist/esm/index.js +47 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/AnthropicAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/GeminiAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/OpenAiAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/OpenRouterAdapter.d.ts +1 -1
- package/dist/esm/operate/adapters/XaiAdapter.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class AnthropicAdapter extends BaseProviderAdapter {
|
|
15
15
|
readonly name: "anthropic";
|
|
16
|
-
readonly defaultModel: "claude-sonnet-4-
|
|
16
|
+
readonly defaultModel: "claude-sonnet-4-6";
|
|
17
17
|
buildRequest(request: OperateRequest): Anthropic.MessageCreateParams;
|
|
18
18
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
19
19
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -13,7 +13,7 @@ import { GeminiPart, GeminiRawResponse, GeminiRequest } from "../../providers/ge
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class GeminiAdapter extends BaseProviderAdapter {
|
|
15
15
|
readonly name: "google";
|
|
16
|
-
readonly defaultModel: "gemini-3-pro-preview";
|
|
16
|
+
readonly defaultModel: "gemini-3.1-pro-preview";
|
|
17
17
|
buildRequest(request: OperateRequest): GeminiRequest;
|
|
18
18
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
19
19
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -12,7 +12,7 @@ import { BaseProviderAdapter } from "./ProviderAdapter.interface.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class OpenAiAdapter extends BaseProviderAdapter {
|
|
14
14
|
readonly name: "openai";
|
|
15
|
-
readonly defaultModel: "gpt-5.
|
|
15
|
+
readonly defaultModel: "gpt-5.4";
|
|
16
16
|
buildRequest(request: OperateRequest): unknown;
|
|
17
17
|
formatTools(toolkit: Toolkit, _outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
18
18
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -84,7 +84,7 @@ type OpenRouterContentPart = {
|
|
|
84
84
|
*/
|
|
85
85
|
export declare class OpenRouterAdapter extends BaseProviderAdapter {
|
|
86
86
|
readonly name: "openrouter";
|
|
87
|
-
readonly defaultModel: "
|
|
87
|
+
readonly defaultModel: "anthropic/claude-sonnet-4-6";
|
|
88
88
|
buildRequest(request: OperateRequest): OpenRouterRequest;
|
|
89
89
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
|
90
90
|
formatOutputSchema(schema: JsonObject | NaturalSchema | z.ZodType): JsonObject;
|
|
@@ -6,6 +6,6 @@ import { OpenAiAdapter } from "./OpenAiAdapter.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class XaiAdapter extends OpenAiAdapter {
|
|
8
8
|
readonly name: "xai";
|
|
9
|
-
readonly defaultModel: "grok-4-
|
|
9
|
+
readonly defaultModel: "grok-4.20-0309-reasoning";
|
|
10
10
|
}
|
|
11
11
|
export declare const xaiAdapter: XaiAdapter;
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export declare const PROVIDER: {
|
|
|
4
4
|
readonly DEFAULT: 4096;
|
|
5
5
|
};
|
|
6
6
|
readonly MODEL: {
|
|
7
|
-
readonly DEFAULT: "claude-sonnet-4-
|
|
8
|
-
readonly LARGE: "claude-opus-4-
|
|
9
|
-
readonly SMALL: "claude-sonnet-4-
|
|
7
|
+
readonly DEFAULT: "claude-sonnet-4-6";
|
|
8
|
+
readonly LARGE: "claude-opus-4-6";
|
|
9
|
+
readonly SMALL: "claude-sonnet-4-6";
|
|
10
10
|
readonly TINY: "claude-haiku-4-5";
|
|
11
11
|
};
|
|
12
12
|
readonly MODEL_MATCH_WORDS: readonly ["anthropic", "claude", "haiku", "opus", "sonnet"];
|
|
@@ -26,10 +26,10 @@ export declare const PROVIDER: {
|
|
|
26
26
|
};
|
|
27
27
|
readonly GEMINI: {
|
|
28
28
|
readonly MODEL: {
|
|
29
|
-
readonly DEFAULT: "gemini-3-pro-preview";
|
|
30
|
-
readonly LARGE: "gemini-3-pro-preview";
|
|
29
|
+
readonly DEFAULT: "gemini-3.1-pro-preview";
|
|
30
|
+
readonly LARGE: "gemini-3.1-pro-preview";
|
|
31
31
|
readonly SMALL: "gemini-3-flash-preview";
|
|
32
|
-
readonly TINY: "gemini-3-flash-preview";
|
|
32
|
+
readonly TINY: "gemini-3.1-flash-lite-preview";
|
|
33
33
|
};
|
|
34
34
|
readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
|
|
35
35
|
readonly NAME: "google";
|
|
@@ -40,20 +40,20 @@ export declare const PROVIDER: {
|
|
|
40
40
|
};
|
|
41
41
|
readonly OPENAI: {
|
|
42
42
|
readonly MODEL: {
|
|
43
|
-
readonly DEFAULT: "gpt-5.
|
|
44
|
-
readonly LARGE: "gpt-5.
|
|
45
|
-
readonly SMALL: "gpt-5-mini";
|
|
46
|
-
readonly TINY: "gpt-5-nano";
|
|
43
|
+
readonly DEFAULT: "gpt-5.4";
|
|
44
|
+
readonly LARGE: "gpt-5.4";
|
|
45
|
+
readonly SMALL: "gpt-5.4-mini";
|
|
46
|
+
readonly TINY: "gpt-5.4-nano";
|
|
47
47
|
};
|
|
48
48
|
readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
|
|
49
49
|
readonly NAME: "openai";
|
|
50
50
|
};
|
|
51
51
|
readonly OPENROUTER: {
|
|
52
52
|
readonly MODEL: {
|
|
53
|
-
readonly DEFAULT: "
|
|
54
|
-
readonly LARGE: "
|
|
55
|
-
readonly SMALL: "
|
|
56
|
-
readonly TINY: "
|
|
53
|
+
readonly DEFAULT: "anthropic/claude-sonnet-4-6";
|
|
54
|
+
readonly LARGE: "anthropic/claude-opus-4-6";
|
|
55
|
+
readonly SMALL: "anthropic/claude-sonnet-4-6";
|
|
56
|
+
readonly TINY: "anthropic/claude-haiku-4-5";
|
|
57
57
|
};
|
|
58
58
|
readonly MODEL_MATCH_WORDS: readonly ["openrouter"];
|
|
59
59
|
readonly NAME: "openrouter";
|
|
@@ -68,10 +68,10 @@ export declare const PROVIDER: {
|
|
|
68
68
|
readonly API_KEY: "XAI_API_KEY";
|
|
69
69
|
readonly BASE_URL: "https://api.x.ai/v1";
|
|
70
70
|
readonly MODEL: {
|
|
71
|
-
readonly DEFAULT: "grok-4-
|
|
72
|
-
readonly LARGE: "grok-4-
|
|
73
|
-
readonly SMALL: "grok-
|
|
74
|
-
readonly TINY: "grok-
|
|
71
|
+
readonly DEFAULT: "grok-4.20-0309-reasoning";
|
|
72
|
+
readonly LARGE: "grok-4.20-0309-reasoning";
|
|
73
|
+
readonly SMALL: "grok-4.20-0309-non-reasoning";
|
|
74
|
+
readonly TINY: "grok-4-1-fast-non-reasoning";
|
|
75
75
|
};
|
|
76
76
|
readonly MODEL_MATCH_WORDS: readonly ["grok", "xai"];
|
|
77
77
|
readonly NAME: "xai";
|
|
@@ -80,26 +80,26 @@ export declare const PROVIDER: {
|
|
|
80
80
|
export type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.GEMINI.NAME | typeof PROVIDER.OPENAI.NAME | typeof PROVIDER.OPENROUTER.NAME | typeof PROVIDER.XAI.NAME;
|
|
81
81
|
export declare const DEFAULT: {
|
|
82
82
|
readonly MODEL: {
|
|
83
|
-
readonly BASE: "gpt-5.
|
|
84
|
-
readonly LARGE: "gpt-5.
|
|
85
|
-
readonly SMALL: "gpt-5-mini";
|
|
86
|
-
readonly TINY: "gpt-5-nano";
|
|
83
|
+
readonly BASE: "gpt-5.4";
|
|
84
|
+
readonly LARGE: "gpt-5.4";
|
|
85
|
+
readonly SMALL: "gpt-5.4-mini";
|
|
86
|
+
readonly TINY: "gpt-5.4-nano";
|
|
87
87
|
};
|
|
88
88
|
readonly PROVIDER: {
|
|
89
89
|
readonly MODEL: {
|
|
90
|
-
readonly DEFAULT: "gpt-5.
|
|
91
|
-
readonly LARGE: "gpt-5.
|
|
92
|
-
readonly SMALL: "gpt-5-mini";
|
|
93
|
-
readonly TINY: "gpt-5-nano";
|
|
90
|
+
readonly DEFAULT: "gpt-5.4";
|
|
91
|
+
readonly LARGE: "gpt-5.4";
|
|
92
|
+
readonly SMALL: "gpt-5.4-mini";
|
|
93
|
+
readonly TINY: "gpt-5.4-nano";
|
|
94
94
|
};
|
|
95
95
|
readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
|
|
96
96
|
readonly NAME: "openai";
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
export declare const ALL: {
|
|
100
|
-
readonly BASE: readonly ["claude-sonnet-4-
|
|
101
|
-
readonly COMBINED: readonly ["claude-sonnet-4-
|
|
102
|
-
readonly LARGE: readonly ["claude-opus-4-
|
|
103
|
-
readonly SMALL: readonly ["claude-sonnet-4-
|
|
104
|
-
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3-flash-preview", "gpt-5-nano", "grok-
|
|
100
|
+
readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-4.20-0309-reasoning"];
|
|
101
|
+
readonly COMBINED: readonly ["claude-sonnet-4-6", "claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5", "gemini-3.1-pro-preview", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-3.1-flash-lite-preview", "gpt-5.4", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "grok-4.20-0309-reasoning", "grok-4.20-0309-reasoning", "grok-4.20-0309-non-reasoning", "grok-4-1-fast-non-reasoning"];
|
|
102
|
+
readonly LARGE: readonly ["claude-opus-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-4.20-0309-reasoning"];
|
|
103
|
+
readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3-flash-preview", "gpt-5.4-mini", "grok-4.20-0309-non-reasoning"];
|
|
104
|
+
readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite-preview", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
|
|
105
105
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -12,35 +12,33 @@ import { getS3FileBuffer, getEnvSecret } from '@jaypie/aws';
|
|
|
12
12
|
import { fetchWeatherApi } from 'openmeteo';
|
|
13
13
|
|
|
14
14
|
const FIRST_CLASS_PROVIDER = {
|
|
15
|
+
// https://docs.anthropic.com/en/docs/about-claude/models/overview
|
|
15
16
|
ANTHROPIC: {
|
|
16
|
-
DEFAULT: "claude-sonnet-4-
|
|
17
|
-
LARGE: "claude-opus-4-
|
|
18
|
-
SMALL: "claude-sonnet-4-
|
|
17
|
+
DEFAULT: "claude-sonnet-4-6",
|
|
18
|
+
LARGE: "claude-opus-4-6",
|
|
19
|
+
SMALL: "claude-sonnet-4-6",
|
|
19
20
|
TINY: "claude-haiku-4-5",
|
|
20
21
|
},
|
|
22
|
+
// https://ai.google.dev/gemini-api/docs/models
|
|
21
23
|
GEMINI: {
|
|
22
|
-
DEFAULT: "gemini-3-pro-preview",
|
|
23
|
-
LARGE: "gemini-3-pro-preview",
|
|
24
|
+
DEFAULT: "gemini-3.1-pro-preview",
|
|
25
|
+
LARGE: "gemini-3.1-pro-preview",
|
|
24
26
|
SMALL: "gemini-3-flash-preview",
|
|
25
|
-
TINY: "gemini-3-flash-preview",
|
|
27
|
+
TINY: "gemini-3.1-flash-lite-preview",
|
|
26
28
|
},
|
|
29
|
+
// https://developers.openai.com/api/docs/models
|
|
27
30
|
OPENAI: {
|
|
28
|
-
DEFAULT: "gpt-5.
|
|
29
|
-
LARGE: "gpt-5.
|
|
30
|
-
SMALL: "gpt-5-mini",
|
|
31
|
-
TINY: "gpt-5-nano",
|
|
32
|
-
},
|
|
33
|
-
OPENROUTER: {
|
|
34
|
-
DEFAULT: "z-ai/glm-4.7",
|
|
35
|
-
LARGE: "z-ai/glm-4.7",
|
|
36
|
-
SMALL: "z-ai/glm-4.7",
|
|
37
|
-
TINY: "z-ai/glm-4.7",
|
|
31
|
+
DEFAULT: "gpt-5.4",
|
|
32
|
+
LARGE: "gpt-5.4",
|
|
33
|
+
SMALL: "gpt-5.4-mini",
|
|
34
|
+
TINY: "gpt-5.4-nano",
|
|
38
35
|
},
|
|
36
|
+
// https://docs.x.ai/developers/models
|
|
39
37
|
XAI: {
|
|
40
|
-
DEFAULT: "grok-4-
|
|
41
|
-
LARGE: "grok-4-
|
|
42
|
-
SMALL: "grok-
|
|
43
|
-
TINY: "grok-
|
|
38
|
+
DEFAULT: "grok-4.20-0309-reasoning",
|
|
39
|
+
LARGE: "grok-4.20-0309-reasoning",
|
|
40
|
+
SMALL: "grok-4.20-0309-non-reasoning",
|
|
41
|
+
TINY: "grok-4-1-fast-non-reasoning",
|
|
44
42
|
},
|
|
45
43
|
};
|
|
46
44
|
const PROVIDER = {
|
|
@@ -103,15 +101,11 @@ const PROVIDER = {
|
|
|
103
101
|
NAME: "openai",
|
|
104
102
|
},
|
|
105
103
|
OPENROUTER: {
|
|
106
|
-
// https://openrouter.ai/models
|
|
107
|
-
// OpenRouter provides access to hundreds of models from various providers
|
|
108
|
-
// The model format is: provider/model-name (e.g., "openai/gpt-4", "anthropic/claude-3-opus")
|
|
109
104
|
MODEL: {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
TINY: FIRST_CLASS_PROVIDER.OPENROUTER.TINY,
|
|
105
|
+
DEFAULT: `anthropic/${FIRST_CLASS_PROVIDER.ANTHROPIC.DEFAULT}`,
|
|
106
|
+
LARGE: `anthropic/${FIRST_CLASS_PROVIDER.ANTHROPIC.LARGE}`,
|
|
107
|
+
SMALL: `anthropic/${FIRST_CLASS_PROVIDER.ANTHROPIC.SMALL}`,
|
|
108
|
+
TINY: `anthropic/${FIRST_CLASS_PROVIDER.ANTHROPIC.TINY}`,
|
|
115
109
|
},
|
|
116
110
|
MODEL_MATCH_WORDS: ["openrouter"],
|
|
117
111
|
NAME: "openrouter",
|
|
@@ -4425,6 +4419,19 @@ class OperateLoop {
|
|
|
4425
4419
|
status: jaypieError.status,
|
|
4426
4420
|
title: ERROR$1.BAD_FUNCTION_CALL,
|
|
4427
4421
|
});
|
|
4422
|
+
// Add error tool_result to history so the tool_use block is not orphaned.
|
|
4423
|
+
// Without this, the next turn's request would have a tool_use without a
|
|
4424
|
+
// matching tool_result, causing Anthropic API to reject with 400.
|
|
4425
|
+
const errorResult = {
|
|
4426
|
+
callId: toolCall.callId,
|
|
4427
|
+
output: JSON.stringify({
|
|
4428
|
+
error: error.message || "Tool execution failed",
|
|
4429
|
+
}),
|
|
4430
|
+
success: false,
|
|
4431
|
+
error: error.message,
|
|
4432
|
+
};
|
|
4433
|
+
const toolResultFormatted = this.adapter.formatToolResult(toolCall, errorResult);
|
|
4434
|
+
state.responseBuilder.appendToHistory(toolResultFormatted);
|
|
4428
4435
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4429
4436
|
log$1.var({ error });
|
|
4430
4437
|
}
|
|
@@ -4905,6 +4912,18 @@ class StreamLoop {
|
|
|
4905
4912
|
title: ERROR.BAD_FUNCTION_CALL,
|
|
4906
4913
|
},
|
|
4907
4914
|
};
|
|
4915
|
+
// Add error tool_result to history so the tool_use block is not orphaned.
|
|
4916
|
+
// Without this, the next turn's request would have a tool_use without a
|
|
4917
|
+
// matching tool_result, causing Anthropic API to reject with 400.
|
|
4918
|
+
const errorOutput = JSON.stringify({
|
|
4919
|
+
error: error.message || "Tool execution failed",
|
|
4920
|
+
});
|
|
4921
|
+
state.currentInput.push({
|
|
4922
|
+
type: LlmMessageType.FunctionCallOutput,
|
|
4923
|
+
output: errorOutput,
|
|
4924
|
+
call_id: toolCall.callId,
|
|
4925
|
+
name: toolCall.name,
|
|
4926
|
+
});
|
|
4908
4927
|
log$1.error(`Error executing function call ${toolCall.name}`);
|
|
4909
4928
|
log$1.var({ error });
|
|
4910
4929
|
}
|