smoltalk 0.0.54 → 0.0.55
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 +74 -22
- package/dist/models.d.ts +44 -16
- package/dist/models.js +23 -8
- package/dist/strategies/index.d.ts +1 -1
- package/dist/strategies/index.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smoltalk
|
|
2
2
|
|
|
3
|
-
Smoltalk exposes a common API to different LLM providers. There are other packages that do this, but Smoltalk allows you to build strategies on top of it. Here is a simple example.
|
|
3
|
+
Smoltalk exposes a common API to different LLM providers. There are other packages that do this, but Smoltalk allows you to build strategies on top of it. Here is a simple example.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -11,23 +11,80 @@ pnpm install smoltalk
|
|
|
11
11
|
## Hello world example
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
const client = getClient({
|
|
17
|
-
openAiApiKey: process.env.OPENAI_API_KEY || "",
|
|
18
|
-
googleApiKey: process.env.GEMINI_API_KEY || "",
|
|
19
|
-
logLevel: "debug",
|
|
20
|
-
model: "gemini-2.0-flash-lite",
|
|
21
|
-
});
|
|
14
|
+
import { text, userMessage } from "smoltalk";
|
|
22
15
|
|
|
23
16
|
async function main() {
|
|
24
|
-
const
|
|
25
|
-
|
|
17
|
+
const messages = [userMessage("Write me a 10 word story.")];
|
|
18
|
+
const response = await text({
|
|
19
|
+
messages,
|
|
20
|
+
model: "gpt-5.4",
|
|
21
|
+
});
|
|
22
|
+
console.log(response);
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
main();
|
|
29
26
|
```
|
|
30
27
|
|
|
28
|
+
This is functionality that other packages allow.
|
|
29
|
+
<details>
|
|
30
|
+
<summary>Response</summary>
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
{
|
|
34
|
+
success: true,
|
|
35
|
+
value: {
|
|
36
|
+
output: 'Clock stopped; everyone smiled as tomorrow finally arrived before yesterday.',
|
|
37
|
+
toolCalls: [],
|
|
38
|
+
usage: {
|
|
39
|
+
inputTokens: 14,
|
|
40
|
+
outputTokens: 15,
|
|
41
|
+
cachedInputTokens: 0,
|
|
42
|
+
totalTokens: 29
|
|
43
|
+
},
|
|
44
|
+
cost: {
|
|
45
|
+
inputCost: 0.000035,
|
|
46
|
+
outputCost: 0.000225,
|
|
47
|
+
cachedInputCost: undefined,
|
|
48
|
+
totalCost: 0.00026,
|
|
49
|
+
currency: 'USD'
|
|
50
|
+
},
|
|
51
|
+
model: 'gpt-5.4'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
</details>
|
|
56
|
+
|
|
57
|
+
What if you wanted to have fallbacks in case the OpenAI API was down? Just change the `model` field:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const response = await text({
|
|
61
|
+
messages,
|
|
62
|
+
model: fallback("gpt-5.4", "gemini-2.5-flash-lite"),
|
|
63
|
+
// or multiple fallbacks:
|
|
64
|
+
// model: fallback("gpt-5.4", ["gemini-2.5-flash-lite", "gemini-3-flash-preview"]),
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or what if you wanted to try a couple of models and take the first response?
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const response = await text({
|
|
72
|
+
messages,
|
|
73
|
+
model: race("gpt-5.4", "gemini-2.5-flash-lite", "o4-mini"),
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or combine them:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const response = await text({
|
|
81
|
+
messages,
|
|
82
|
+
model: race(fallback("gpt-5.4", "gemini-2.5-flash-lite"), "o4-mini"),
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
You get the idea.
|
|
87
|
+
|
|
31
88
|
## Longer tutorial
|
|
32
89
|
To use Smoltak, you first create a client:
|
|
33
90
|
|
|
@@ -157,20 +214,15 @@ Detects when the model is stuck in a repetitive tool-call loop.
|
|
|
157
214
|
| `intervention` | `string` | Action to take: `"remove-tool"`, `"remove-all-tools"`, `"throw-error"`, or `"halt-execution"`. |
|
|
158
215
|
| `excludeTools` | `string[]` | Tool names to ignore when counting consecutive calls. |
|
|
159
216
|
|
|
160
|
-
##
|
|
217
|
+
## Limitations
|
|
218
|
+
Smoltalk has support for a limited number of providers right now, and is mostly focused on the stateless APIs for text completion, though I plan to add support for more providers as well as image and speech models later. Smoltalk is also a personal project, and there are alternatives backed by companies:
|
|
219
|
+
|
|
161
220
|
- Langchain
|
|
162
|
-
OpenRouter
|
|
221
|
+
- OpenRouter
|
|
163
222
|
- Vercel AI
|
|
164
223
|
|
|
165
|
-
These are all good options, but they are quite heavy, and I wanted a lighter option. That said, you may be better off with one of the above alternatives:
|
|
166
|
-
- They are backed by a business and are more likely to be responsive.
|
|
167
|
-
- They support way more functionality and providers. Smoltalk currently supports just a subset of functionality for OpenAI and Google.
|
|
168
|
-
|
|
169
|
-
## Functionality
|
|
170
|
-
Smoltalk pretty much lets you generate text using an OpenAI or Google model, with support for function calling and structured output, and that's it. I will add functionality and providers sporadically when I have time and need.
|
|
171
|
-
|
|
172
224
|
## Contributing
|
|
173
|
-
|
|
225
|
+
Contributions are welcome. Any of the following contributions would be helpful:
|
|
174
226
|
- Adding support for API parameters or endpoints
|
|
175
227
|
- Adding support for different providers
|
|
176
|
-
- Updating the list of models
|
|
228
|
+
- Updating the list of models
|
package/dist/models.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare const speechToTextModels: readonly [{
|
|
|
67
67
|
export declare const textModels: readonly [{
|
|
68
68
|
readonly type: "text";
|
|
69
69
|
readonly modelName: "gpt-4o-mini";
|
|
70
|
-
readonly description: "GPT-4o mini (
|
|
70
|
+
readonly description: "GPT-4o mini ('o' for 'omni') is a fast, affordable small model for focused tasks. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). It is ideal for fine-tuning, and model outputs from a larger model like GPT-4o can be distilled to GPT-4o-mini to produce similar results at lower cost and latency. Knowledge cutoff: July 2025.";
|
|
71
71
|
readonly maxInputTokens: 128000;
|
|
72
72
|
readonly maxOutputTokens: 16384;
|
|
73
73
|
readonly inputTokenCost: 0.15;
|
|
@@ -78,7 +78,7 @@ export declare const textModels: readonly [{
|
|
|
78
78
|
}, {
|
|
79
79
|
readonly type: "text";
|
|
80
80
|
readonly modelName: "gpt-4o";
|
|
81
|
-
readonly description: "GPT-4o (
|
|
81
|
+
readonly description: "GPT-4o ('o' for 'omni') is our versatile, high-intelligence flagship model. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). Knowledge cutoff: April 2024.";
|
|
82
82
|
readonly maxInputTokens: 128000;
|
|
83
83
|
readonly maxOutputTokens: 16384;
|
|
84
84
|
readonly inputTokenCost: 2.5;
|
|
@@ -89,7 +89,7 @@ export declare const textModels: readonly [{
|
|
|
89
89
|
}, {
|
|
90
90
|
readonly type: "text";
|
|
91
91
|
readonly modelName: "o3";
|
|
92
|
-
readonly description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models.
|
|
92
|
+
readonly description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models. Knowledge cutoff: June 2024.";
|
|
93
93
|
readonly maxInputTokens: 200000;
|
|
94
94
|
readonly maxOutputTokens: 100000;
|
|
95
95
|
readonly inputTokenCost: 2;
|
|
@@ -107,8 +107,8 @@ export declare const textModels: readonly [{
|
|
|
107
107
|
}, {
|
|
108
108
|
readonly type: "text";
|
|
109
109
|
readonly modelName: "o3-mini";
|
|
110
|
-
readonly description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks.
|
|
111
|
-
readonly maxInputTokens:
|
|
110
|
+
readonly description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks. Knowledge cutoff: June 2024.";
|
|
111
|
+
readonly maxInputTokens: 500000;
|
|
112
112
|
readonly maxOutputTokens: 100000;
|
|
113
113
|
readonly inputTokenCost: 1.1;
|
|
114
114
|
readonly cachedInputTokenCost: 0.55;
|
|
@@ -128,9 +128,9 @@ export declare const textModels: readonly [{
|
|
|
128
128
|
readonly description: "Latest small o-series model optimized for fast, effective reasoning with exceptional performance in coding and visual tasks. Knowledge cutoff: June 2024.";
|
|
129
129
|
readonly maxInputTokens: 200000;
|
|
130
130
|
readonly maxOutputTokens: 100000;
|
|
131
|
-
readonly inputTokenCost:
|
|
132
|
-
readonly cachedInputTokenCost: 0.
|
|
133
|
-
readonly outputTokenCost:
|
|
131
|
+
readonly inputTokenCost: 0.6;
|
|
132
|
+
readonly cachedInputTokenCost: 0.3;
|
|
133
|
+
readonly outputTokenCost: 2.4;
|
|
134
134
|
readonly outputTokensPerSecond: 135;
|
|
135
135
|
readonly reasoning: {
|
|
136
136
|
readonly levels: readonly ["low", "medium", "high"];
|
|
@@ -324,6 +324,20 @@ export declare const textModels: readonly [{
|
|
|
324
324
|
readonly outputsSignatures: false;
|
|
325
325
|
};
|
|
326
326
|
readonly provider: "openai";
|
|
327
|
+
}, {
|
|
328
|
+
readonly type: "text";
|
|
329
|
+
readonly modelName: "gpt-5.2-pro";
|
|
330
|
+
readonly description: "GPT-5.2 Pro uses more compute for complex reasoning tasks. 400K context window. Knowledge cutoff: August 2025.";
|
|
331
|
+
readonly maxInputTokens: 400000;
|
|
332
|
+
readonly maxOutputTokens: 128000;
|
|
333
|
+
readonly inputTokenCost: 21;
|
|
334
|
+
readonly outputTokenCost: 168;
|
|
335
|
+
readonly reasoning: {
|
|
336
|
+
readonly canDisable: false;
|
|
337
|
+
readonly outputsThinking: false;
|
|
338
|
+
readonly outputsSignatures: false;
|
|
339
|
+
};
|
|
340
|
+
readonly provider: "openai";
|
|
327
341
|
}, {
|
|
328
342
|
readonly type: "text";
|
|
329
343
|
readonly modelName: "gpt-5.4";
|
|
@@ -691,7 +705,7 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
691
705
|
} | {
|
|
692
706
|
readonly type: "text";
|
|
693
707
|
readonly modelName: "gpt-4o-mini";
|
|
694
|
-
readonly description: "GPT-4o mini (
|
|
708
|
+
readonly description: "GPT-4o mini ('o' for 'omni') is a fast, affordable small model for focused tasks. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). It is ideal for fine-tuning, and model outputs from a larger model like GPT-4o can be distilled to GPT-4o-mini to produce similar results at lower cost and latency. Knowledge cutoff: July 2025.";
|
|
695
709
|
readonly maxInputTokens: 128000;
|
|
696
710
|
readonly maxOutputTokens: 16384;
|
|
697
711
|
readonly inputTokenCost: 0.15;
|
|
@@ -702,7 +716,7 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
702
716
|
} | {
|
|
703
717
|
readonly type: "text";
|
|
704
718
|
readonly modelName: "gpt-4o";
|
|
705
|
-
readonly description: "GPT-4o (
|
|
719
|
+
readonly description: "GPT-4o ('o' for 'omni') is our versatile, high-intelligence flagship model. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). Knowledge cutoff: April 2024.";
|
|
706
720
|
readonly maxInputTokens: 128000;
|
|
707
721
|
readonly maxOutputTokens: 16384;
|
|
708
722
|
readonly inputTokenCost: 2.5;
|
|
@@ -713,7 +727,7 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
713
727
|
} | {
|
|
714
728
|
readonly type: "text";
|
|
715
729
|
readonly modelName: "o3";
|
|
716
|
-
readonly description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models.
|
|
730
|
+
readonly description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models. Knowledge cutoff: June 2024.";
|
|
717
731
|
readonly maxInputTokens: 200000;
|
|
718
732
|
readonly maxOutputTokens: 100000;
|
|
719
733
|
readonly inputTokenCost: 2;
|
|
@@ -731,8 +745,8 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
731
745
|
} | {
|
|
732
746
|
readonly type: "text";
|
|
733
747
|
readonly modelName: "o3-mini";
|
|
734
|
-
readonly description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks.
|
|
735
|
-
readonly maxInputTokens:
|
|
748
|
+
readonly description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks. Knowledge cutoff: June 2024.";
|
|
749
|
+
readonly maxInputTokens: 500000;
|
|
736
750
|
readonly maxOutputTokens: 100000;
|
|
737
751
|
readonly inputTokenCost: 1.1;
|
|
738
752
|
readonly cachedInputTokenCost: 0.55;
|
|
@@ -752,9 +766,9 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
752
766
|
readonly description: "Latest small o-series model optimized for fast, effective reasoning with exceptional performance in coding and visual tasks. Knowledge cutoff: June 2024.";
|
|
753
767
|
readonly maxInputTokens: 200000;
|
|
754
768
|
readonly maxOutputTokens: 100000;
|
|
755
|
-
readonly inputTokenCost:
|
|
756
|
-
readonly cachedInputTokenCost: 0.
|
|
757
|
-
readonly outputTokenCost:
|
|
769
|
+
readonly inputTokenCost: 0.6;
|
|
770
|
+
readonly cachedInputTokenCost: 0.3;
|
|
771
|
+
readonly outputTokenCost: 2.4;
|
|
758
772
|
readonly outputTokensPerSecond: 135;
|
|
759
773
|
readonly reasoning: {
|
|
760
774
|
readonly levels: readonly ["low", "medium", "high"];
|
|
@@ -948,6 +962,20 @@ export declare function getModel(modelName: ModelName): TextModel | {
|
|
|
948
962
|
readonly outputsSignatures: false;
|
|
949
963
|
};
|
|
950
964
|
readonly provider: "openai";
|
|
965
|
+
} | {
|
|
966
|
+
readonly type: "text";
|
|
967
|
+
readonly modelName: "gpt-5.2-pro";
|
|
968
|
+
readonly description: "GPT-5.2 Pro uses more compute for complex reasoning tasks. 400K context window. Knowledge cutoff: August 2025.";
|
|
969
|
+
readonly maxInputTokens: 400000;
|
|
970
|
+
readonly maxOutputTokens: 128000;
|
|
971
|
+
readonly inputTokenCost: 21;
|
|
972
|
+
readonly outputTokenCost: 168;
|
|
973
|
+
readonly reasoning: {
|
|
974
|
+
readonly canDisable: false;
|
|
975
|
+
readonly outputsThinking: false;
|
|
976
|
+
readonly outputsSignatures: false;
|
|
977
|
+
};
|
|
978
|
+
readonly provider: "openai";
|
|
951
979
|
} | {
|
|
952
980
|
readonly type: "text";
|
|
953
981
|
readonly modelName: "gpt-5.4";
|
package/dist/models.js
CHANGED
|
@@ -33,7 +33,7 @@ export const textModels = [
|
|
|
33
33
|
{
|
|
34
34
|
type: "text",
|
|
35
35
|
modelName: "gpt-4o-mini",
|
|
36
|
-
description: "GPT-4o mini (
|
|
36
|
+
description: "GPT-4o mini ('o' for 'omni') is a fast, affordable small model for focused tasks. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). It is ideal for fine-tuning, and model outputs from a larger model like GPT-4o can be distilled to GPT-4o-mini to produce similar results at lower cost and latency. Knowledge cutoff: July 2025.",
|
|
37
37
|
maxInputTokens: 128000,
|
|
38
38
|
maxOutputTokens: 16384,
|
|
39
39
|
inputTokenCost: 0.15,
|
|
@@ -45,7 +45,7 @@ export const textModels = [
|
|
|
45
45
|
{
|
|
46
46
|
type: "text",
|
|
47
47
|
modelName: "gpt-4o",
|
|
48
|
-
description: "GPT-4o (
|
|
48
|
+
description: "GPT-4o ('o' for 'omni') is our versatile, high-intelligence flagship model. It accepts both text and image inputs, and produces text outputs (including Structured Outputs). Knowledge cutoff: April 2024.",
|
|
49
49
|
maxInputTokens: 128000,
|
|
50
50
|
maxOutputTokens: 16384,
|
|
51
51
|
inputTokenCost: 2.5,
|
|
@@ -57,7 +57,7 @@ export const textModels = [
|
|
|
57
57
|
{
|
|
58
58
|
type: "text",
|
|
59
59
|
modelName: "o3",
|
|
60
|
-
description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models.
|
|
60
|
+
description: "o3 is a reasoning model that sets a new standard for math, science, coding, visual reasoning tasks, and technical writing. Part of the o-series of reasoning models. Knowledge cutoff: June 2024.",
|
|
61
61
|
maxInputTokens: 200000,
|
|
62
62
|
maxOutputTokens: 100000,
|
|
63
63
|
inputTokenCost: 2,
|
|
@@ -76,8 +76,8 @@ export const textModels = [
|
|
|
76
76
|
{
|
|
77
77
|
type: "text",
|
|
78
78
|
modelName: "o3-mini",
|
|
79
|
-
description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks.
|
|
80
|
-
maxInputTokens:
|
|
79
|
+
description: "o3-mini is our most recent small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. o3-mini also supports key developer features, like Structured Outputs, function calling, Batch API, and more. Like other models in the o-series, it is designed to excel at science, math, and coding tasks. Knowledge cutoff: June 2024.",
|
|
80
|
+
maxInputTokens: 500000,
|
|
81
81
|
maxOutputTokens: 100000,
|
|
82
82
|
inputTokenCost: 1.1,
|
|
83
83
|
cachedInputTokenCost: 0.55,
|
|
@@ -98,9 +98,9 @@ export const textModels = [
|
|
|
98
98
|
description: "Latest small o-series model optimized for fast, effective reasoning with exceptional performance in coding and visual tasks. Knowledge cutoff: June 2024.",
|
|
99
99
|
maxInputTokens: 200000,
|
|
100
100
|
maxOutputTokens: 100000,
|
|
101
|
-
inputTokenCost:
|
|
102
|
-
cachedInputTokenCost: 0.
|
|
103
|
-
outputTokenCost:
|
|
101
|
+
inputTokenCost: 0.6,
|
|
102
|
+
cachedInputTokenCost: 0.3,
|
|
103
|
+
outputTokenCost: 2.4,
|
|
104
104
|
outputTokensPerSecond: 135,
|
|
105
105
|
reasoning: {
|
|
106
106
|
levels: ["low", "medium", "high"],
|
|
@@ -308,6 +308,21 @@ export const textModels = [
|
|
|
308
308
|
},
|
|
309
309
|
provider: "openai",
|
|
310
310
|
},
|
|
311
|
+
{
|
|
312
|
+
type: "text",
|
|
313
|
+
modelName: "gpt-5.2-pro",
|
|
314
|
+
description: "GPT-5.2 Pro uses more compute for complex reasoning tasks. 400K context window. Knowledge cutoff: August 2025.",
|
|
315
|
+
maxInputTokens: 400000,
|
|
316
|
+
maxOutputTokens: 128000,
|
|
317
|
+
inputTokenCost: 21,
|
|
318
|
+
outputTokenCost: 168,
|
|
319
|
+
reasoning: {
|
|
320
|
+
canDisable: false,
|
|
321
|
+
outputsThinking: false,
|
|
322
|
+
outputsSignatures: false,
|
|
323
|
+
},
|
|
324
|
+
provider: "openai",
|
|
325
|
+
},
|
|
311
326
|
{
|
|
312
327
|
type: "text",
|
|
313
328
|
modelName: "gpt-5.4",
|
|
@@ -7,5 +7,5 @@ export * from "./raceStrategy.js";
|
|
|
7
7
|
export * from "./types.js";
|
|
8
8
|
export declare function race(...strategies: ModelParam[]): Strategy;
|
|
9
9
|
export declare function id(model: ModelLike): Strategy;
|
|
10
|
-
export declare function fallback(primaryStrategy: ModelParam, config: FallbackStrategyConfig): Strategy;
|
|
10
|
+
export declare function fallback(primaryStrategy: ModelParam, config: FallbackStrategyConfig | string | string[]): Strategy;
|
|
11
11
|
export declare function fromJSON(json: StrategyJSON): Strategy;
|
package/dist/strategies/index.js
CHANGED
|
@@ -14,7 +14,17 @@ export function id(model) {
|
|
|
14
14
|
return new IDStrategy(model);
|
|
15
15
|
}
|
|
16
16
|
export function fallback(primaryStrategy, config) {
|
|
17
|
-
|
|
17
|
+
let resolvedConfig;
|
|
18
|
+
if (typeof config === "string") {
|
|
19
|
+
resolvedConfig = { error: [config] };
|
|
20
|
+
}
|
|
21
|
+
else if (Array.isArray(config)) {
|
|
22
|
+
resolvedConfig = { error: config };
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
resolvedConfig = config;
|
|
26
|
+
}
|
|
27
|
+
return new FallbackStrategy(primaryStrategy, resolvedConfig);
|
|
18
28
|
}
|
|
19
29
|
export function fromJSON(json) {
|
|
20
30
|
if (IDStrategyJSONSchema.safeParse(json).success) {
|