@promptbook/cli 0.94.0-3 → 0.94.0-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +486 -204
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/ollama.index.d.ts +4 -0
- package/esm/typings/src/_packages/openai.index.d.ts +2 -0
- package/esm/typings/src/llm-providers/{openai/computeUsage.d.ts → _common/utils/pricing.d.ts} +2 -2
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +44 -0
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/createOllamaExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +14 -0
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +91 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +12 -53
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +486 -204
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/llm-providers/{openai/computeUsage.test.d.ts → _common/utils/pricing.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @generated
|
|
58
58
|
* @see https://github.com/webgptorg/promptbook
|
|
59
59
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.94.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.94.0-4';
|
|
61
61
|
/**
|
|
62
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
63
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11832,7 +11832,7 @@
|
|
|
11832
11832
|
function preserve(func) {
|
|
11833
11833
|
// Note: NOT calling the function
|
|
11834
11834
|
(async () => {
|
|
11835
|
-
// TODO: [💩] Change to `await forEver` or
|
|
11835
|
+
// TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
|
|
11836
11836
|
await waitasecond.forTime(100000000);
|
|
11837
11837
|
// [1]
|
|
11838
11838
|
try {
|
|
@@ -12447,7 +12447,10 @@
|
|
|
12447
12447
|
function usageToHuman(usage) {
|
|
12448
12448
|
const reportItems = [];
|
|
12449
12449
|
const uncertainNumberToHuman = ({ value, isUncertain }) => `${isUncertain ? 'approximately ' : ''}${Math.round(value * 100) / 100}`;
|
|
12450
|
-
if (usage.price.value
|
|
12450
|
+
if (usage.price.value === 0) {
|
|
12451
|
+
reportItems.push(`Zero cost`);
|
|
12452
|
+
}
|
|
12453
|
+
else if (usage.price.value > 0.01
|
|
12451
12454
|
// <- TODO: [🍓][🧞♂️][👩🏽🤝🧑🏻] Configure negligible value - default value to config + value to `UsageToHumanSettings`
|
|
12452
12455
|
) {
|
|
12453
12456
|
reportItems.push(`Cost ${uncertainNumberToHuman(usage.price)} USD`);
|
|
@@ -15077,11 +15080,11 @@
|
|
|
15077
15080
|
*/
|
|
15078
15081
|
|
|
15079
15082
|
/**
|
|
15080
|
-
*
|
|
15083
|
+
* Create price per one token based on the string value found on openai page
|
|
15081
15084
|
*
|
|
15082
15085
|
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
15083
15086
|
*/
|
|
15084
|
-
function
|
|
15087
|
+
function pricing(value) {
|
|
15085
15088
|
const [price, tokens] = value.split(' / ');
|
|
15086
15089
|
return parseFloat(price.replace('$', '')) / parseFloat(tokens.replace('M tokens', '')) / 1000000;
|
|
15087
15090
|
}
|
|
@@ -15103,8 +15106,8 @@
|
|
|
15103
15106
|
modelName: 'claude-3-5-sonnet-20240620',
|
|
15104
15107
|
modelDescription: 'Latest Claude model with great reasoning, coding, and language understanding capabilities. 200K context window. Optimized balance of intelligence and speed.',
|
|
15105
15108
|
pricing: {
|
|
15106
|
-
prompt:
|
|
15107
|
-
output:
|
|
15109
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
15110
|
+
output: pricing(`$12.50 / 1M tokens`),
|
|
15108
15111
|
},
|
|
15109
15112
|
},
|
|
15110
15113
|
{
|
|
@@ -15113,8 +15116,8 @@
|
|
|
15113
15116
|
modelName: 'claude-3-opus-20240229',
|
|
15114
15117
|
modelDescription: 'Most capable Claude model excelling at complex reasoning, coding, and detailed instruction following. 200K context window. Best for sophisticated tasks requiring nuanced understanding.',
|
|
15115
15118
|
pricing: {
|
|
15116
|
-
prompt:
|
|
15117
|
-
output:
|
|
15119
|
+
prompt: pricing(`$12.00 / 1M tokens`),
|
|
15120
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
15118
15121
|
},
|
|
15119
15122
|
},
|
|
15120
15123
|
{
|
|
@@ -15123,8 +15126,8 @@
|
|
|
15123
15126
|
modelName: 'claude-3-sonnet-20240229',
|
|
15124
15127
|
modelDescription: 'Strong general-purpose model with excellent performance across reasoning, conversation, and coding tasks. 200K context window. Good balance of intelligence and cost-efficiency.',
|
|
15125
15128
|
pricing: {
|
|
15126
|
-
prompt:
|
|
15127
|
-
output:
|
|
15129
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
15130
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
15128
15131
|
},
|
|
15129
15132
|
},
|
|
15130
15133
|
{
|
|
@@ -15133,8 +15136,8 @@
|
|
|
15133
15136
|
modelName: ' claude-3-haiku-20240307',
|
|
15134
15137
|
modelDescription: 'Fastest and most compact Claude model optimized for responsiveness in interactive applications. 200K context window. Excellent for quick responses and lightweight applications.',
|
|
15135
15138
|
pricing: {
|
|
15136
|
-
prompt:
|
|
15137
|
-
output:
|
|
15139
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
15140
|
+
output: pricing(`$1.25 / 1M tokens`),
|
|
15138
15141
|
},
|
|
15139
15142
|
},
|
|
15140
15143
|
{
|
|
@@ -15143,8 +15146,8 @@
|
|
|
15143
15146
|
modelName: 'claude-2.1',
|
|
15144
15147
|
modelDescription: 'Improved version of Claude 2 with better performance across reasoning and truthfulness. 100K context window. Legacy model with strong reliability.',
|
|
15145
15148
|
pricing: {
|
|
15146
|
-
prompt:
|
|
15147
|
-
output:
|
|
15149
|
+
prompt: pricing(`$8.00 / 1M tokens`),
|
|
15150
|
+
output: pricing(`$24.00 / 1M tokens`),
|
|
15148
15151
|
},
|
|
15149
15152
|
},
|
|
15150
15153
|
{
|
|
@@ -15153,8 +15156,8 @@
|
|
|
15153
15156
|
modelName: 'claude-2.0',
|
|
15154
15157
|
modelDescription: 'Legacy model with strong general reasoning and language capabilities. 100K context window. Superseded by newer Claude 3 models.',
|
|
15155
15158
|
pricing: {
|
|
15156
|
-
prompt:
|
|
15157
|
-
output:
|
|
15159
|
+
prompt: pricing(`$8.00 / 1M tokens`),
|
|
15160
|
+
output: pricing(`$24.00 / 1M tokens`),
|
|
15158
15161
|
},
|
|
15159
15162
|
},
|
|
15160
15163
|
{
|
|
@@ -15163,8 +15166,8 @@
|
|
|
15163
15166
|
modelName: 'claude-instant-1.2',
|
|
15164
15167
|
modelDescription: 'Older, faster Claude model optimized for high throughput applications. Lower cost but less capable than newer models. 100K context window.',
|
|
15165
15168
|
pricing: {
|
|
15166
|
-
prompt:
|
|
15167
|
-
output:
|
|
15169
|
+
prompt: pricing(`$0.80 / 1M tokens`),
|
|
15170
|
+
output: pricing(`$2.40 / 1M tokens`),
|
|
15168
15171
|
},
|
|
15169
15172
|
},
|
|
15170
15173
|
{
|
|
@@ -15173,8 +15176,8 @@
|
|
|
15173
15176
|
modelName: 'claude-3-7-sonnet-20250219',
|
|
15174
15177
|
modelDescription: 'Latest generation Claude model with advanced reasoning and language understanding. Enhanced capabilities over 3.5 with improved domain knowledge. 200K context window.',
|
|
15175
15178
|
pricing: {
|
|
15176
|
-
prompt:
|
|
15177
|
-
output:
|
|
15179
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
15180
|
+
output: pricing(`$12.50 / 1M tokens`),
|
|
15178
15181
|
},
|
|
15179
15182
|
},
|
|
15180
15183
|
{
|
|
@@ -15183,11 +15186,31 @@
|
|
|
15183
15186
|
modelName: 'claude-3-5-haiku-20241022',
|
|
15184
15187
|
modelDescription: 'Fast and efficient Claude 3.5 variant optimized for speed and cost-effectiveness. Great for interactive applications requiring quick responses. 200K context window.',
|
|
15185
15188
|
pricing: {
|
|
15186
|
-
prompt:
|
|
15187
|
-
output:
|
|
15189
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
15190
|
+
output: pricing(`$1.25 / 1M tokens`),
|
|
15188
15191
|
},
|
|
15189
15192
|
},
|
|
15190
|
-
|
|
15193
|
+
{
|
|
15194
|
+
modelVariant: 'CHAT',
|
|
15195
|
+
modelTitle: 'Claude 3.7 Haiku',
|
|
15196
|
+
modelName: 'claude-3-7-haiku-20250115',
|
|
15197
|
+
modelDescription: 'Ultra-fast Claude variant for lightweight applications',
|
|
15198
|
+
pricing: {
|
|
15199
|
+
prompt: pricing(`$0.20 / 1M tokens`),
|
|
15200
|
+
output: pricing(`$1.00 / 1M tokens`),
|
|
15201
|
+
},
|
|
15202
|
+
},
|
|
15203
|
+
{
|
|
15204
|
+
modelVariant: 'CHAT',
|
|
15205
|
+
modelTitle: 'Claude Embedding',
|
|
15206
|
+
modelName: 'claude-embedding-1',
|
|
15207
|
+
modelDescription: 'Model optimized for text embeddings',
|
|
15208
|
+
pricing: {
|
|
15209
|
+
prompt: pricing(`$0.05 / 1M tokens`),
|
|
15210
|
+
output: 0,
|
|
15211
|
+
},
|
|
15212
|
+
},
|
|
15213
|
+
// …add any additional models from https://docs.anthropic.com/en/docs/models-overview…
|
|
15191
15214
|
],
|
|
15192
15215
|
});
|
|
15193
15216
|
/**
|
|
@@ -15652,8 +15675,8 @@
|
|
|
15652
15675
|
modelName: 'davinci-002',
|
|
15653
15676
|
modelDescription: 'Legacy completion model with strong performance on text generation tasks. Optimized for complex instructions and longer outputs.',
|
|
15654
15677
|
pricing: {
|
|
15655
|
-
prompt:
|
|
15656
|
-
output:
|
|
15678
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
15679
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
15657
15680
|
},
|
|
15658
15681
|
},
|
|
15659
15682
|
/**/
|
|
@@ -15670,8 +15693,8 @@
|
|
|
15670
15693
|
modelName: 'gpt-3.5-turbo-16k',
|
|
15671
15694
|
modelDescription: 'GPT-3.5 Turbo with extended 16k token context length for handling longer conversations and documents.',
|
|
15672
15695
|
pricing: {
|
|
15673
|
-
prompt:
|
|
15674
|
-
output:
|
|
15696
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
15697
|
+
output: pricing(`$4.00 / 1M tokens`),
|
|
15675
15698
|
},
|
|
15676
15699
|
},
|
|
15677
15700
|
/**/
|
|
@@ -15694,8 +15717,8 @@
|
|
|
15694
15717
|
modelName: 'gpt-4',
|
|
15695
15718
|
modelDescription: 'GPT-4 is a powerful language model with enhanced reasoning, instruction-following capabilities, and 8K context window. Optimized for complex tasks requiring deep understanding.',
|
|
15696
15719
|
pricing: {
|
|
15697
|
-
prompt:
|
|
15698
|
-
output:
|
|
15720
|
+
prompt: pricing(`$30.00 / 1M tokens`),
|
|
15721
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
15699
15722
|
},
|
|
15700
15723
|
},
|
|
15701
15724
|
/**/
|
|
@@ -15706,8 +15729,8 @@
|
|
|
15706
15729
|
modelName: 'gpt-4-32k',
|
|
15707
15730
|
modelDescription: 'Extended context version of GPT-4 with a 32K token window for processing very long inputs and generating comprehensive responses for complex tasks.',
|
|
15708
15731
|
pricing: {
|
|
15709
|
-
prompt:
|
|
15710
|
-
output:
|
|
15732
|
+
prompt: pricing(`$60.00 / 1M tokens`),
|
|
15733
|
+
output: pricing(`$120.00 / 1M tokens`),
|
|
15711
15734
|
},
|
|
15712
15735
|
},
|
|
15713
15736
|
/**/
|
|
@@ -15729,8 +15752,8 @@
|
|
|
15729
15752
|
modelName: 'gpt-4-turbo-2024-04-09',
|
|
15730
15753
|
modelDescription: 'Latest stable GPT-4 Turbo model from April 2024 with enhanced reasoning and context handling capabilities. Offers 128K context window and improved performance.',
|
|
15731
15754
|
pricing: {
|
|
15732
|
-
prompt:
|
|
15733
|
-
output:
|
|
15755
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15756
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15734
15757
|
},
|
|
15735
15758
|
},
|
|
15736
15759
|
/**/
|
|
@@ -15741,8 +15764,8 @@
|
|
|
15741
15764
|
modelName: 'gpt-3.5-turbo-1106',
|
|
15742
15765
|
modelDescription: 'November 2023 version of GPT-3.5 Turbo with improved instruction following and a 16K token context window.',
|
|
15743
15766
|
pricing: {
|
|
15744
|
-
prompt:
|
|
15745
|
-
output:
|
|
15767
|
+
prompt: pricing(`$1.00 / 1M tokens`),
|
|
15768
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
15746
15769
|
},
|
|
15747
15770
|
},
|
|
15748
15771
|
/**/
|
|
@@ -15753,8 +15776,8 @@
|
|
|
15753
15776
|
modelName: 'gpt-4-turbo',
|
|
15754
15777
|
modelDescription: 'More capable model than GPT-4 with improved instruction following, function calling and a 128K token context window for handling very large documents.',
|
|
15755
15778
|
pricing: {
|
|
15756
|
-
prompt:
|
|
15757
|
-
output:
|
|
15779
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15780
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15758
15781
|
},
|
|
15759
15782
|
},
|
|
15760
15783
|
/**/
|
|
@@ -15765,8 +15788,8 @@
|
|
|
15765
15788
|
modelName: 'gpt-3.5-turbo-instruct-0914',
|
|
15766
15789
|
modelDescription: 'September 2023 version of GPT-3.5 Turbo optimized for completion-style instruction following with a 4K context window.',
|
|
15767
15790
|
pricing: {
|
|
15768
|
-
prompt:
|
|
15769
|
-
output:
|
|
15791
|
+
prompt: pricing(`$1.50 / 1M tokens`),
|
|
15792
|
+
output: pricing(`$2.00 / 1M tokens`), // <- For gpt-3.5-turbo-instruct
|
|
15770
15793
|
},
|
|
15771
15794
|
},
|
|
15772
15795
|
/**/
|
|
@@ -15777,8 +15800,8 @@
|
|
|
15777
15800
|
modelName: 'gpt-3.5-turbo-instruct',
|
|
15778
15801
|
modelDescription: 'Optimized version of GPT-3.5 for completion-style API with good instruction following and a 4K token context window.',
|
|
15779
15802
|
pricing: {
|
|
15780
|
-
prompt:
|
|
15781
|
-
output:
|
|
15803
|
+
prompt: pricing(`$1.50 / 1M tokens`),
|
|
15804
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
15782
15805
|
},
|
|
15783
15806
|
},
|
|
15784
15807
|
/**/
|
|
@@ -15795,8 +15818,8 @@
|
|
|
15795
15818
|
modelName: 'gpt-3.5-turbo',
|
|
15796
15819
|
modelDescription: 'Latest version of GPT-3.5 Turbo with improved performance and instruction following capabilities. Default 4K context window with options for 16K.',
|
|
15797
15820
|
pricing: {
|
|
15798
|
-
prompt:
|
|
15799
|
-
output:
|
|
15821
|
+
prompt: pricing(`$0.50 / 1M tokens`),
|
|
15822
|
+
output: pricing(`$1.50 / 1M tokens`),
|
|
15800
15823
|
},
|
|
15801
15824
|
},
|
|
15802
15825
|
/**/
|
|
@@ -15807,8 +15830,8 @@
|
|
|
15807
15830
|
modelName: 'gpt-3.5-turbo-0301',
|
|
15808
15831
|
modelDescription: 'March 2023 version of GPT-3.5 Turbo with a 4K token context window. Legacy model maintained for backward compatibility.',
|
|
15809
15832
|
pricing: {
|
|
15810
|
-
prompt:
|
|
15811
|
-
output:
|
|
15833
|
+
prompt: pricing(`$1.50 / 1M tokens`),
|
|
15834
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
15812
15835
|
},
|
|
15813
15836
|
},
|
|
15814
15837
|
/**/
|
|
@@ -15819,8 +15842,8 @@
|
|
|
15819
15842
|
modelName: 'babbage-002',
|
|
15820
15843
|
modelDescription: 'Efficient legacy completion model with a good balance of performance and speed. Suitable for straightforward text generation tasks.',
|
|
15821
15844
|
pricing: {
|
|
15822
|
-
prompt:
|
|
15823
|
-
output:
|
|
15845
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
15846
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
15824
15847
|
},
|
|
15825
15848
|
},
|
|
15826
15849
|
/**/
|
|
@@ -15831,8 +15854,8 @@
|
|
|
15831
15854
|
modelName: 'gpt-4-1106-preview',
|
|
15832
15855
|
modelDescription: 'November 2023 preview version of GPT-4 Turbo with improved instruction following and a 128K token context window.',
|
|
15833
15856
|
pricing: {
|
|
15834
|
-
prompt:
|
|
15835
|
-
output:
|
|
15857
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15858
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15836
15859
|
},
|
|
15837
15860
|
},
|
|
15838
15861
|
/**/
|
|
@@ -15843,8 +15866,8 @@
|
|
|
15843
15866
|
modelName: 'gpt-4-0125-preview',
|
|
15844
15867
|
modelDescription: 'January 2024 preview version of GPT-4 Turbo with improved reasoning capabilities and a 128K token context window.',
|
|
15845
15868
|
pricing: {
|
|
15846
|
-
prompt:
|
|
15847
|
-
output:
|
|
15869
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15870
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15848
15871
|
},
|
|
15849
15872
|
},
|
|
15850
15873
|
/**/
|
|
@@ -15861,8 +15884,8 @@
|
|
|
15861
15884
|
modelName: 'gpt-3.5-turbo-0125',
|
|
15862
15885
|
modelDescription: 'January 2024 version of GPT-3.5 Turbo with improved reasoning capabilities and a 16K token context window.',
|
|
15863
15886
|
pricing: {
|
|
15864
|
-
prompt:
|
|
15865
|
-
output:
|
|
15887
|
+
prompt: pricing(`$0.50 / 1M tokens`),
|
|
15888
|
+
output: pricing(`$1.50 / 1M tokens`),
|
|
15866
15889
|
},
|
|
15867
15890
|
},
|
|
15868
15891
|
/**/
|
|
@@ -15873,8 +15896,8 @@
|
|
|
15873
15896
|
modelName: 'gpt-4-turbo-preview',
|
|
15874
15897
|
modelDescription: 'Preview version of GPT-4 Turbo that points to the latest model version. Features improved instruction following, 128K token context window and lower latency.',
|
|
15875
15898
|
pricing: {
|
|
15876
|
-
prompt:
|
|
15877
|
-
output:
|
|
15899
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15900
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15878
15901
|
},
|
|
15879
15902
|
},
|
|
15880
15903
|
/**/
|
|
@@ -15885,7 +15908,7 @@
|
|
|
15885
15908
|
modelName: 'text-embedding-3-large',
|
|
15886
15909
|
modelDescription: "OpenAI's most capable text embedding model designed for high-quality embeddings for complex similarity tasks and information retrieval.",
|
|
15887
15910
|
pricing: {
|
|
15888
|
-
prompt:
|
|
15911
|
+
prompt: pricing(`$0.13 / 1M tokens`),
|
|
15889
15912
|
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
15890
15913
|
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
15891
15914
|
},
|
|
@@ -15898,7 +15921,7 @@
|
|
|
15898
15921
|
modelName: 'text-embedding-3-small',
|
|
15899
15922
|
modelDescription: 'Cost-effective embedding model with good performance for simpler tasks like text similarity and retrieval. Good balance of quality and efficiency.',
|
|
15900
15923
|
pricing: {
|
|
15901
|
-
prompt:
|
|
15924
|
+
prompt: pricing(`$0.02 / 1M tokens`),
|
|
15902
15925
|
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
15903
15926
|
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
15904
15927
|
},
|
|
@@ -15911,8 +15934,8 @@
|
|
|
15911
15934
|
modelName: 'gpt-3.5-turbo-0613',
|
|
15912
15935
|
modelDescription: 'June 2023 version of GPT-3.5 Turbo with function calling capabilities and a 4K token context window.',
|
|
15913
15936
|
pricing: {
|
|
15914
|
-
prompt:
|
|
15915
|
-
output:
|
|
15937
|
+
prompt: pricing(`$1.50 / 1M tokens`),
|
|
15938
|
+
output: pricing(`$2.00 / 1M tokens`),
|
|
15916
15939
|
},
|
|
15917
15940
|
},
|
|
15918
15941
|
/**/
|
|
@@ -15923,7 +15946,7 @@
|
|
|
15923
15946
|
modelName: 'text-embedding-ada-002',
|
|
15924
15947
|
modelDescription: 'Legacy text embedding model suitable for text similarity and retrieval augmented generation use cases. Replaced by newer embedding-3 models.',
|
|
15925
15948
|
pricing: {
|
|
15926
|
-
prompt:
|
|
15949
|
+
prompt: pricing(`$0.1 / 1M tokens`),
|
|
15927
15950
|
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
15928
15951
|
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
15929
15952
|
},
|
|
@@ -15954,8 +15977,8 @@
|
|
|
15954
15977
|
modelName: 'gpt-4o-2024-05-13',
|
|
15955
15978
|
modelDescription: 'May 2024 version of GPT-4o with enhanced multimodal capabilities, improved reasoning, and optimized for vision, audio and chat at lower latencies.',
|
|
15956
15979
|
pricing: {
|
|
15957
|
-
prompt:
|
|
15958
|
-
output:
|
|
15980
|
+
prompt: pricing(`$5.00 / 1M tokens`),
|
|
15981
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
15959
15982
|
},
|
|
15960
15983
|
},
|
|
15961
15984
|
/**/
|
|
@@ -15966,8 +15989,8 @@
|
|
|
15966
15989
|
modelName: 'gpt-4o',
|
|
15967
15990
|
modelDescription: "OpenAI's most advanced multimodal model optimized for performance, speed, and cost. Capable of vision, reasoning, and high quality text generation.",
|
|
15968
15991
|
pricing: {
|
|
15969
|
-
prompt:
|
|
15970
|
-
output:
|
|
15992
|
+
prompt: pricing(`$5.00 / 1M tokens`),
|
|
15993
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
15971
15994
|
},
|
|
15972
15995
|
},
|
|
15973
15996
|
/**/
|
|
@@ -15978,8 +16001,8 @@
|
|
|
15978
16001
|
modelName: 'gpt-4o-mini',
|
|
15979
16002
|
modelDescription: 'Smaller, more cost-effective version of GPT-4o with good performance across text, vision, and audio tasks at reduced complexity.',
|
|
15980
16003
|
pricing: {
|
|
15981
|
-
prompt:
|
|
15982
|
-
output:
|
|
16004
|
+
prompt: pricing(`$0.15 / 1M tokens`),
|
|
16005
|
+
output: pricing(`$0.60 / 1M tokens`),
|
|
15983
16006
|
},
|
|
15984
16007
|
},
|
|
15985
16008
|
/**/
|
|
@@ -15990,8 +16013,8 @@
|
|
|
15990
16013
|
modelName: 'o1-preview',
|
|
15991
16014
|
modelDescription: 'Advanced reasoning model with exceptional performance on complex logical, mathematical, and analytical tasks. Built for deep reasoning and specialized professional tasks.',
|
|
15992
16015
|
pricing: {
|
|
15993
|
-
prompt:
|
|
15994
|
-
output:
|
|
16016
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
16017
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
15995
16018
|
},
|
|
15996
16019
|
},
|
|
15997
16020
|
/**/
|
|
@@ -16003,8 +16026,8 @@
|
|
|
16003
16026
|
modelDescription: 'September 2024 version of O1 preview with specialized reasoning capabilities for complex tasks requiring precise analytical thinking.',
|
|
16004
16027
|
// <- TODO: [💩] Some better system to organize these date suffixes and versions
|
|
16005
16028
|
pricing: {
|
|
16006
|
-
prompt:
|
|
16007
|
-
output:
|
|
16029
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
16030
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
16008
16031
|
},
|
|
16009
16032
|
},
|
|
16010
16033
|
/**/
|
|
@@ -16015,8 +16038,8 @@
|
|
|
16015
16038
|
modelName: 'o1-mini',
|
|
16016
16039
|
modelDescription: 'Smaller, cost-effective version of the O1 model with good performance on reasoning tasks while maintaining efficiency for everyday analytical use.',
|
|
16017
16040
|
pricing: {
|
|
16018
|
-
prompt:
|
|
16019
|
-
output:
|
|
16041
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
16042
|
+
output: pricing(`$12.00 / 1M tokens`),
|
|
16020
16043
|
},
|
|
16021
16044
|
},
|
|
16022
16045
|
/**/
|
|
@@ -16027,8 +16050,8 @@
|
|
|
16027
16050
|
modelName: 'o1',
|
|
16028
16051
|
modelDescription: "OpenAI's advanced reasoning model focused on logic and problem-solving. Designed for complex analytical tasks with rigorous step-by-step reasoning. 128K context window.",
|
|
16029
16052
|
pricing: {
|
|
16030
|
-
prompt:
|
|
16031
|
-
output:
|
|
16053
|
+
prompt: pricing(`$15.00 / 1M tokens`),
|
|
16054
|
+
output: pricing(`$60.00 / 1M tokens`),
|
|
16032
16055
|
},
|
|
16033
16056
|
},
|
|
16034
16057
|
/**/
|
|
@@ -16039,8 +16062,8 @@
|
|
|
16039
16062
|
modelName: 'o3-mini',
|
|
16040
16063
|
modelDescription: 'Cost-effective reasoning model optimized for academic and scientific problem-solving. Efficient performance on STEM tasks with deep mathematical and scientific knowledge. 128K context window.',
|
|
16041
16064
|
pricing: {
|
|
16042
|
-
prompt:
|
|
16043
|
-
output:
|
|
16065
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
16066
|
+
output: pricing(`$12.00 / 1M tokens`),
|
|
16044
16067
|
// <- TODO: !! Unsure, check the pricing
|
|
16045
16068
|
},
|
|
16046
16069
|
},
|
|
@@ -16052,8 +16075,8 @@
|
|
|
16052
16075
|
modelName: 'o1-mini-2024-09-12',
|
|
16053
16076
|
modelDescription: "September 2024 version of O1-mini with balanced reasoning capabilities and cost-efficiency. Good for analytical tasks that don't require the full O1 model.",
|
|
16054
16077
|
pricing: {
|
|
16055
|
-
prompt:
|
|
16056
|
-
output:
|
|
16078
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
16079
|
+
output: pricing(`$12.00 / 1M tokens`),
|
|
16057
16080
|
},
|
|
16058
16081
|
},
|
|
16059
16082
|
/**/
|
|
@@ -16064,8 +16087,8 @@
|
|
|
16064
16087
|
modelName: 'gpt-3.5-turbo-16k-0613',
|
|
16065
16088
|
modelDescription: 'June 2023 version of GPT-3.5 Turbo with extended 16k token context window for processing longer conversations and documents.',
|
|
16066
16089
|
pricing: {
|
|
16067
|
-
prompt:
|
|
16068
|
-
output:
|
|
16090
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
16091
|
+
output: pricing(`$4.00 / 1M tokens`),
|
|
16069
16092
|
},
|
|
16070
16093
|
},
|
|
16071
16094
|
/**/
|
|
@@ -16645,8 +16668,8 @@
|
|
|
16645
16668
|
modelName: 'deepseek-chat',
|
|
16646
16669
|
modelDescription: 'General-purpose language model with strong performance across conversation, reasoning, and content generation. 128K context window with excellent instruction following capabilities.',
|
|
16647
16670
|
pricing: {
|
|
16648
|
-
prompt:
|
|
16649
|
-
output:
|
|
16671
|
+
prompt: pricing(`$0.80 / 1M tokens`),
|
|
16672
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
16650
16673
|
},
|
|
16651
16674
|
},
|
|
16652
16675
|
{
|
|
@@ -16655,8 +16678,8 @@
|
|
|
16655
16678
|
modelName: 'deepseek-reasoner',
|
|
16656
16679
|
modelDescription: 'Specialized model focused on complex reasoning tasks like mathematical problem-solving and logical analysis. Enhanced step-by-step reasoning with explicit chain-of-thought processes. 128K context window.',
|
|
16657
16680
|
pricing: {
|
|
16658
|
-
prompt:
|
|
16659
|
-
output:
|
|
16681
|
+
prompt: pricing(`$3.50 / 1M tokens`),
|
|
16682
|
+
output: pricing(`$7.00 / 1M tokens`),
|
|
16660
16683
|
},
|
|
16661
16684
|
},
|
|
16662
16685
|
{
|
|
@@ -16665,8 +16688,8 @@
|
|
|
16665
16688
|
modelName: 'deepseek-v3-0324',
|
|
16666
16689
|
modelDescription: 'Advanced general-purpose model with improved reasoning, coding abilities, and multimodal understanding. Built on the latest DeepSeek architecture with enhanced knowledge representation.',
|
|
16667
16690
|
pricing: {
|
|
16668
|
-
prompt:
|
|
16669
|
-
output:
|
|
16691
|
+
prompt: pricing(`$1.50 / 1M tokens`),
|
|
16692
|
+
output: pricing(`$3.00 / 1M tokens`),
|
|
16670
16693
|
},
|
|
16671
16694
|
},
|
|
16672
16695
|
{
|
|
@@ -16675,11 +16698,31 @@
|
|
|
16675
16698
|
modelName: 'deepseek-r1',
|
|
16676
16699
|
modelDescription: 'Research-focused model optimized for scientific problem-solving and analytical tasks. Excellent performance on tasks requiring domain-specific expertise and critical thinking.',
|
|
16677
16700
|
pricing: {
|
|
16678
|
-
prompt:
|
|
16679
|
-
output:
|
|
16701
|
+
prompt: pricing(`$5.00 / 1M tokens`),
|
|
16702
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
16680
16703
|
},
|
|
16681
16704
|
},
|
|
16682
|
-
|
|
16705
|
+
{
|
|
16706
|
+
modelVariant: 'EMBEDDING',
|
|
16707
|
+
modelTitle: 'DeepSeek Embedder',
|
|
16708
|
+
modelName: 'deepseek-embedder-v1',
|
|
16709
|
+
modelDescription: 'High-quality text embedding model',
|
|
16710
|
+
pricing: {
|
|
16711
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
16712
|
+
output: 0,
|
|
16713
|
+
},
|
|
16714
|
+
},
|
|
16715
|
+
{
|
|
16716
|
+
modelVariant: 'CHAT',
|
|
16717
|
+
modelTitle: 'DeepSeek Vision',
|
|
16718
|
+
modelName: 'deepseek-vision-v2',
|
|
16719
|
+
modelDescription: 'Multimodal model for image + text tasks',
|
|
16720
|
+
pricing: {
|
|
16721
|
+
prompt: pricing(`$1.20 / 1M tokens`),
|
|
16722
|
+
output: pricing(`$2.40 / 1M tokens`),
|
|
16723
|
+
},
|
|
16724
|
+
},
|
|
16725
|
+
// …add any additional at https://www.deepseek.com/models…
|
|
16683
16726
|
],
|
|
16684
16727
|
});
|
|
16685
16728
|
/**
|
|
@@ -16804,8 +16847,8 @@
|
|
|
16804
16847
|
modelName: 'gemini-2.5-pro-preview-03-25',
|
|
16805
16848
|
modelDescription: 'Latest advanced multimodal model with exceptional reasoning, tool use, and instruction following. 1M token context window with improved vision capabilities for complex visual tasks.',
|
|
16806
16849
|
pricing: {
|
|
16807
|
-
prompt:
|
|
16808
|
-
output:
|
|
16850
|
+
prompt: pricing(`$8.00 / 1M tokens`),
|
|
16851
|
+
output: pricing(`$24.00 / 1M tokens`),
|
|
16809
16852
|
},
|
|
16810
16853
|
},
|
|
16811
16854
|
{
|
|
@@ -16814,8 +16857,8 @@
|
|
|
16814
16857
|
modelName: 'gemini-2.0-flash',
|
|
16815
16858
|
modelDescription: 'Fast, efficient model optimized for rapid response times. Good balance between performance and cost, with strong capabilities across text, code, and reasoning tasks. 128K context window.',
|
|
16816
16859
|
pricing: {
|
|
16817
|
-
prompt:
|
|
16818
|
-
output:
|
|
16860
|
+
prompt: pricing(`$0.35 / 1M tokens`),
|
|
16861
|
+
output: pricing(`$1.05 / 1M tokens`),
|
|
16819
16862
|
},
|
|
16820
16863
|
},
|
|
16821
16864
|
{
|
|
@@ -16824,8 +16867,8 @@
|
|
|
16824
16867
|
modelName: 'gemini-2.0-flash-lite',
|
|
16825
16868
|
modelDescription: 'Streamlined version of Gemini 2.0 Flash, designed for extremely low-latency applications and edge deployments. Optimized for efficiency while maintaining core capabilities.',
|
|
16826
16869
|
pricing: {
|
|
16827
|
-
prompt:
|
|
16828
|
-
output:
|
|
16870
|
+
prompt: pricing(`$0.20 / 1M tokens`),
|
|
16871
|
+
output: pricing(`$0.60 / 1M tokens`),
|
|
16829
16872
|
},
|
|
16830
16873
|
},
|
|
16831
16874
|
{
|
|
@@ -16834,8 +16877,8 @@
|
|
|
16834
16877
|
modelName: 'gemini-2.0-flash-thinking-exp-01-21',
|
|
16835
16878
|
modelDescription: 'Experimental model focused on enhanced reasoning with explicit chain-of-thought processes. Designed for tasks requiring structured thinking and problem-solving approaches.',
|
|
16836
16879
|
pricing: {
|
|
16837
|
-
prompt:
|
|
16838
|
-
output:
|
|
16880
|
+
prompt: pricing(`$0.35 / 1M tokens`),
|
|
16881
|
+
output: pricing(`$1.05 / 1M tokens`),
|
|
16839
16882
|
},
|
|
16840
16883
|
},
|
|
16841
16884
|
{
|
|
@@ -16844,8 +16887,8 @@
|
|
|
16844
16887
|
modelName: 'gemini-1.5-flash',
|
|
16845
16888
|
modelDescription: 'Efficient model balancing speed and quality for general-purpose applications. 1M token context window with good multimodal capabilities and quick response times.',
|
|
16846
16889
|
pricing: {
|
|
16847
|
-
prompt:
|
|
16848
|
-
output:
|
|
16890
|
+
prompt: pricing(`$0.25 / 1M tokens`),
|
|
16891
|
+
output: pricing(`$0.75 / 1M tokens`),
|
|
16849
16892
|
},
|
|
16850
16893
|
},
|
|
16851
16894
|
{
|
|
@@ -16902,8 +16945,8 @@
|
|
|
16902
16945
|
modelName: 'gemini-1.5-pro-latest',
|
|
16903
16946
|
modelDescription: 'Points to the most recent version of the flagship Gemini 1.5 Pro model, ensuring access to the latest capabilities and improvements.',
|
|
16904
16947
|
pricing: {
|
|
16905
|
-
prompt:
|
|
16906
|
-
output:
|
|
16948
|
+
prompt: pricing(`$7.00 / 1M tokens`),
|
|
16949
|
+
output: pricing(`$21.00 / 1M tokens`),
|
|
16907
16950
|
},
|
|
16908
16951
|
},
|
|
16909
16952
|
{
|
|
@@ -16912,8 +16955,8 @@
|
|
|
16912
16955
|
modelName: 'gemini-1.5-pro',
|
|
16913
16956
|
modelDescription: 'Flagship multimodal model with strong performance across text, code, vision, and audio tasks. 1M token context window with excellent reasoning capabilities.',
|
|
16914
16957
|
pricing: {
|
|
16915
|
-
prompt:
|
|
16916
|
-
output:
|
|
16958
|
+
prompt: pricing(`$6.00 / 1M tokens`),
|
|
16959
|
+
output: pricing(`$18.00 / 1M tokens`),
|
|
16917
16960
|
},
|
|
16918
16961
|
},
|
|
16919
16962
|
{
|
|
@@ -16940,11 +16983,31 @@
|
|
|
16940
16983
|
modelName: 'gemini-1.0-pro',
|
|
16941
16984
|
modelDescription: 'Original Gemini series foundation model with solid multimodal capabilities. 32K context window with good performance on text, code, and basic vision tasks.',
|
|
16942
16985
|
pricing: {
|
|
16943
|
-
prompt:
|
|
16944
|
-
output:
|
|
16986
|
+
prompt: pricing(`$0.35 / 1M tokens`),
|
|
16987
|
+
output: pricing(`$1.05 / 1M tokens`),
|
|
16945
16988
|
},
|
|
16946
16989
|
},
|
|
16947
|
-
|
|
16990
|
+
{
|
|
16991
|
+
modelVariant: 'EMBEDDING',
|
|
16992
|
+
modelTitle: 'Gemini Embedder',
|
|
16993
|
+
modelName: 'gemini-embedder-v1',
|
|
16994
|
+
modelDescription: 'High-quality embeddings for retrieval',
|
|
16995
|
+
pricing: {
|
|
16996
|
+
prompt: pricing(`$0.08 / 1M tokens`),
|
|
16997
|
+
output: 0,
|
|
16998
|
+
},
|
|
16999
|
+
},
|
|
17000
|
+
{
|
|
17001
|
+
modelVariant: 'CHAT',
|
|
17002
|
+
modelTitle: 'Gemini Pro Vision',
|
|
17003
|
+
modelName: 'gemini-pro-vision-v1',
|
|
17004
|
+
modelDescription: 'Advanced vision + language model',
|
|
17005
|
+
pricing: {
|
|
17006
|
+
prompt: pricing(`$9.00 / 1M tokens`),
|
|
17007
|
+
output: pricing(`$27.00 / 1M tokens`),
|
|
17008
|
+
},
|
|
17009
|
+
},
|
|
17010
|
+
// …add any additional from https://ai.google.dev/models/gemini…
|
|
16948
17011
|
],
|
|
16949
17012
|
});
|
|
16950
17013
|
/**
|
|
@@ -17102,15 +17165,15 @@
|
|
|
17102
17165
|
*/
|
|
17103
17166
|
|
|
17104
17167
|
/**
|
|
17105
|
-
* Execution Tools for calling OpenAI API
|
|
17168
|
+
* Execution Tools for calling OpenAI API or other OpeenAI compatible provider
|
|
17106
17169
|
*
|
|
17107
17170
|
* @public exported from `@promptbook/openai`
|
|
17108
17171
|
*/
|
|
17109
|
-
class
|
|
17172
|
+
class OpenAiCompatibleExecutionTools {
|
|
17110
17173
|
/**
|
|
17111
|
-
* Creates OpenAI Execution Tools.
|
|
17174
|
+
* Creates OpenAI compatible Execution Tools.
|
|
17112
17175
|
*
|
|
17113
|
-
* @param options which are relevant are directly passed to the OpenAI client
|
|
17176
|
+
* @param options which are relevant are directly passed to the OpenAI compatible client
|
|
17114
17177
|
*/
|
|
17115
17178
|
constructor(options) {
|
|
17116
17179
|
this.options = options;
|
|
@@ -17123,12 +17186,6 @@
|
|
|
17123
17186
|
minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
|
|
17124
17187
|
});
|
|
17125
17188
|
}
|
|
17126
|
-
get title() {
|
|
17127
|
-
return 'OpenAI';
|
|
17128
|
-
}
|
|
17129
|
-
get description() {
|
|
17130
|
-
return 'Use all models provided by OpenAI';
|
|
17131
|
-
}
|
|
17132
17189
|
async getClient() {
|
|
17133
17190
|
if (this.client === null) {
|
|
17134
17191
|
// Note: Passing only OpenAI relevant options to OpenAI constructor
|
|
@@ -17139,18 +17196,6 @@
|
|
|
17139
17196
|
}
|
|
17140
17197
|
return this.client;
|
|
17141
17198
|
}
|
|
17142
|
-
/*
|
|
17143
|
-
Note: Commenting this out to avoid circular dependency
|
|
17144
|
-
/**
|
|
17145
|
-
* Create (sub)tools for calling OpenAI API Assistants
|
|
17146
|
-
*
|
|
17147
|
-
* @param assistantId Which assistant to use
|
|
17148
|
-
* @returns Tools for calling OpenAI API Assistants with same token
|
|
17149
|
-
* /
|
|
17150
|
-
public createAssistantSubtools(assistantId: string_token): OpenAiAssistantExecutionTools {
|
|
17151
|
-
return new OpenAiAssistantExecutionTools({ ...this.options, assistantId });
|
|
17152
|
-
}
|
|
17153
|
-
*/
|
|
17154
17199
|
/**
|
|
17155
17200
|
* Check the `options` passed to `constructor`
|
|
17156
17201
|
*/
|
|
@@ -17159,23 +17204,15 @@
|
|
|
17159
17204
|
// TODO: [🎍] Do here a real check that API is online, working and API key is correct
|
|
17160
17205
|
}
|
|
17161
17206
|
/**
|
|
17162
|
-
* List all available OpenAI models that can be used
|
|
17207
|
+
* List all available OpenAI compatible models that can be used
|
|
17163
17208
|
*/
|
|
17164
17209
|
async listModels() {
|
|
17165
|
-
/*
|
|
17166
|
-
Note: Dynamic lising of the models
|
|
17167
|
-
const models = await this.openai.models.list({});
|
|
17168
|
-
|
|
17169
|
-
console.log({ models });
|
|
17170
|
-
console.log(models.data);
|
|
17171
|
-
*/
|
|
17172
17210
|
const client = await this.getClient();
|
|
17173
17211
|
const rawModelsList = await client.models.list();
|
|
17174
17212
|
const availableModels = rawModelsList.data
|
|
17175
17213
|
.sort((a, b) => (a.created > b.created ? 1 : -1))
|
|
17176
17214
|
.map((modelFromApi) => {
|
|
17177
|
-
|
|
17178
|
-
const modelFromList = OPENAI_MODELS.find(({ modelName }) => modelName === modelFromApi.id ||
|
|
17215
|
+
const modelFromList = this.HARDCODED_MODELS.find(({ modelName }) => modelName === modelFromApi.id ||
|
|
17179
17216
|
modelName.startsWith(modelFromApi.id) ||
|
|
17180
17217
|
modelFromApi.id.startsWith(modelName));
|
|
17181
17218
|
if (modelFromList !== undefined) {
|
|
@@ -17191,12 +17228,12 @@
|
|
|
17191
17228
|
return availableModels;
|
|
17192
17229
|
}
|
|
17193
17230
|
/**
|
|
17194
|
-
* Calls OpenAI API to use a chat model.
|
|
17231
|
+
* Calls OpenAI compatible API to use a chat model.
|
|
17195
17232
|
*/
|
|
17196
17233
|
async callChatModel(prompt) {
|
|
17197
17234
|
var _a;
|
|
17198
17235
|
if (this.options.isVerbose) {
|
|
17199
|
-
console.info(
|
|
17236
|
+
console.info(`💬 ${this.title} callChatModel call`, { prompt });
|
|
17200
17237
|
}
|
|
17201
17238
|
const { content, parameters, modelRequirements, format } = prompt;
|
|
17202
17239
|
const client = await this.getClient();
|
|
@@ -17257,20 +17294,20 @@
|
|
|
17257
17294
|
}
|
|
17258
17295
|
const complete = $getCurrentDate();
|
|
17259
17296
|
if (!rawResponse.choices[0]) {
|
|
17260
|
-
throw new PipelineExecutionError(
|
|
17297
|
+
throw new PipelineExecutionError(`No choises from ${this.title}`);
|
|
17261
17298
|
}
|
|
17262
17299
|
if (rawResponse.choices.length > 1) {
|
|
17263
17300
|
// TODO: This should be maybe only warning
|
|
17264
|
-
throw new PipelineExecutionError(
|
|
17301
|
+
throw new PipelineExecutionError(`More than one choise from ${this.title}`);
|
|
17265
17302
|
}
|
|
17266
17303
|
const resultContent = rawResponse.choices[0].message.content;
|
|
17267
|
-
const usage =
|
|
17304
|
+
const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
|
|
17268
17305
|
if (resultContent === null) {
|
|
17269
|
-
throw new PipelineExecutionError(
|
|
17306
|
+
throw new PipelineExecutionError(`No response message from ${this.title}`);
|
|
17270
17307
|
}
|
|
17271
17308
|
return exportJson({
|
|
17272
17309
|
name: 'promptResult',
|
|
17273
|
-
message: `Result of \`
|
|
17310
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
|
|
17274
17311
|
order: [],
|
|
17275
17312
|
value: {
|
|
17276
17313
|
content: resultContent,
|
|
@@ -17293,7 +17330,7 @@
|
|
|
17293
17330
|
async callCompletionModel(prompt) {
|
|
17294
17331
|
var _a;
|
|
17295
17332
|
if (this.options.isVerbose) {
|
|
17296
|
-
console.info(
|
|
17333
|
+
console.info(`🖋 ${this.title} callCompletionModel call`, { prompt });
|
|
17297
17334
|
}
|
|
17298
17335
|
const { content, parameters, modelRequirements } = prompt;
|
|
17299
17336
|
const client = await this.getClient();
|
|
@@ -17334,17 +17371,17 @@
|
|
|
17334
17371
|
}
|
|
17335
17372
|
const complete = $getCurrentDate();
|
|
17336
17373
|
if (!rawResponse.choices[0]) {
|
|
17337
|
-
throw new PipelineExecutionError(
|
|
17374
|
+
throw new PipelineExecutionError(`No choises from ${this.title}`);
|
|
17338
17375
|
}
|
|
17339
17376
|
if (rawResponse.choices.length > 1) {
|
|
17340
17377
|
// TODO: This should be maybe only warning
|
|
17341
|
-
throw new PipelineExecutionError(
|
|
17378
|
+
throw new PipelineExecutionError(`More than one choise from ${this.title}`);
|
|
17342
17379
|
}
|
|
17343
17380
|
const resultContent = rawResponse.choices[0].text;
|
|
17344
|
-
const usage =
|
|
17381
|
+
const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
|
|
17345
17382
|
return exportJson({
|
|
17346
17383
|
name: 'promptResult',
|
|
17347
|
-
message: `Result of \`
|
|
17384
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callCompletionModel\``,
|
|
17348
17385
|
order: [],
|
|
17349
17386
|
value: {
|
|
17350
17387
|
content: resultContent,
|
|
@@ -17362,11 +17399,11 @@
|
|
|
17362
17399
|
});
|
|
17363
17400
|
}
|
|
17364
17401
|
/**
|
|
17365
|
-
* Calls OpenAI API to use a embedding model
|
|
17402
|
+
* Calls OpenAI compatible API to use a embedding model
|
|
17366
17403
|
*/
|
|
17367
17404
|
async callEmbeddingModel(prompt) {
|
|
17368
17405
|
if (this.options.isVerbose) {
|
|
17369
|
-
console.info(
|
|
17406
|
+
console.info(`🖋 ${this.title} embedding call`, { prompt });
|
|
17370
17407
|
}
|
|
17371
17408
|
const { content, parameters, modelRequirements } = prompt;
|
|
17372
17409
|
const client = await this.getClient();
|
|
@@ -17401,12 +17438,12 @@
|
|
|
17401
17438
|
throw new PipelineExecutionError(`Expected exactly 1 data item in response, got ${rawResponse.data.length}`);
|
|
17402
17439
|
}
|
|
17403
17440
|
const resultContent = rawResponse.data[0].embedding;
|
|
17404
|
-
const usage =
|
|
17441
|
+
const usage = this.computeUsage(content || '', '',
|
|
17405
17442
|
// <- Note: Embedding does not have result content
|
|
17406
17443
|
rawResponse);
|
|
17407
17444
|
return exportJson({
|
|
17408
17445
|
name: 'promptResult',
|
|
17409
|
-
message: `Result of \`
|
|
17446
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
|
|
17410
17447
|
order: [],
|
|
17411
17448
|
value: {
|
|
17412
17449
|
content: resultContent,
|
|
@@ -17429,65 +17466,171 @@
|
|
|
17429
17466
|
*/
|
|
17430
17467
|
getDefaultModel(defaultModelName) {
|
|
17431
17468
|
// Note: Match exact or prefix for model families
|
|
17432
|
-
const model =
|
|
17469
|
+
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
17433
17470
|
if (model === undefined) {
|
|
17434
|
-
throw new
|
|
17435
|
-
Cannot find model in
|
|
17471
|
+
throw new PipelineExecutionError(spaceTrim__default["default"]((block) => `
|
|
17472
|
+
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
17436
17473
|
|
|
17437
17474
|
Available models:
|
|
17438
|
-
${block(
|
|
17475
|
+
${block(this.HARDCODED_MODELS.map(({ modelName }) => `- "${modelName}"`).join('\n'))}
|
|
17476
|
+
|
|
17477
|
+
Model "${defaultModelName}" is probably not available anymore, not installed, inaccessible or misconfigured.
|
|
17439
17478
|
|
|
17440
17479
|
`));
|
|
17441
17480
|
}
|
|
17442
17481
|
return model;
|
|
17443
17482
|
}
|
|
17444
|
-
/**
|
|
17445
|
-
* Default model for chat variant.
|
|
17446
|
-
*/
|
|
17447
|
-
getDefaultChatModel() {
|
|
17448
|
-
return this.getDefaultModel('gpt-4o');
|
|
17449
|
-
}
|
|
17450
|
-
/**
|
|
17451
|
-
* Default model for completion variant.
|
|
17452
|
-
*/
|
|
17453
|
-
getDefaultCompletionModel() {
|
|
17454
|
-
return this.getDefaultModel('gpt-3.5-turbo-instruct');
|
|
17455
|
-
}
|
|
17456
|
-
/**
|
|
17457
|
-
* Default model for completion variant.
|
|
17458
|
-
*/
|
|
17459
|
-
getDefaultEmbeddingModel() {
|
|
17460
|
-
return this.getDefaultModel('text-embedding-3-large');
|
|
17461
|
-
}
|
|
17462
17483
|
}
|
|
17463
17484
|
/**
|
|
17464
|
-
* TODO: [
|
|
17465
|
-
* TODO: Maybe
|
|
17466
|
-
* TODO: Maybe make custom OpenAiError
|
|
17485
|
+
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
17486
|
+
* TODO: [🛄] Maybe make custom `OpenAiCompatibleError`
|
|
17467
17487
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
17468
17488
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
17469
17489
|
*/
|
|
17470
17490
|
|
|
17471
17491
|
/**
|
|
17472
|
-
*
|
|
17492
|
+
* List of available models in Ollama library
|
|
17473
17493
|
*
|
|
17474
|
-
* Note:
|
|
17494
|
+
* Note: Done at 2025-05-19
|
|
17475
17495
|
*
|
|
17476
|
-
* @
|
|
17496
|
+
* @see https://ollama.com/library
|
|
17497
|
+
* @public exported from `@promptbook/ollama`
|
|
17477
17498
|
*/
|
|
17478
|
-
const
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17499
|
+
const OLLAMA_MODELS = exportJson({
|
|
17500
|
+
name: 'OLLAMA_MODELS',
|
|
17501
|
+
value: [
|
|
17502
|
+
{
|
|
17503
|
+
modelVariant: 'CHAT',
|
|
17504
|
+
modelTitle: 'llama2',
|
|
17505
|
+
modelName: 'llama2',
|
|
17506
|
+
modelDescription: 'Meta Llama 2, a general-purpose large language model.',
|
|
17507
|
+
},
|
|
17508
|
+
{
|
|
17509
|
+
modelVariant: 'CHAT',
|
|
17510
|
+
modelTitle: 'llama2-chat',
|
|
17511
|
+
modelName: 'llama2-chat',
|
|
17512
|
+
modelDescription: 'Meta Llama 2 Chat, optimized for conversational tasks.',
|
|
17513
|
+
},
|
|
17514
|
+
{
|
|
17515
|
+
modelVariant: 'CHAT',
|
|
17516
|
+
modelTitle: 'alpaca-7b',
|
|
17517
|
+
modelName: 'alpaca-7b',
|
|
17518
|
+
modelDescription: 'Stanford Alpaca 7B, instruction-tuned LLaMA model.',
|
|
17519
|
+
},
|
|
17520
|
+
{
|
|
17521
|
+
modelVariant: 'CHAT',
|
|
17522
|
+
modelTitle: 'alpaca-30b',
|
|
17523
|
+
modelName: 'alpaca-30b',
|
|
17524
|
+
modelDescription: 'Stanford Alpaca 30B, larger instruction-tuned LLaMA model.',
|
|
17525
|
+
},
|
|
17526
|
+
{
|
|
17527
|
+
modelVariant: 'CHAT',
|
|
17528
|
+
modelTitle: 'vicuna-13b',
|
|
17529
|
+
modelName: 'vicuna-13b',
|
|
17530
|
+
modelDescription: 'Vicuna 13B, fine-tuned LLaMA for chat and instruction.',
|
|
17531
|
+
},
|
|
17532
|
+
{
|
|
17533
|
+
modelVariant: 'CHAT',
|
|
17534
|
+
modelTitle: 'falcon-7b',
|
|
17535
|
+
modelName: 'falcon-7b',
|
|
17536
|
+
modelDescription: 'Falcon 7B, a performant open large language model.',
|
|
17537
|
+
},
|
|
17538
|
+
{
|
|
17539
|
+
modelVariant: 'CHAT',
|
|
17540
|
+
modelTitle: 'falcon-40b',
|
|
17541
|
+
modelName: 'falcon-40b',
|
|
17542
|
+
modelDescription: 'Falcon 40B, a larger open large language model.',
|
|
17543
|
+
},
|
|
17544
|
+
{
|
|
17545
|
+
modelVariant: 'CHAT',
|
|
17546
|
+
modelTitle: 'bloom-7b',
|
|
17547
|
+
modelName: 'bloom-7b',
|
|
17548
|
+
modelDescription: 'BLOOM 7B, multilingual large language model.',
|
|
17549
|
+
},
|
|
17550
|
+
{
|
|
17551
|
+
modelVariant: 'CHAT',
|
|
17552
|
+
modelTitle: 'mistral-7b',
|
|
17553
|
+
modelName: 'mistral-7b',
|
|
17554
|
+
modelDescription: 'Mistral 7B, efficient and fast open LLM.',
|
|
17555
|
+
},
|
|
17556
|
+
{
|
|
17557
|
+
modelVariant: 'CHAT',
|
|
17558
|
+
modelTitle: 'gorilla',
|
|
17559
|
+
modelName: 'gorilla',
|
|
17560
|
+
modelDescription: 'Gorilla, open-source LLM for tool use and APIs.',
|
|
17561
|
+
},
|
|
17562
|
+
{
|
|
17563
|
+
modelVariant: 'CHAT',
|
|
17564
|
+
modelTitle: 'cerebras-13b',
|
|
17565
|
+
modelName: 'cerebras-13b',
|
|
17566
|
+
modelDescription: 'Cerebras-GPT 13B, open large language model.',
|
|
17567
|
+
},
|
|
17568
|
+
{
|
|
17569
|
+
modelVariant: 'CHAT',
|
|
17570
|
+
modelTitle: 'openchat-7b',
|
|
17571
|
+
modelName: 'openchat-7b',
|
|
17572
|
+
modelDescription: 'OpenChat 7B, fine-tuned for conversational tasks.',
|
|
17573
|
+
},
|
|
17574
|
+
{
|
|
17575
|
+
modelVariant: 'CHAT',
|
|
17576
|
+
modelTitle: 'openchat-13b',
|
|
17577
|
+
modelName: 'openchat-13b',
|
|
17578
|
+
modelDescription: 'OpenChat 13B, larger conversational LLM.',
|
|
17579
|
+
},
|
|
17580
|
+
{
|
|
17581
|
+
modelVariant: 'CHAT',
|
|
17582
|
+
modelTitle: 'mpt-7b-chat',
|
|
17583
|
+
modelName: 'mpt-7b-chat',
|
|
17584
|
+
modelDescription: 'MPT-7B Chat, optimized for dialogue and chat.',
|
|
17585
|
+
},
|
|
17586
|
+
{
|
|
17587
|
+
modelVariant: 'CHAT',
|
|
17588
|
+
modelTitle: 'mpt-7b-instruct',
|
|
17589
|
+
modelName: 'mpt-7b-instruct',
|
|
17590
|
+
modelDescription: 'MPT-7B Instruct, instruction-tuned variant.',
|
|
17591
|
+
},
|
|
17592
|
+
{
|
|
17593
|
+
modelVariant: 'CHAT',
|
|
17594
|
+
modelTitle: 'command-7b',
|
|
17595
|
+
modelName: 'command-7b',
|
|
17596
|
+
modelDescription: 'Command 7B, instruction-following LLM.',
|
|
17597
|
+
},
|
|
17598
|
+
{
|
|
17599
|
+
modelVariant: 'CHAT',
|
|
17600
|
+
modelTitle: 'starcoder',
|
|
17601
|
+
modelName: 'starcoder',
|
|
17602
|
+
modelDescription: 'StarCoder, code generation large language model.',
|
|
17603
|
+
},
|
|
17604
|
+
{
|
|
17605
|
+
modelVariant: 'CHAT',
|
|
17606
|
+
modelTitle: 'starcoder2',
|
|
17607
|
+
modelName: 'starcoder2',
|
|
17608
|
+
modelDescription: 'StarCoder2, improved code generation model.',
|
|
17609
|
+
},
|
|
17610
|
+
{
|
|
17611
|
+
modelVariant: 'CHAT',
|
|
17612
|
+
modelTitle: 'mixtral-7b-chat',
|
|
17613
|
+
modelName: 'mixtral-7b-chat',
|
|
17614
|
+
modelDescription: 'Mixtral 7B Chat, Mixture-of-Experts conversational model.',
|
|
17615
|
+
},
|
|
17616
|
+
{
|
|
17617
|
+
modelVariant: 'CHAT',
|
|
17618
|
+
modelTitle: 'mixtral-8x7b',
|
|
17619
|
+
modelName: 'mixtral-8x7b',
|
|
17620
|
+
modelDescription: 'Mixtral 8x7B, Mixture-of-Experts large language model.',
|
|
17621
|
+
},
|
|
17622
|
+
{
|
|
17623
|
+
modelVariant: 'CHAT',
|
|
17624
|
+
modelTitle: 'mixtral-8x7b-instruct',
|
|
17625
|
+
modelName: 'mixtral-8x7b-instruct',
|
|
17626
|
+
modelDescription: 'Mixtral 8x7B Instruct, instruction-tuned Mixture-of-Experts model.',
|
|
17627
|
+
},
|
|
17628
|
+
// <- [🕕]
|
|
17629
|
+
],
|
|
17487
17630
|
});
|
|
17488
17631
|
/**
|
|
17489
|
-
* TODO: [
|
|
17490
|
-
*
|
|
17632
|
+
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
17633
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17491
17634
|
*/
|
|
17492
17635
|
|
|
17493
17636
|
/**
|
|
@@ -17495,22 +17638,79 @@
|
|
|
17495
17638
|
*
|
|
17496
17639
|
* @public exported from `@promptbook/ollama`
|
|
17497
17640
|
*/
|
|
17498
|
-
const DEFAULT_OLLAMA_BASE_URL = 'http://localhost:11434';
|
|
17641
|
+
const DEFAULT_OLLAMA_BASE_URL = 'http://localhost:11434/v1';
|
|
17499
17642
|
|
|
17500
17643
|
/**
|
|
17501
17644
|
* Execution Tools for calling Ollama API
|
|
17502
17645
|
*
|
|
17503
17646
|
* @public exported from `@promptbook/ollama`
|
|
17504
17647
|
*/
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17648
|
+
class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
17649
|
+
/* <- TODO: [🍚] `, Destroyable` */
|
|
17650
|
+
constructor(ollamaOptions) {
|
|
17651
|
+
const openAiCompatibleOptions = {
|
|
17652
|
+
baseURL: DEFAULT_OLLAMA_BASE_URL,
|
|
17653
|
+
...ollamaOptions,
|
|
17654
|
+
userId: 'ollama',
|
|
17655
|
+
};
|
|
17656
|
+
super(openAiCompatibleOptions);
|
|
17657
|
+
}
|
|
17658
|
+
get title() {
|
|
17659
|
+
return 'Ollama';
|
|
17660
|
+
}
|
|
17661
|
+
get description() {
|
|
17662
|
+
return 'Use all models provided by Ollama';
|
|
17663
|
+
}
|
|
17664
|
+
/**
|
|
17665
|
+
* List all available models (non dynamically)
|
|
17666
|
+
*
|
|
17667
|
+
* Note: Purpose of this is to provide more information about models than standard listing from API
|
|
17668
|
+
*/
|
|
17669
|
+
get HARDCODED_MODELS() {
|
|
17670
|
+
return OLLAMA_MODELS;
|
|
17671
|
+
}
|
|
17672
|
+
/**
|
|
17673
|
+
* Computes the usage of the Ollama API based on the response from Ollama
|
|
17674
|
+
*/
|
|
17675
|
+
computeUsage(...args) {
|
|
17676
|
+
return {
|
|
17677
|
+
...computeOpenAiUsage(...args),
|
|
17678
|
+
price: ZERO_VALUE, // <- Note: Running on local model, so no price, maybe in the future we can add a way to calculate price based on electricity usage
|
|
17679
|
+
};
|
|
17680
|
+
}
|
|
17681
|
+
/**
|
|
17682
|
+
* Default model for chat variant.
|
|
17683
|
+
*/
|
|
17684
|
+
getDefaultChatModel() {
|
|
17685
|
+
return this.getDefaultModel('llama2'); // <- TODO: [🧠] Pick the best default model
|
|
17686
|
+
// <- TODO: [🛄] When 'llama2' not installed, maybe better error message
|
|
17687
|
+
}
|
|
17688
|
+
/**
|
|
17689
|
+
* Default model for completion variant.
|
|
17690
|
+
*/
|
|
17691
|
+
getDefaultCompletionModel() {
|
|
17692
|
+
return this.getDefaultModel('llama2'); // <- TODO: [🧠] Pick the best default model
|
|
17693
|
+
// <- TODO: [🛄] When 'llama2' not installed, maybe better error message
|
|
17694
|
+
}
|
|
17695
|
+
/**
|
|
17696
|
+
* Default model for completion variant.
|
|
17697
|
+
*/
|
|
17698
|
+
getDefaultEmbeddingModel() {
|
|
17699
|
+
return this.getDefaultModel('text-embedding-3-large'); // <- TODO: [🧠] Pick the best default model
|
|
17700
|
+
// <- TODO: [🛄]
|
|
17701
|
+
}
|
|
17702
|
+
}
|
|
17703
|
+
/**
|
|
17704
|
+
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
17705
|
+
*/
|
|
17706
|
+
|
|
17707
|
+
/**
|
|
17708
|
+
* Execution Tools for calling Ollama API
|
|
17709
|
+
*
|
|
17710
|
+
* @public exported from `@promptbook/ollama`
|
|
17711
|
+
*/
|
|
17712
|
+
const createOllamaExecutionTools = Object.assign((options) => {
|
|
17713
|
+
return new OllamaExecutionTools(options);
|
|
17514
17714
|
}, {
|
|
17515
17715
|
packageName: '@promptbook/ollama',
|
|
17516
17716
|
className: 'OllamaExecutionTools',
|
|
@@ -17625,6 +17825,67 @@
|
|
|
17625
17825
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17626
17826
|
*/
|
|
17627
17827
|
|
|
17828
|
+
/**
|
|
17829
|
+
* Execution Tools for calling OpenAI API
|
|
17830
|
+
*
|
|
17831
|
+
* @public exported from `@promptbook/openai`
|
|
17832
|
+
*/
|
|
17833
|
+
class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
17834
|
+
constructor() {
|
|
17835
|
+
super(...arguments);
|
|
17836
|
+
/**
|
|
17837
|
+
* Computes the usage of the OpenAI API based on the response from OpenAI
|
|
17838
|
+
*/
|
|
17839
|
+
this.computeUsage = computeOpenAiUsage;
|
|
17840
|
+
// <- Note: [🤖] getDefaultXxxModel
|
|
17841
|
+
}
|
|
17842
|
+
/* <- TODO: [🍚] `, Destroyable` */
|
|
17843
|
+
get title() {
|
|
17844
|
+
return 'OpenAI';
|
|
17845
|
+
}
|
|
17846
|
+
get description() {
|
|
17847
|
+
return 'Use all models provided by OpenAI';
|
|
17848
|
+
}
|
|
17849
|
+
/*
|
|
17850
|
+
Note: Commenting this out to avoid circular dependency
|
|
17851
|
+
/**
|
|
17852
|
+
* Create (sub)tools for calling OpenAI API Assistants
|
|
17853
|
+
*
|
|
17854
|
+
* @param assistantId Which assistant to use
|
|
17855
|
+
* @returns Tools for calling OpenAI API Assistants with same token
|
|
17856
|
+
* /
|
|
17857
|
+
public createAssistantSubtools(assistantId: string_token): OpenAiAssistantExecutionTools {
|
|
17858
|
+
return new OpenAiAssistantExecutionTools({ ...this.options, assistantId });
|
|
17859
|
+
}
|
|
17860
|
+
*/
|
|
17861
|
+
/**
|
|
17862
|
+
* List all available models (non dynamically)
|
|
17863
|
+
*
|
|
17864
|
+
* Note: Purpose of this is to provide more information about models than standard listing from API
|
|
17865
|
+
*/
|
|
17866
|
+
get HARDCODED_MODELS() {
|
|
17867
|
+
return OPENAI_MODELS;
|
|
17868
|
+
}
|
|
17869
|
+
/**
|
|
17870
|
+
* Default model for chat variant.
|
|
17871
|
+
*/
|
|
17872
|
+
getDefaultChatModel() {
|
|
17873
|
+
return this.getDefaultModel('gpt-4o');
|
|
17874
|
+
}
|
|
17875
|
+
/**
|
|
17876
|
+
* Default model for completion variant.
|
|
17877
|
+
*/
|
|
17878
|
+
getDefaultCompletionModel() {
|
|
17879
|
+
return this.getDefaultModel('gpt-3.5-turbo-instruct');
|
|
17880
|
+
}
|
|
17881
|
+
/**
|
|
17882
|
+
* Default model for completion variant.
|
|
17883
|
+
*/
|
|
17884
|
+
getDefaultEmbeddingModel() {
|
|
17885
|
+
return this.getDefaultModel('text-embedding-3-large');
|
|
17886
|
+
}
|
|
17887
|
+
}
|
|
17888
|
+
|
|
17628
17889
|
/**
|
|
17629
17890
|
* Execution Tools for calling OpenAI API Assistants
|
|
17630
17891
|
*
|
|
@@ -17812,6 +18073,27 @@
|
|
|
17812
18073
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
17813
18074
|
*/
|
|
17814
18075
|
|
|
18076
|
+
/**
|
|
18077
|
+
* Execution Tools for calling OpenAI API
|
|
18078
|
+
*
|
|
18079
|
+
* Note: This can be also used for other OpenAI compatible APIs, like Ollama
|
|
18080
|
+
*
|
|
18081
|
+
* @public exported from `@promptbook/openai`
|
|
18082
|
+
*/
|
|
18083
|
+
const createOpenAiExecutionTools = Object.assign((options) => {
|
|
18084
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
18085
|
+
options = { ...options, dangerouslyAllowBrowser: true };
|
|
18086
|
+
}
|
|
18087
|
+
return new OpenAiExecutionTools(options);
|
|
18088
|
+
}, {
|
|
18089
|
+
packageName: '@promptbook/openai',
|
|
18090
|
+
className: 'OpenAiExecutionTools',
|
|
18091
|
+
});
|
|
18092
|
+
/**
|
|
18093
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
18094
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
18095
|
+
*/
|
|
18096
|
+
|
|
17815
18097
|
/**
|
|
17816
18098
|
* Registration of LLM provider
|
|
17817
18099
|
*
|