@jaypie/llm 1.1.23 → 1.1.25
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/Llm.d.ts +4 -4
- package/dist/constants.d.ts +22 -15
- package/dist/index.d.ts +3 -2
- package/dist/index.js +177 -21
- package/dist/index.js.map +1 -1
- package/dist/providers/openai/types.d.ts +9 -1
- package/dist/tools/index.d.ts +10 -2
- package/dist/types/LlmProvider.interface.d.ts +6 -6
- package/dist/util/determineModelProvider.d.ts +4 -0
- package/dist/util/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/Llm.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { JsonObject } from "@jaypie/types";
|
|
2
2
|
import { LlmProviderName } from "./constants.js";
|
|
3
|
-
import { LlmProvider, LlmMessageOptions, LlmOperateOptions, LlmOptions, LlmOperateResponse } from "./types/LlmProvider.interface.js";
|
|
3
|
+
import { LlmProvider, LlmHistory, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOptions, LlmOperateResponse } from "./types/LlmProvider.interface.js";
|
|
4
4
|
declare class Llm implements LlmProvider {
|
|
5
5
|
private _provider;
|
|
6
6
|
private _llm;
|
|
7
7
|
private _options;
|
|
8
|
-
constructor(providerName?: LlmProviderName, options?: LlmOptions);
|
|
8
|
+
constructor(providerName?: LlmProviderName | string, options?: LlmOptions);
|
|
9
9
|
private createProvider;
|
|
10
10
|
send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
|
|
11
|
-
operate(
|
|
11
|
+
operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
|
|
12
12
|
static send(message: string, options?: LlmMessageOptions & {
|
|
13
13
|
llm?: LlmProviderName;
|
|
14
14
|
apiKey?: string;
|
|
15
15
|
model?: string;
|
|
16
16
|
}): Promise<string | JsonObject>;
|
|
17
|
-
static operate(
|
|
17
|
+
static operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions & {
|
|
18
18
|
llm?: LlmProviderName;
|
|
19
19
|
apiKey?: string;
|
|
20
20
|
model?: string;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export declare const PROVIDER: {
|
|
2
2
|
readonly ANTHROPIC: {
|
|
3
3
|
readonly MODEL: {
|
|
4
|
-
readonly DEFAULT: "claude-
|
|
5
|
-
readonly SMALL: "claude-
|
|
4
|
+
readonly DEFAULT: "claude-opus-4-1";
|
|
5
|
+
readonly SMALL: "claude-sonnet-4-0";
|
|
6
6
|
readonly TINY: "claude-3-5-haiku-latest";
|
|
7
|
-
readonly LARGE: "claude-opus-4-
|
|
8
|
-
readonly
|
|
9
|
-
readonly CLAUDE_OPUS_4: "claude-opus-4-0";
|
|
7
|
+
readonly LARGE: "claude-opus-4-1";
|
|
8
|
+
readonly CLAUDE_OPUS_4: "claude-opus-4-1";
|
|
10
9
|
readonly CLAUDE_SONNET_4: "claude-sonnet-4-0";
|
|
11
10
|
readonly CLAUDE_3_HAIKU: "claude-3-5-haiku-latest";
|
|
12
11
|
readonly CLAUDE_3_OPUS: "claude-3-opus-latest";
|
|
13
12
|
readonly CLAUDE_3_SONNET: "claude-3-7-sonnet-latest";
|
|
13
|
+
readonly CLAUDE_OPUS_4_1: "claude-opus-4-1";
|
|
14
14
|
readonly CLAUDE_OPUS_4_0: "claude-opus-4-0";
|
|
15
15
|
readonly CLAUDE_SONNET_4_0: "claude-sonnet-4-0";
|
|
16
16
|
readonly CLAUDE_3_7_SONNET: "claude-3-7-sonnet-latest\t";
|
|
@@ -20,6 +20,7 @@ export declare const PROVIDER: {
|
|
|
20
20
|
readonly CLAUDE_OPUS_3: "claude-3-opus-latest";
|
|
21
21
|
readonly CLAUDE_SONNET_3: "claude-3-7-sonnet-latest";
|
|
22
22
|
};
|
|
23
|
+
readonly MODEL_MATCH_WORDS: readonly ["anthropic", "claude", "haiku", "opus", "sonnet"];
|
|
23
24
|
readonly NAME: "anthropic";
|
|
24
25
|
readonly PROMPT: {
|
|
25
26
|
readonly AI: "\n\nAssistant:";
|
|
@@ -39,11 +40,13 @@ export declare const PROVIDER: {
|
|
|
39
40
|
};
|
|
40
41
|
readonly OPENAI: {
|
|
41
42
|
readonly MODEL: {
|
|
42
|
-
readonly DEFAULT: "gpt-
|
|
43
|
-
readonly SMALL: "gpt-
|
|
44
|
-
readonly LARGE: "
|
|
45
|
-
readonly TINY: "gpt-
|
|
46
|
-
readonly
|
|
43
|
+
readonly DEFAULT: "gpt-5";
|
|
44
|
+
readonly SMALL: "gpt-5-mini";
|
|
45
|
+
readonly LARGE: "gpt-5";
|
|
46
|
+
readonly TINY: "gpt-5-nano";
|
|
47
|
+
readonly GPT_5: "gpt-5";
|
|
48
|
+
readonly GPT_5_MINI: "gpt-5-mini";
|
|
49
|
+
readonly GPT_5_NANO: "gpt-5-nano";
|
|
47
50
|
readonly GPT_4_1: "gpt-4.1";
|
|
48
51
|
readonly GPT_4_1_MINI: "gpt-4.1-mini";
|
|
49
52
|
readonly GPT_4_1_NANO: "gpt-4.1-nano";
|
|
@@ -60,6 +63,7 @@ export declare const PROVIDER: {
|
|
|
60
63
|
readonly O3_PRO: "o3-pro";
|
|
61
64
|
readonly O4_MINI: "o4-mini";
|
|
62
65
|
};
|
|
66
|
+
readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
|
|
63
67
|
readonly NAME: "openai";
|
|
64
68
|
};
|
|
65
69
|
};
|
|
@@ -67,11 +71,13 @@ export type LlmProviderName = typeof PROVIDER.OPENAI.NAME | typeof PROVIDER.ANTH
|
|
|
67
71
|
export declare const DEFAULT: {
|
|
68
72
|
readonly PROVIDER: {
|
|
69
73
|
readonly MODEL: {
|
|
70
|
-
readonly DEFAULT: "gpt-
|
|
71
|
-
readonly SMALL: "gpt-
|
|
72
|
-
readonly LARGE: "
|
|
73
|
-
readonly TINY: "gpt-
|
|
74
|
-
readonly
|
|
74
|
+
readonly DEFAULT: "gpt-5";
|
|
75
|
+
readonly SMALL: "gpt-5-mini";
|
|
76
|
+
readonly LARGE: "gpt-5";
|
|
77
|
+
readonly TINY: "gpt-5-nano";
|
|
78
|
+
readonly GPT_5: "gpt-5";
|
|
79
|
+
readonly GPT_5_MINI: "gpt-5-mini";
|
|
80
|
+
readonly GPT_5_NANO: "gpt-5-nano";
|
|
75
81
|
readonly GPT_4_1: "gpt-4.1";
|
|
76
82
|
readonly GPT_4_1_MINI: "gpt-4.1-mini";
|
|
77
83
|
readonly GPT_4_1_NANO: "gpt-4.1-nano";
|
|
@@ -88,6 +94,7 @@ export declare const DEFAULT: {
|
|
|
88
94
|
readonly O3_PRO: "o3-pro";
|
|
89
95
|
readonly O4_MINI: "o4-mini";
|
|
90
96
|
};
|
|
97
|
+
readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
|
|
91
98
|
readonly NAME: "openai";
|
|
92
99
|
};
|
|
93
100
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Llm } from "./Llm.js";
|
|
2
2
|
export * as LLM from "./constants.js";
|
|
3
|
-
export type { LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
3
|
+
export type { LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, } from "./types/LlmProvider.interface.js";
|
|
4
|
+
export { LlmMessageRole, LlmMessageType, } from "./types/LlmProvider.interface.js";
|
|
4
5
|
export type { LlmTool } from "./types/LlmTool.interface.js";
|
|
5
|
-
export { toolkit, Toolkit, tools } from "./tools/index.js";
|
|
6
|
+
export { JaypieToolkit, toolkit, Toolkit, tools } from "./tools/index.js";
|
package/dist/index.js
CHANGED
|
@@ -14,18 +14,18 @@ const PROVIDER = {
|
|
|
14
14
|
// https://docs.anthropic.com/en/docs/about-claude/models/overview
|
|
15
15
|
MODEL: {
|
|
16
16
|
// Jaypie Aliases
|
|
17
|
-
DEFAULT: "claude-
|
|
18
|
-
SMALL: "claude-
|
|
17
|
+
DEFAULT: "claude-opus-4-1",
|
|
18
|
+
SMALL: "claude-sonnet-4-0",
|
|
19
19
|
TINY: "claude-3-5-haiku-latest",
|
|
20
|
-
LARGE: "claude-opus-4-
|
|
21
|
-
JUMBO: "claude-opus-4-0",
|
|
20
|
+
LARGE: "claude-opus-4-1",
|
|
22
21
|
// Latests
|
|
23
|
-
CLAUDE_OPUS_4: "claude-opus-4-
|
|
22
|
+
CLAUDE_OPUS_4: "claude-opus-4-1",
|
|
24
23
|
CLAUDE_SONNET_4: "claude-sonnet-4-0",
|
|
25
24
|
CLAUDE_3_HAIKU: "claude-3-5-haiku-latest",
|
|
26
25
|
CLAUDE_3_OPUS: "claude-3-opus-latest",
|
|
27
26
|
CLAUDE_3_SONNET: "claude-3-7-sonnet-latest",
|
|
28
27
|
// Specifics
|
|
28
|
+
CLAUDE_OPUS_4_1: "claude-opus-4-1",
|
|
29
29
|
CLAUDE_OPUS_4_0: "claude-opus-4-0",
|
|
30
30
|
CLAUDE_SONNET_4_0: "claude-sonnet-4-0",
|
|
31
31
|
CLAUDE_3_7_SONNET: "claude-3-7-sonnet-latest ",
|
|
@@ -37,6 +37,13 @@ const PROVIDER = {
|
|
|
37
37
|
CLAUDE_OPUS_3: "claude-3-opus-latest",
|
|
38
38
|
CLAUDE_SONNET_3: "claude-3-7-sonnet-latest",
|
|
39
39
|
},
|
|
40
|
+
MODEL_MATCH_WORDS: [
|
|
41
|
+
"anthropic",
|
|
42
|
+
"claude",
|
|
43
|
+
"haiku",
|
|
44
|
+
"opus",
|
|
45
|
+
"sonnet",
|
|
46
|
+
],
|
|
40
47
|
NAME: "anthropic",
|
|
41
48
|
PROMPT: {
|
|
42
49
|
AI: "\n\nAssistant:",
|
|
@@ -58,12 +65,14 @@ const PROVIDER = {
|
|
|
58
65
|
// https://platform.openai.com/docs/models
|
|
59
66
|
MODEL: {
|
|
60
67
|
// Jaypie Aliases
|
|
61
|
-
DEFAULT: "gpt-
|
|
62
|
-
SMALL: "gpt-
|
|
63
|
-
LARGE: "
|
|
64
|
-
TINY: "gpt-
|
|
65
|
-
JUMBO: "o3-pro",
|
|
68
|
+
DEFAULT: "gpt-5",
|
|
69
|
+
SMALL: "gpt-5-mini",
|
|
70
|
+
LARGE: "gpt-5",
|
|
71
|
+
TINY: "gpt-5-nano",
|
|
66
72
|
// OpenAI Official
|
|
73
|
+
GPT_5: "gpt-5",
|
|
74
|
+
GPT_5_MINI: "gpt-5-mini",
|
|
75
|
+
GPT_5_NANO: "gpt-5-nano",
|
|
67
76
|
GPT_4_1: "gpt-4.1",
|
|
68
77
|
GPT_4_1_MINI: "gpt-4.1-mini",
|
|
69
78
|
GPT_4_1_NANO: "gpt-4.1-nano",
|
|
@@ -80,6 +89,7 @@ const PROVIDER = {
|
|
|
80
89
|
O3_PRO: "o3-pro",
|
|
81
90
|
O4_MINI: "o4-mini",
|
|
82
91
|
},
|
|
92
|
+
MODEL_MATCH_WORDS: ["openai", "gpt", /^o\d/],
|
|
83
93
|
NAME: "openai",
|
|
84
94
|
},
|
|
85
95
|
};
|
|
@@ -94,6 +104,79 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
94
104
|
PROVIDER: PROVIDER
|
|
95
105
|
});
|
|
96
106
|
|
|
107
|
+
function determineModelProvider(input) {
|
|
108
|
+
if (!input) {
|
|
109
|
+
return {
|
|
110
|
+
model: DEFAULT.PROVIDER.MODEL.DEFAULT,
|
|
111
|
+
provider: DEFAULT.PROVIDER.NAME,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Check if input is a provider name
|
|
115
|
+
if (input === PROVIDER.ANTHROPIC.NAME) {
|
|
116
|
+
return {
|
|
117
|
+
model: PROVIDER.ANTHROPIC.MODEL.DEFAULT,
|
|
118
|
+
provider: PROVIDER.ANTHROPIC.NAME,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (input === PROVIDER.OPENAI.NAME) {
|
|
122
|
+
return {
|
|
123
|
+
model: PROVIDER.OPENAI.MODEL.DEFAULT,
|
|
124
|
+
provider: PROVIDER.OPENAI.NAME,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Check if input matches an Anthropic model exactly
|
|
128
|
+
for (const [, modelValue] of Object.entries(PROVIDER.ANTHROPIC.MODEL)) {
|
|
129
|
+
if (input === modelValue) {
|
|
130
|
+
return {
|
|
131
|
+
model: input,
|
|
132
|
+
provider: PROVIDER.ANTHROPIC.NAME,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Check if input matches an OpenAI model exactly
|
|
137
|
+
for (const [, modelValue] of Object.entries(PROVIDER.OPENAI.MODEL)) {
|
|
138
|
+
if (input === modelValue) {
|
|
139
|
+
return {
|
|
140
|
+
model: input,
|
|
141
|
+
provider: PROVIDER.OPENAI.NAME,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Check Anthropic match words
|
|
146
|
+
const lowerInput = input.toLowerCase();
|
|
147
|
+
for (const matchWord of PROVIDER.ANTHROPIC.MODEL_MATCH_WORDS) {
|
|
148
|
+
if (lowerInput.includes(matchWord)) {
|
|
149
|
+
return {
|
|
150
|
+
model: input,
|
|
151
|
+
provider: PROVIDER.ANTHROPIC.NAME,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Check OpenAI match words
|
|
156
|
+
for (const matchWord of PROVIDER.OPENAI.MODEL_MATCH_WORDS) {
|
|
157
|
+
if (typeof matchWord === "string") {
|
|
158
|
+
if (lowerInput.includes(matchWord)) {
|
|
159
|
+
return {
|
|
160
|
+
model: input,
|
|
161
|
+
provider: PROVIDER.OPENAI.NAME,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (matchWord instanceof RegExp) {
|
|
166
|
+
if (matchWord.test(input)) {
|
|
167
|
+
return {
|
|
168
|
+
model: input,
|
|
169
|
+
provider: PROVIDER.OPENAI.NAME,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Default fallback if model not recognized
|
|
175
|
+
return {
|
|
176
|
+
model: input,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
97
180
|
const DEFAULT_TOOL_TYPE = "function";
|
|
98
181
|
const log$1 = log$2.lib({ lib: JAYPIE.LIB.LLM });
|
|
99
182
|
function logToolMessage(message, context) {
|
|
@@ -644,6 +727,10 @@ function extractContentFromResponse(currentResponse, options) {
|
|
|
644
727
|
if (output.type === LlmMessageType.FunctionCall) {
|
|
645
728
|
return createFunctionCallContent(output);
|
|
646
729
|
}
|
|
730
|
+
// Skip reasoning items when extracting content
|
|
731
|
+
if (output.type === "reasoning") {
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
647
734
|
}
|
|
648
735
|
return "";
|
|
649
736
|
}
|
|
@@ -843,6 +930,7 @@ async function operate$1(input, options = {}, context = {
|
|
|
843
930
|
}));
|
|
844
931
|
}
|
|
845
932
|
// Use type assertion to handle the OpenAI SDK response type
|
|
933
|
+
log.trace.var({ "openai.responses.create": requestOptions });
|
|
846
934
|
const currentResponse = (await openai.responses.create(
|
|
847
935
|
// @ts-expect-error error claims missing non-required id, status
|
|
848
936
|
requestOptions));
|
|
@@ -878,12 +966,19 @@ async function operate$1(input, options = {}, context = {
|
|
|
878
966
|
}
|
|
879
967
|
// Check if we need to process function calls for multi-turn conversations
|
|
880
968
|
let hasFunctionCall = false;
|
|
969
|
+
const pendingReasoningItems = []; // Track reasoning items that need to be paired
|
|
881
970
|
try {
|
|
882
971
|
if (currentResponse.output && Array.isArray(currentResponse.output)) {
|
|
883
972
|
// New OpenAI API format with output array
|
|
884
973
|
for (const output of currentResponse.output) {
|
|
885
974
|
returnResponse.output.push(output);
|
|
886
975
|
returnResponse.history.push(output);
|
|
976
|
+
// Handle reasoning items (GPT-5)
|
|
977
|
+
if (output.type === "reasoning") {
|
|
978
|
+
// Store reasoning items to be added with their paired function calls
|
|
979
|
+
pendingReasoningItems.push(output);
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
887
982
|
if (output.type === LlmMessageType.FunctionCall) {
|
|
888
983
|
hasFunctionCall = true;
|
|
889
984
|
let toolkit;
|
|
@@ -940,6 +1035,13 @@ async function operate$1(input, options = {}, context = {
|
|
|
940
1035
|
}
|
|
941
1036
|
// Add model's function call and result
|
|
942
1037
|
if (Array.isArray(currentInput)) {
|
|
1038
|
+
// Add any pending reasoning items before the function call
|
|
1039
|
+
for (const reasoningItem of pendingReasoningItems) {
|
|
1040
|
+
currentInput.push(reasoningItem);
|
|
1041
|
+
}
|
|
1042
|
+
// Clear the pending reasoning items after adding them
|
|
1043
|
+
pendingReasoningItems.length = 0;
|
|
1044
|
+
// Add the function call
|
|
943
1045
|
currentInput.push(output);
|
|
944
1046
|
// Add function call result
|
|
945
1047
|
const functionCallOutput = {
|
|
@@ -1651,9 +1753,38 @@ class AnthropicProvider {
|
|
|
1651
1753
|
|
|
1652
1754
|
class Llm {
|
|
1653
1755
|
constructor(providerName = DEFAULT.PROVIDER.NAME, options = {}) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1756
|
+
const { model } = options;
|
|
1757
|
+
let finalProvider = providerName;
|
|
1758
|
+
let finalModel = model;
|
|
1759
|
+
if (model) {
|
|
1760
|
+
const modelDetermined = determineModelProvider(model);
|
|
1761
|
+
finalModel = modelDetermined.model;
|
|
1762
|
+
if (modelDetermined.provider) {
|
|
1763
|
+
finalProvider = modelDetermined.provider;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
// Only determine provider from providerName if we don't have a provider from model
|
|
1767
|
+
if (!model || !determineModelProvider(model).provider) {
|
|
1768
|
+
const providerDetermined = determineModelProvider(providerName);
|
|
1769
|
+
if (!providerDetermined.provider) {
|
|
1770
|
+
throw new ConfigurationError(`Unable to determine provider from: ${providerName}`);
|
|
1771
|
+
}
|
|
1772
|
+
finalProvider = providerDetermined.provider;
|
|
1773
|
+
}
|
|
1774
|
+
// Handle conflicts: if both providerName and model specify different providers
|
|
1775
|
+
if (model && providerName !== DEFAULT.PROVIDER.NAME) {
|
|
1776
|
+
const modelDetermined = determineModelProvider(model);
|
|
1777
|
+
const providerDetermined = determineModelProvider(providerName);
|
|
1778
|
+
if (modelDetermined.provider &&
|
|
1779
|
+
providerDetermined.provider &&
|
|
1780
|
+
modelDetermined.provider !== providerDetermined.provider) {
|
|
1781
|
+
// Model's provider conflicts with explicit provider, don't pass model
|
|
1782
|
+
finalModel = undefined;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
this._provider = finalProvider;
|
|
1786
|
+
this._options = { ...options, model: finalModel };
|
|
1787
|
+
this._llm = this.createProvider(finalProvider, this._options);
|
|
1657
1788
|
}
|
|
1658
1789
|
createProvider(providerName, options = {}) {
|
|
1659
1790
|
const { apiKey, model } = options;
|
|
@@ -1665,27 +1796,43 @@ class Llm {
|
|
|
1665
1796
|
case PROVIDER.ANTHROPIC.NAME:
|
|
1666
1797
|
return new AnthropicProvider(model || PROVIDER.ANTHROPIC.MODEL.DEFAULT, { apiKey });
|
|
1667
1798
|
default:
|
|
1668
|
-
throw new
|
|
1799
|
+
throw new ConfigurationError(`Unsupported provider: ${providerName}`);
|
|
1669
1800
|
}
|
|
1670
1801
|
}
|
|
1671
1802
|
async send(message, options) {
|
|
1672
1803
|
return this._llm.send(message, options);
|
|
1673
1804
|
}
|
|
1674
|
-
async operate(
|
|
1805
|
+
async operate(input, options = {}) {
|
|
1675
1806
|
if (!this._llm.operate) {
|
|
1676
1807
|
throw new NotImplementedError(`Provider ${this._provider} does not support operate method`);
|
|
1677
1808
|
}
|
|
1678
|
-
return this._llm.operate(
|
|
1809
|
+
return this._llm.operate(input, options);
|
|
1679
1810
|
}
|
|
1680
1811
|
static async send(message, options) {
|
|
1681
1812
|
const { llm, apiKey, model, ...messageOptions } = options || {};
|
|
1682
1813
|
const instance = new Llm(llm, { apiKey, model });
|
|
1683
1814
|
return instance.send(message, messageOptions);
|
|
1684
1815
|
}
|
|
1685
|
-
static async operate(
|
|
1816
|
+
static async operate(input, options) {
|
|
1686
1817
|
const { llm, apiKey, model, ...operateOptions } = options || {};
|
|
1687
|
-
|
|
1688
|
-
|
|
1818
|
+
let finalLlm = llm;
|
|
1819
|
+
let finalModel = model;
|
|
1820
|
+
if (!llm && model) {
|
|
1821
|
+
const determined = determineModelProvider(model);
|
|
1822
|
+
if (determined.provider) {
|
|
1823
|
+
finalLlm = determined.provider;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
else if (llm && model) {
|
|
1827
|
+
// When both llm and model are provided, check if they conflict
|
|
1828
|
+
const determined = determineModelProvider(model);
|
|
1829
|
+
if (determined.provider && determined.provider !== llm) {
|
|
1830
|
+
// Don't pass the conflicting model to the constructor
|
|
1831
|
+
finalModel = undefined;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
const instance = new Llm(finalLlm, { apiKey, model: finalModel });
|
|
1835
|
+
return instance.operate(input, operateOptions);
|
|
1689
1836
|
}
|
|
1690
1837
|
}
|
|
1691
1838
|
|
|
@@ -1957,7 +2104,16 @@ const weather = {
|
|
|
1957
2104
|
};
|
|
1958
2105
|
|
|
1959
2106
|
const tools = [random, roll, time, weather];
|
|
1960
|
-
|
|
2107
|
+
class JaypieToolkit extends Toolkit {
|
|
2108
|
+
constructor(tools, options) {
|
|
2109
|
+
super(tools, options);
|
|
2110
|
+
this.random = random;
|
|
2111
|
+
this.roll = roll;
|
|
2112
|
+
this.time = time;
|
|
2113
|
+
this.weather = weather;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
const toolkit = new JaypieToolkit(tools);
|
|
1961
2117
|
|
|
1962
|
-
export { constants as LLM, Llm, Toolkit, toolkit, tools };
|
|
2118
|
+
export { JaypieToolkit, constants as LLM, Llm, LlmMessageRole, LlmMessageType, Toolkit, toolkit, tools };
|
|
1963
2119
|
//# sourceMappingURL=index.js.map
|