@promptbook/cli 0.94.0-2 → 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 CHANGED
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.94.0-2';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.94.0-4';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -11822,7 +11822,7 @@ function extractBlock(markdown) {
11822
11822
  function preserve(func) {
11823
11823
  // Note: NOT calling the function
11824
11824
  (async () => {
11825
- // TODO: [💩] Change to `await forEver` or something better
11825
+ // TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
11826
11826
  await forTime(100000000);
11827
11827
  // [1]
11828
11828
  try {
@@ -12437,7 +12437,10 @@ function usageToWorktime(usage) {
12437
12437
  function usageToHuman(usage) {
12438
12438
  const reportItems = [];
12439
12439
  const uncertainNumberToHuman = ({ value, isUncertain }) => `${isUncertain ? 'approximately ' : ''}${Math.round(value * 100) / 100}`;
12440
- if (usage.price.value > 0.01
12440
+ if (usage.price.value === 0) {
12441
+ reportItems.push(`Zero cost`);
12442
+ }
12443
+ else if (usage.price.value > 0.01
12441
12444
  // <- TODO: [🍓][🧞‍♂️][👩🏽‍🤝‍🧑🏻] Configure negligible value - default value to config + value to `UsageToHumanSettings`
12442
12445
  ) {
12443
12446
  reportItems.push(`Cost ${uncertainNumberToHuman(usage.price)} USD`);
@@ -15067,11 +15070,11 @@ const _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register(
15067
15070
  */
15068
15071
 
15069
15072
  /**
15070
- * Function computeUsage will create price per one token based on the string value found on openai page
15073
+ * Create price per one token based on the string value found on openai page
15071
15074
  *
15072
15075
  * @private within the repository, used only as internal helper for `OPENAI_MODELS`
15073
15076
  */
15074
- function computeUsage(value) {
15077
+ function pricing(value) {
15075
15078
  const [price, tokens] = value.split(' / ');
15076
15079
  return parseFloat(price.replace('$', '')) / parseFloat(tokens.replace('M tokens', '')) / 1000000;
15077
15080
  }
@@ -15093,8 +15096,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15093
15096
  modelName: 'claude-3-5-sonnet-20240620',
15094
15097
  modelDescription: 'Latest Claude model with great reasoning, coding, and language understanding capabilities. 200K context window. Optimized balance of intelligence and speed.',
15095
15098
  pricing: {
15096
- prompt: computeUsage(`$2.50 / 1M tokens`),
15097
- output: computeUsage(`$12.50 / 1M tokens`),
15099
+ prompt: pricing(`$2.50 / 1M tokens`),
15100
+ output: pricing(`$12.50 / 1M tokens`),
15098
15101
  },
15099
15102
  },
15100
15103
  {
@@ -15103,8 +15106,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15103
15106
  modelName: 'claude-3-opus-20240229',
15104
15107
  modelDescription: 'Most capable Claude model excelling at complex reasoning, coding, and detailed instruction following. 200K context window. Best for sophisticated tasks requiring nuanced understanding.',
15105
15108
  pricing: {
15106
- prompt: computeUsage(`$12.00 / 1M tokens`),
15107
- output: computeUsage(`$60.00 / 1M tokens`),
15109
+ prompt: pricing(`$12.00 / 1M tokens`),
15110
+ output: pricing(`$60.00 / 1M tokens`),
15108
15111
  },
15109
15112
  },
15110
15113
  {
@@ -15113,8 +15116,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15113
15116
  modelName: 'claude-3-sonnet-20240229',
15114
15117
  modelDescription: 'Strong general-purpose model with excellent performance across reasoning, conversation, and coding tasks. 200K context window. Good balance of intelligence and cost-efficiency.',
15115
15118
  pricing: {
15116
- prompt: computeUsage(`$3.00 / 1M tokens`),
15117
- output: computeUsage(`$15.00 / 1M tokens`),
15119
+ prompt: pricing(`$3.00 / 1M tokens`),
15120
+ output: pricing(`$15.00 / 1M tokens`),
15118
15121
  },
15119
15122
  },
15120
15123
  {
@@ -15123,8 +15126,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15123
15126
  modelName: ' claude-3-haiku-20240307',
15124
15127
  modelDescription: 'Fastest and most compact Claude model optimized for responsiveness in interactive applications. 200K context window. Excellent for quick responses and lightweight applications.',
15125
15128
  pricing: {
15126
- prompt: computeUsage(`$0.25 / 1M tokens`),
15127
- output: computeUsage(`$1.25 / 1M tokens`),
15129
+ prompt: pricing(`$0.25 / 1M tokens`),
15130
+ output: pricing(`$1.25 / 1M tokens`),
15128
15131
  },
15129
15132
  },
15130
15133
  {
@@ -15133,8 +15136,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15133
15136
  modelName: 'claude-2.1',
15134
15137
  modelDescription: 'Improved version of Claude 2 with better performance across reasoning and truthfulness. 100K context window. Legacy model with strong reliability.',
15135
15138
  pricing: {
15136
- prompt: computeUsage(`$8.00 / 1M tokens`),
15137
- output: computeUsage(`$24.00 / 1M tokens`),
15139
+ prompt: pricing(`$8.00 / 1M tokens`),
15140
+ output: pricing(`$24.00 / 1M tokens`),
15138
15141
  },
15139
15142
  },
15140
15143
  {
@@ -15143,8 +15146,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15143
15146
  modelName: 'claude-2.0',
15144
15147
  modelDescription: 'Legacy model with strong general reasoning and language capabilities. 100K context window. Superseded by newer Claude 3 models.',
15145
15148
  pricing: {
15146
- prompt: computeUsage(`$8.00 / 1M tokens`),
15147
- output: computeUsage(`$24.00 / 1M tokens`),
15149
+ prompt: pricing(`$8.00 / 1M tokens`),
15150
+ output: pricing(`$24.00 / 1M tokens`),
15148
15151
  },
15149
15152
  },
15150
15153
  {
@@ -15153,8 +15156,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15153
15156
  modelName: 'claude-instant-1.2',
15154
15157
  modelDescription: 'Older, faster Claude model optimized for high throughput applications. Lower cost but less capable than newer models. 100K context window.',
15155
15158
  pricing: {
15156
- prompt: computeUsage(`$0.80 / 1M tokens`),
15157
- output: computeUsage(`$2.40 / 1M tokens`),
15159
+ prompt: pricing(`$0.80 / 1M tokens`),
15160
+ output: pricing(`$2.40 / 1M tokens`),
15158
15161
  },
15159
15162
  },
15160
15163
  {
@@ -15163,8 +15166,8 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15163
15166
  modelName: 'claude-3-7-sonnet-20250219',
15164
15167
  modelDescription: 'Latest generation Claude model with advanced reasoning and language understanding. Enhanced capabilities over 3.5 with improved domain knowledge. 200K context window.',
15165
15168
  pricing: {
15166
- prompt: computeUsage(`$2.50 / 1M tokens`),
15167
- output: computeUsage(`$12.50 / 1M tokens`),
15169
+ prompt: pricing(`$2.50 / 1M tokens`),
15170
+ output: pricing(`$12.50 / 1M tokens`),
15168
15171
  },
15169
15172
  },
15170
15173
  {
@@ -15173,11 +15176,31 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
15173
15176
  modelName: 'claude-3-5-haiku-20241022',
15174
15177
  modelDescription: 'Fast and efficient Claude 3.5 variant optimized for speed and cost-effectiveness. Great for interactive applications requiring quick responses. 200K context window.',
15175
15178
  pricing: {
15176
- prompt: computeUsage(`$0.25 / 1M tokens`),
15177
- output: computeUsage(`$1.25 / 1M tokens`),
15179
+ prompt: pricing(`$0.25 / 1M tokens`),
15180
+ output: pricing(`$1.25 / 1M tokens`),
15178
15181
  },
15179
15182
  },
15180
- // <- [🕕]
15183
+ {
15184
+ modelVariant: 'CHAT',
15185
+ modelTitle: 'Claude 3.7 Haiku',
15186
+ modelName: 'claude-3-7-haiku-20250115',
15187
+ modelDescription: 'Ultra-fast Claude variant for lightweight applications',
15188
+ pricing: {
15189
+ prompt: pricing(`$0.20 / 1M tokens`),
15190
+ output: pricing(`$1.00 / 1M tokens`),
15191
+ },
15192
+ },
15193
+ {
15194
+ modelVariant: 'CHAT',
15195
+ modelTitle: 'Claude Embedding',
15196
+ modelName: 'claude-embedding-1',
15197
+ modelDescription: 'Model optimized for text embeddings',
15198
+ pricing: {
15199
+ prompt: pricing(`$0.05 / 1M tokens`),
15200
+ output: 0,
15201
+ },
15202
+ },
15203
+ // …add any additional models from https://docs.anthropic.com/en/docs/models-overview…
15181
15204
  ],
15182
15205
  });
15183
15206
  /**
@@ -15642,8 +15665,8 @@ const OPENAI_MODELS = exportJson({
15642
15665
  modelName: 'davinci-002',
15643
15666
  modelDescription: 'Legacy completion model with strong performance on text generation tasks. Optimized for complex instructions and longer outputs.',
15644
15667
  pricing: {
15645
- prompt: computeUsage(`$2.00 / 1M tokens`),
15646
- output: computeUsage(`$2.00 / 1M tokens`),
15668
+ prompt: pricing(`$2.00 / 1M tokens`),
15669
+ output: pricing(`$2.00 / 1M tokens`),
15647
15670
  },
15648
15671
  },
15649
15672
  /**/
@@ -15660,8 +15683,8 @@ const OPENAI_MODELS = exportJson({
15660
15683
  modelName: 'gpt-3.5-turbo-16k',
15661
15684
  modelDescription: 'GPT-3.5 Turbo with extended 16k token context length for handling longer conversations and documents.',
15662
15685
  pricing: {
15663
- prompt: computeUsage(`$3.00 / 1M tokens`),
15664
- output: computeUsage(`$4.00 / 1M tokens`),
15686
+ prompt: pricing(`$3.00 / 1M tokens`),
15687
+ output: pricing(`$4.00 / 1M tokens`),
15665
15688
  },
15666
15689
  },
15667
15690
  /**/
@@ -15684,8 +15707,8 @@ const OPENAI_MODELS = exportJson({
15684
15707
  modelName: 'gpt-4',
15685
15708
  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.',
15686
15709
  pricing: {
15687
- prompt: computeUsage(`$30.00 / 1M tokens`),
15688
- output: computeUsage(`$60.00 / 1M tokens`),
15710
+ prompt: pricing(`$30.00 / 1M tokens`),
15711
+ output: pricing(`$60.00 / 1M tokens`),
15689
15712
  },
15690
15713
  },
15691
15714
  /**/
@@ -15696,8 +15719,8 @@ const OPENAI_MODELS = exportJson({
15696
15719
  modelName: 'gpt-4-32k',
15697
15720
  modelDescription: 'Extended context version of GPT-4 with a 32K token window for processing very long inputs and generating comprehensive responses for complex tasks.',
15698
15721
  pricing: {
15699
- prompt: computeUsage(`$60.00 / 1M tokens`),
15700
- output: computeUsage(`$120.00 / 1M tokens`),
15722
+ prompt: pricing(`$60.00 / 1M tokens`),
15723
+ output: pricing(`$120.00 / 1M tokens`),
15701
15724
  },
15702
15725
  },
15703
15726
  /**/
@@ -15719,8 +15742,8 @@ const OPENAI_MODELS = exportJson({
15719
15742
  modelName: 'gpt-4-turbo-2024-04-09',
15720
15743
  modelDescription: 'Latest stable GPT-4 Turbo model from April 2024 with enhanced reasoning and context handling capabilities. Offers 128K context window and improved performance.',
15721
15744
  pricing: {
15722
- prompt: computeUsage(`$10.00 / 1M tokens`),
15723
- output: computeUsage(`$30.00 / 1M tokens`),
15745
+ prompt: pricing(`$10.00 / 1M tokens`),
15746
+ output: pricing(`$30.00 / 1M tokens`),
15724
15747
  },
15725
15748
  },
15726
15749
  /**/
@@ -15731,8 +15754,8 @@ const OPENAI_MODELS = exportJson({
15731
15754
  modelName: 'gpt-3.5-turbo-1106',
15732
15755
  modelDescription: 'November 2023 version of GPT-3.5 Turbo with improved instruction following and a 16K token context window.',
15733
15756
  pricing: {
15734
- prompt: computeUsage(`$1.00 / 1M tokens`),
15735
- output: computeUsage(`$2.00 / 1M tokens`),
15757
+ prompt: pricing(`$1.00 / 1M tokens`),
15758
+ output: pricing(`$2.00 / 1M tokens`),
15736
15759
  },
15737
15760
  },
15738
15761
  /**/
@@ -15743,8 +15766,8 @@ const OPENAI_MODELS = exportJson({
15743
15766
  modelName: 'gpt-4-turbo',
15744
15767
  modelDescription: 'More capable model than GPT-4 with improved instruction following, function calling and a 128K token context window for handling very large documents.',
15745
15768
  pricing: {
15746
- prompt: computeUsage(`$10.00 / 1M tokens`),
15747
- output: computeUsage(`$30.00 / 1M tokens`),
15769
+ prompt: pricing(`$10.00 / 1M tokens`),
15770
+ output: pricing(`$30.00 / 1M tokens`),
15748
15771
  },
15749
15772
  },
15750
15773
  /**/
@@ -15755,8 +15778,8 @@ const OPENAI_MODELS = exportJson({
15755
15778
  modelName: 'gpt-3.5-turbo-instruct-0914',
15756
15779
  modelDescription: 'September 2023 version of GPT-3.5 Turbo optimized for completion-style instruction following with a 4K context window.',
15757
15780
  pricing: {
15758
- prompt: computeUsage(`$1.50 / 1M tokens`),
15759
- output: computeUsage(`$2.00 / 1M tokens`), // <- For gpt-3.5-turbo-instruct
15781
+ prompt: pricing(`$1.50 / 1M tokens`),
15782
+ output: pricing(`$2.00 / 1M tokens`), // <- For gpt-3.5-turbo-instruct
15760
15783
  },
15761
15784
  },
15762
15785
  /**/
@@ -15767,8 +15790,8 @@ const OPENAI_MODELS = exportJson({
15767
15790
  modelName: 'gpt-3.5-turbo-instruct',
15768
15791
  modelDescription: 'Optimized version of GPT-3.5 for completion-style API with good instruction following and a 4K token context window.',
15769
15792
  pricing: {
15770
- prompt: computeUsage(`$1.50 / 1M tokens`),
15771
- output: computeUsage(`$2.00 / 1M tokens`),
15793
+ prompt: pricing(`$1.50 / 1M tokens`),
15794
+ output: pricing(`$2.00 / 1M tokens`),
15772
15795
  },
15773
15796
  },
15774
15797
  /**/
@@ -15785,8 +15808,8 @@ const OPENAI_MODELS = exportJson({
15785
15808
  modelName: 'gpt-3.5-turbo',
15786
15809
  modelDescription: 'Latest version of GPT-3.5 Turbo with improved performance and instruction following capabilities. Default 4K context window with options for 16K.',
15787
15810
  pricing: {
15788
- prompt: computeUsage(`$0.50 / 1M tokens`),
15789
- output: computeUsage(`$1.50 / 1M tokens`),
15811
+ prompt: pricing(`$0.50 / 1M tokens`),
15812
+ output: pricing(`$1.50 / 1M tokens`),
15790
15813
  },
15791
15814
  },
15792
15815
  /**/
@@ -15797,8 +15820,8 @@ const OPENAI_MODELS = exportJson({
15797
15820
  modelName: 'gpt-3.5-turbo-0301',
15798
15821
  modelDescription: 'March 2023 version of GPT-3.5 Turbo with a 4K token context window. Legacy model maintained for backward compatibility.',
15799
15822
  pricing: {
15800
- prompt: computeUsage(`$1.50 / 1M tokens`),
15801
- output: computeUsage(`$2.00 / 1M tokens`),
15823
+ prompt: pricing(`$1.50 / 1M tokens`),
15824
+ output: pricing(`$2.00 / 1M tokens`),
15802
15825
  },
15803
15826
  },
15804
15827
  /**/
@@ -15809,8 +15832,8 @@ const OPENAI_MODELS = exportJson({
15809
15832
  modelName: 'babbage-002',
15810
15833
  modelDescription: 'Efficient legacy completion model with a good balance of performance and speed. Suitable for straightforward text generation tasks.',
15811
15834
  pricing: {
15812
- prompt: computeUsage(`$0.40 / 1M tokens`),
15813
- output: computeUsage(`$0.40 / 1M tokens`),
15835
+ prompt: pricing(`$0.40 / 1M tokens`),
15836
+ output: pricing(`$0.40 / 1M tokens`),
15814
15837
  },
15815
15838
  },
15816
15839
  /**/
@@ -15821,8 +15844,8 @@ const OPENAI_MODELS = exportJson({
15821
15844
  modelName: 'gpt-4-1106-preview',
15822
15845
  modelDescription: 'November 2023 preview version of GPT-4 Turbo with improved instruction following and a 128K token context window.',
15823
15846
  pricing: {
15824
- prompt: computeUsage(`$10.00 / 1M tokens`),
15825
- output: computeUsage(`$30.00 / 1M tokens`),
15847
+ prompt: pricing(`$10.00 / 1M tokens`),
15848
+ output: pricing(`$30.00 / 1M tokens`),
15826
15849
  },
15827
15850
  },
15828
15851
  /**/
@@ -15833,8 +15856,8 @@ const OPENAI_MODELS = exportJson({
15833
15856
  modelName: 'gpt-4-0125-preview',
15834
15857
  modelDescription: 'January 2024 preview version of GPT-4 Turbo with improved reasoning capabilities and a 128K token context window.',
15835
15858
  pricing: {
15836
- prompt: computeUsage(`$10.00 / 1M tokens`),
15837
- output: computeUsage(`$30.00 / 1M tokens`),
15859
+ prompt: pricing(`$10.00 / 1M tokens`),
15860
+ output: pricing(`$30.00 / 1M tokens`),
15838
15861
  },
15839
15862
  },
15840
15863
  /**/
@@ -15851,8 +15874,8 @@ const OPENAI_MODELS = exportJson({
15851
15874
  modelName: 'gpt-3.5-turbo-0125',
15852
15875
  modelDescription: 'January 2024 version of GPT-3.5 Turbo with improved reasoning capabilities and a 16K token context window.',
15853
15876
  pricing: {
15854
- prompt: computeUsage(`$0.50 / 1M tokens`),
15855
- output: computeUsage(`$1.50 / 1M tokens`),
15877
+ prompt: pricing(`$0.50 / 1M tokens`),
15878
+ output: pricing(`$1.50 / 1M tokens`),
15856
15879
  },
15857
15880
  },
15858
15881
  /**/
@@ -15863,8 +15886,8 @@ const OPENAI_MODELS = exportJson({
15863
15886
  modelName: 'gpt-4-turbo-preview',
15864
15887
  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.',
15865
15888
  pricing: {
15866
- prompt: computeUsage(`$10.00 / 1M tokens`),
15867
- output: computeUsage(`$30.00 / 1M tokens`),
15889
+ prompt: pricing(`$10.00 / 1M tokens`),
15890
+ output: pricing(`$30.00 / 1M tokens`),
15868
15891
  },
15869
15892
  },
15870
15893
  /**/
@@ -15875,7 +15898,7 @@ const OPENAI_MODELS = exportJson({
15875
15898
  modelName: 'text-embedding-3-large',
15876
15899
  modelDescription: "OpenAI's most capable text embedding model designed for high-quality embeddings for complex similarity tasks and information retrieval.",
15877
15900
  pricing: {
15878
- prompt: computeUsage(`$0.13 / 1M tokens`),
15901
+ prompt: pricing(`$0.13 / 1M tokens`),
15879
15902
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
15880
15903
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
15881
15904
  },
@@ -15888,7 +15911,7 @@ const OPENAI_MODELS = exportJson({
15888
15911
  modelName: 'text-embedding-3-small',
15889
15912
  modelDescription: 'Cost-effective embedding model with good performance for simpler tasks like text similarity and retrieval. Good balance of quality and efficiency.',
15890
15913
  pricing: {
15891
- prompt: computeUsage(`$0.02 / 1M tokens`),
15914
+ prompt: pricing(`$0.02 / 1M tokens`),
15892
15915
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
15893
15916
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
15894
15917
  },
@@ -15901,8 +15924,8 @@ const OPENAI_MODELS = exportJson({
15901
15924
  modelName: 'gpt-3.5-turbo-0613',
15902
15925
  modelDescription: 'June 2023 version of GPT-3.5 Turbo with function calling capabilities and a 4K token context window.',
15903
15926
  pricing: {
15904
- prompt: computeUsage(`$1.50 / 1M tokens`),
15905
- output: computeUsage(`$2.00 / 1M tokens`),
15927
+ prompt: pricing(`$1.50 / 1M tokens`),
15928
+ output: pricing(`$2.00 / 1M tokens`),
15906
15929
  },
15907
15930
  },
15908
15931
  /**/
@@ -15913,7 +15936,7 @@ const OPENAI_MODELS = exportJson({
15913
15936
  modelName: 'text-embedding-ada-002',
15914
15937
  modelDescription: 'Legacy text embedding model suitable for text similarity and retrieval augmented generation use cases. Replaced by newer embedding-3 models.',
15915
15938
  pricing: {
15916
- prompt: computeUsage(`$0.1 / 1M tokens`),
15939
+ prompt: pricing(`$0.1 / 1M tokens`),
15917
15940
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
15918
15941
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
15919
15942
  },
@@ -15944,8 +15967,8 @@ const OPENAI_MODELS = exportJson({
15944
15967
  modelName: 'gpt-4o-2024-05-13',
15945
15968
  modelDescription: 'May 2024 version of GPT-4o with enhanced multimodal capabilities, improved reasoning, and optimized for vision, audio and chat at lower latencies.',
15946
15969
  pricing: {
15947
- prompt: computeUsage(`$5.00 / 1M tokens`),
15948
- output: computeUsage(`$15.00 / 1M tokens`),
15970
+ prompt: pricing(`$5.00 / 1M tokens`),
15971
+ output: pricing(`$15.00 / 1M tokens`),
15949
15972
  },
15950
15973
  },
15951
15974
  /**/
@@ -15956,8 +15979,8 @@ const OPENAI_MODELS = exportJson({
15956
15979
  modelName: 'gpt-4o',
15957
15980
  modelDescription: "OpenAI's most advanced multimodal model optimized for performance, speed, and cost. Capable of vision, reasoning, and high quality text generation.",
15958
15981
  pricing: {
15959
- prompt: computeUsage(`$5.00 / 1M tokens`),
15960
- output: computeUsage(`$15.00 / 1M tokens`),
15982
+ prompt: pricing(`$5.00 / 1M tokens`),
15983
+ output: pricing(`$15.00 / 1M tokens`),
15961
15984
  },
15962
15985
  },
15963
15986
  /**/
@@ -15968,8 +15991,8 @@ const OPENAI_MODELS = exportJson({
15968
15991
  modelName: 'gpt-4o-mini',
15969
15992
  modelDescription: 'Smaller, more cost-effective version of GPT-4o with good performance across text, vision, and audio tasks at reduced complexity.',
15970
15993
  pricing: {
15971
- prompt: computeUsage(`$0.15 / 1M tokens`),
15972
- output: computeUsage(`$0.60 / 1M tokens`),
15994
+ prompt: pricing(`$0.15 / 1M tokens`),
15995
+ output: pricing(`$0.60 / 1M tokens`),
15973
15996
  },
15974
15997
  },
15975
15998
  /**/
@@ -15980,8 +16003,8 @@ const OPENAI_MODELS = exportJson({
15980
16003
  modelName: 'o1-preview',
15981
16004
  modelDescription: 'Advanced reasoning model with exceptional performance on complex logical, mathematical, and analytical tasks. Built for deep reasoning and specialized professional tasks.',
15982
16005
  pricing: {
15983
- prompt: computeUsage(`$15.00 / 1M tokens`),
15984
- output: computeUsage(`$60.00 / 1M tokens`),
16006
+ prompt: pricing(`$15.00 / 1M tokens`),
16007
+ output: pricing(`$60.00 / 1M tokens`),
15985
16008
  },
15986
16009
  },
15987
16010
  /**/
@@ -15993,8 +16016,8 @@ const OPENAI_MODELS = exportJson({
15993
16016
  modelDescription: 'September 2024 version of O1 preview with specialized reasoning capabilities for complex tasks requiring precise analytical thinking.',
15994
16017
  // <- TODO: [💩] Some better system to organize these date suffixes and versions
15995
16018
  pricing: {
15996
- prompt: computeUsage(`$15.00 / 1M tokens`),
15997
- output: computeUsage(`$60.00 / 1M tokens`),
16019
+ prompt: pricing(`$15.00 / 1M tokens`),
16020
+ output: pricing(`$60.00 / 1M tokens`),
15998
16021
  },
15999
16022
  },
16000
16023
  /**/
@@ -16005,8 +16028,8 @@ const OPENAI_MODELS = exportJson({
16005
16028
  modelName: 'o1-mini',
16006
16029
  modelDescription: 'Smaller, cost-effective version of the O1 model with good performance on reasoning tasks while maintaining efficiency for everyday analytical use.',
16007
16030
  pricing: {
16008
- prompt: computeUsage(`$3.00 / 1M tokens`),
16009
- output: computeUsage(`$12.00 / 1M tokens`),
16031
+ prompt: pricing(`$3.00 / 1M tokens`),
16032
+ output: pricing(`$12.00 / 1M tokens`),
16010
16033
  },
16011
16034
  },
16012
16035
  /**/
@@ -16017,8 +16040,8 @@ const OPENAI_MODELS = exportJson({
16017
16040
  modelName: 'o1',
16018
16041
  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.",
16019
16042
  pricing: {
16020
- prompt: computeUsage(`$15.00 / 1M tokens`),
16021
- output: computeUsage(`$60.00 / 1M tokens`),
16043
+ prompt: pricing(`$15.00 / 1M tokens`),
16044
+ output: pricing(`$60.00 / 1M tokens`),
16022
16045
  },
16023
16046
  },
16024
16047
  /**/
@@ -16029,8 +16052,8 @@ const OPENAI_MODELS = exportJson({
16029
16052
  modelName: 'o3-mini',
16030
16053
  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.',
16031
16054
  pricing: {
16032
- prompt: computeUsage(`$3.00 / 1M tokens`),
16033
- output: computeUsage(`$12.00 / 1M tokens`),
16055
+ prompt: pricing(`$3.00 / 1M tokens`),
16056
+ output: pricing(`$12.00 / 1M tokens`),
16034
16057
  // <- TODO: !! Unsure, check the pricing
16035
16058
  },
16036
16059
  },
@@ -16042,8 +16065,8 @@ const OPENAI_MODELS = exportJson({
16042
16065
  modelName: 'o1-mini-2024-09-12',
16043
16066
  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.",
16044
16067
  pricing: {
16045
- prompt: computeUsage(`$3.00 / 1M tokens`),
16046
- output: computeUsage(`$12.00 / 1M tokens`),
16068
+ prompt: pricing(`$3.00 / 1M tokens`),
16069
+ output: pricing(`$12.00 / 1M tokens`),
16047
16070
  },
16048
16071
  },
16049
16072
  /**/
@@ -16054,8 +16077,8 @@ const OPENAI_MODELS = exportJson({
16054
16077
  modelName: 'gpt-3.5-turbo-16k-0613',
16055
16078
  modelDescription: 'June 2023 version of GPT-3.5 Turbo with extended 16k token context window for processing longer conversations and documents.',
16056
16079
  pricing: {
16057
- prompt: computeUsage(`$3.00 / 1M tokens`),
16058
- output: computeUsage(`$4.00 / 1M tokens`),
16080
+ prompt: pricing(`$3.00 / 1M tokens`),
16081
+ output: pricing(`$4.00 / 1M tokens`),
16059
16082
  },
16060
16083
  },
16061
16084
  /**/
@@ -16635,8 +16658,8 @@ const DEEPSEEK_MODELS = exportJson({
16635
16658
  modelName: 'deepseek-chat',
16636
16659
  modelDescription: 'General-purpose language model with strong performance across conversation, reasoning, and content generation. 128K context window with excellent instruction following capabilities.',
16637
16660
  pricing: {
16638
- prompt: computeUsage(`$0.80 / 1M tokens`),
16639
- output: computeUsage(`$1.60 / 1M tokens`),
16661
+ prompt: pricing(`$0.80 / 1M tokens`),
16662
+ output: pricing(`$1.60 / 1M tokens`),
16640
16663
  },
16641
16664
  },
16642
16665
  {
@@ -16645,8 +16668,8 @@ const DEEPSEEK_MODELS = exportJson({
16645
16668
  modelName: 'deepseek-reasoner',
16646
16669
  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.',
16647
16670
  pricing: {
16648
- prompt: computeUsage(`$3.50 / 1M tokens`),
16649
- output: computeUsage(`$7.00 / 1M tokens`),
16671
+ prompt: pricing(`$3.50 / 1M tokens`),
16672
+ output: pricing(`$7.00 / 1M tokens`),
16650
16673
  },
16651
16674
  },
16652
16675
  {
@@ -16655,8 +16678,8 @@ const DEEPSEEK_MODELS = exportJson({
16655
16678
  modelName: 'deepseek-v3-0324',
16656
16679
  modelDescription: 'Advanced general-purpose model with improved reasoning, coding abilities, and multimodal understanding. Built on the latest DeepSeek architecture with enhanced knowledge representation.',
16657
16680
  pricing: {
16658
- prompt: computeUsage(`$1.50 / 1M tokens`),
16659
- output: computeUsage(`$3.00 / 1M tokens`),
16681
+ prompt: pricing(`$1.50 / 1M tokens`),
16682
+ output: pricing(`$3.00 / 1M tokens`),
16660
16683
  },
16661
16684
  },
16662
16685
  {
@@ -16665,11 +16688,31 @@ const DEEPSEEK_MODELS = exportJson({
16665
16688
  modelName: 'deepseek-r1',
16666
16689
  modelDescription: 'Research-focused model optimized for scientific problem-solving and analytical tasks. Excellent performance on tasks requiring domain-specific expertise and critical thinking.',
16667
16690
  pricing: {
16668
- prompt: computeUsage(`$5.00 / 1M tokens`),
16669
- output: computeUsage(`$10.00 / 1M tokens`),
16691
+ prompt: pricing(`$5.00 / 1M tokens`),
16692
+ output: pricing(`$10.00 / 1M tokens`),
16670
16693
  },
16671
16694
  },
16672
- // <- [🕕]
16695
+ {
16696
+ modelVariant: 'EMBEDDING',
16697
+ modelTitle: 'DeepSeek Embedder',
16698
+ modelName: 'deepseek-embedder-v1',
16699
+ modelDescription: 'High-quality text embedding model',
16700
+ pricing: {
16701
+ prompt: pricing(`$0.10 / 1M tokens`),
16702
+ output: 0,
16703
+ },
16704
+ },
16705
+ {
16706
+ modelVariant: 'CHAT',
16707
+ modelTitle: 'DeepSeek Vision',
16708
+ modelName: 'deepseek-vision-v2',
16709
+ modelDescription: 'Multimodal model for image + text tasks',
16710
+ pricing: {
16711
+ prompt: pricing(`$1.20 / 1M tokens`),
16712
+ output: pricing(`$2.40 / 1M tokens`),
16713
+ },
16714
+ },
16715
+ // …add any additional at https://www.deepseek.com/models…
16673
16716
  ],
16674
16717
  });
16675
16718
  /**
@@ -16794,8 +16837,8 @@ const GOOGLE_MODELS = exportJson({
16794
16837
  modelName: 'gemini-2.5-pro-preview-03-25',
16795
16838
  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.',
16796
16839
  pricing: {
16797
- prompt: computeUsage(`$8.00 / 1M tokens`),
16798
- output: computeUsage(`$24.00 / 1M tokens`),
16840
+ prompt: pricing(`$8.00 / 1M tokens`),
16841
+ output: pricing(`$24.00 / 1M tokens`),
16799
16842
  },
16800
16843
  },
16801
16844
  {
@@ -16804,8 +16847,8 @@ const GOOGLE_MODELS = exportJson({
16804
16847
  modelName: 'gemini-2.0-flash',
16805
16848
  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.',
16806
16849
  pricing: {
16807
- prompt: computeUsage(`$0.35 / 1M tokens`),
16808
- output: computeUsage(`$1.05 / 1M tokens`),
16850
+ prompt: pricing(`$0.35 / 1M tokens`),
16851
+ output: pricing(`$1.05 / 1M tokens`),
16809
16852
  },
16810
16853
  },
16811
16854
  {
@@ -16814,8 +16857,8 @@ const GOOGLE_MODELS = exportJson({
16814
16857
  modelName: 'gemini-2.0-flash-lite',
16815
16858
  modelDescription: 'Streamlined version of Gemini 2.0 Flash, designed for extremely low-latency applications and edge deployments. Optimized for efficiency while maintaining core capabilities.',
16816
16859
  pricing: {
16817
- prompt: computeUsage(`$0.20 / 1M tokens`),
16818
- output: computeUsage(`$0.60 / 1M tokens`),
16860
+ prompt: pricing(`$0.20 / 1M tokens`),
16861
+ output: pricing(`$0.60 / 1M tokens`),
16819
16862
  },
16820
16863
  },
16821
16864
  {
@@ -16824,8 +16867,8 @@ const GOOGLE_MODELS = exportJson({
16824
16867
  modelName: 'gemini-2.0-flash-thinking-exp-01-21',
16825
16868
  modelDescription: 'Experimental model focused on enhanced reasoning with explicit chain-of-thought processes. Designed for tasks requiring structured thinking and problem-solving approaches.',
16826
16869
  pricing: {
16827
- prompt: computeUsage(`$0.35 / 1M tokens`),
16828
- output: computeUsage(`$1.05 / 1M tokens`),
16870
+ prompt: pricing(`$0.35 / 1M tokens`),
16871
+ output: pricing(`$1.05 / 1M tokens`),
16829
16872
  },
16830
16873
  },
16831
16874
  {
@@ -16834,8 +16877,8 @@ const GOOGLE_MODELS = exportJson({
16834
16877
  modelName: 'gemini-1.5-flash',
16835
16878
  modelDescription: 'Efficient model balancing speed and quality for general-purpose applications. 1M token context window with good multimodal capabilities and quick response times.',
16836
16879
  pricing: {
16837
- prompt: computeUsage(`$0.25 / 1M tokens`),
16838
- output: computeUsage(`$0.75 / 1M tokens`),
16880
+ prompt: pricing(`$0.25 / 1M tokens`),
16881
+ output: pricing(`$0.75 / 1M tokens`),
16839
16882
  },
16840
16883
  },
16841
16884
  {
@@ -16892,8 +16935,8 @@ const GOOGLE_MODELS = exportJson({
16892
16935
  modelName: 'gemini-1.5-pro-latest',
16893
16936
  modelDescription: 'Points to the most recent version of the flagship Gemini 1.5 Pro model, ensuring access to the latest capabilities and improvements.',
16894
16937
  pricing: {
16895
- prompt: computeUsage(`$7.00 / 1M tokens`),
16896
- output: computeUsage(`$21.00 / 1M tokens`),
16938
+ prompt: pricing(`$7.00 / 1M tokens`),
16939
+ output: pricing(`$21.00 / 1M tokens`),
16897
16940
  },
16898
16941
  },
16899
16942
  {
@@ -16902,8 +16945,8 @@ const GOOGLE_MODELS = exportJson({
16902
16945
  modelName: 'gemini-1.5-pro',
16903
16946
  modelDescription: 'Flagship multimodal model with strong performance across text, code, vision, and audio tasks. 1M token context window with excellent reasoning capabilities.',
16904
16947
  pricing: {
16905
- prompt: computeUsage(`$6.00 / 1M tokens`),
16906
- output: computeUsage(`$18.00 / 1M tokens`),
16948
+ prompt: pricing(`$6.00 / 1M tokens`),
16949
+ output: pricing(`$18.00 / 1M tokens`),
16907
16950
  },
16908
16951
  },
16909
16952
  {
@@ -16930,11 +16973,31 @@ const GOOGLE_MODELS = exportJson({
16930
16973
  modelName: 'gemini-1.0-pro',
16931
16974
  modelDescription: 'Original Gemini series foundation model with solid multimodal capabilities. 32K context window with good performance on text, code, and basic vision tasks.',
16932
16975
  pricing: {
16933
- prompt: computeUsage(`$0.35 / 1M tokens`),
16934
- output: computeUsage(`$1.05 / 1M tokens`),
16976
+ prompt: pricing(`$0.35 / 1M tokens`),
16977
+ output: pricing(`$1.05 / 1M tokens`),
16935
16978
  },
16936
16979
  },
16937
- // <- [🕕]
16980
+ {
16981
+ modelVariant: 'EMBEDDING',
16982
+ modelTitle: 'Gemini Embedder',
16983
+ modelName: 'gemini-embedder-v1',
16984
+ modelDescription: 'High-quality embeddings for retrieval',
16985
+ pricing: {
16986
+ prompt: pricing(`$0.08 / 1M tokens`),
16987
+ output: 0,
16988
+ },
16989
+ },
16990
+ {
16991
+ modelVariant: 'CHAT',
16992
+ modelTitle: 'Gemini Pro Vision',
16993
+ modelName: 'gemini-pro-vision-v1',
16994
+ modelDescription: 'Advanced vision + language model',
16995
+ pricing: {
16996
+ prompt: pricing(`$9.00 / 1M tokens`),
16997
+ output: pricing(`$27.00 / 1M tokens`),
16998
+ },
16999
+ },
17000
+ // …add any additional from https://ai.google.dev/models/gemini…
16938
17001
  ],
16939
17002
  });
16940
17003
  /**
@@ -17092,15 +17155,15 @@ resultContent, rawResponse) {
17092
17155
  */
17093
17156
 
17094
17157
  /**
17095
- * Execution Tools for calling OpenAI API
17158
+ * Execution Tools for calling OpenAI API or other OpeenAI compatible provider
17096
17159
  *
17097
17160
  * @public exported from `@promptbook/openai`
17098
17161
  */
17099
- class OpenAiExecutionTools {
17162
+ class OpenAiCompatibleExecutionTools {
17100
17163
  /**
17101
- * Creates OpenAI Execution Tools.
17164
+ * Creates OpenAI compatible Execution Tools.
17102
17165
  *
17103
- * @param options which are relevant are directly passed to the OpenAI client
17166
+ * @param options which are relevant are directly passed to the OpenAI compatible client
17104
17167
  */
17105
17168
  constructor(options) {
17106
17169
  this.options = options;
@@ -17113,12 +17176,6 @@ class OpenAiExecutionTools {
17113
17176
  minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
17114
17177
  });
17115
17178
  }
17116
- get title() {
17117
- return 'OpenAI';
17118
- }
17119
- get description() {
17120
- return 'Use all models provided by OpenAI';
17121
- }
17122
17179
  async getClient() {
17123
17180
  if (this.client === null) {
17124
17181
  // Note: Passing only OpenAI relevant options to OpenAI constructor
@@ -17129,18 +17186,6 @@ class OpenAiExecutionTools {
17129
17186
  }
17130
17187
  return this.client;
17131
17188
  }
17132
- /*
17133
- Note: Commenting this out to avoid circular dependency
17134
- /**
17135
- * Create (sub)tools for calling OpenAI API Assistants
17136
- *
17137
- * @param assistantId Which assistant to use
17138
- * @returns Tools for calling OpenAI API Assistants with same token
17139
- * /
17140
- public createAssistantSubtools(assistantId: string_token): OpenAiAssistantExecutionTools {
17141
- return new OpenAiAssistantExecutionTools({ ...this.options, assistantId });
17142
- }
17143
- */
17144
17189
  /**
17145
17190
  * Check the `options` passed to `constructor`
17146
17191
  */
@@ -17149,23 +17194,15 @@ class OpenAiExecutionTools {
17149
17194
  // TODO: [🎍] Do here a real check that API is online, working and API key is correct
17150
17195
  }
17151
17196
  /**
17152
- * List all available OpenAI models that can be used
17197
+ * List all available OpenAI compatible models that can be used
17153
17198
  */
17154
17199
  async listModels() {
17155
- /*
17156
- Note: Dynamic lising of the models
17157
- const models = await this.openai.models.list({});
17158
-
17159
- console.log({ models });
17160
- console.log(models.data);
17161
- */
17162
17200
  const client = await this.getClient();
17163
17201
  const rawModelsList = await client.models.list();
17164
17202
  const availableModels = rawModelsList.data
17165
17203
  .sort((a, b) => (a.created > b.created ? 1 : -1))
17166
17204
  .map((modelFromApi) => {
17167
- // TODO: !!!! What about other model compatibilities?
17168
- const modelFromList = OPENAI_MODELS.find(({ modelName }) => modelName === modelFromApi.id ||
17205
+ const modelFromList = this.HARDCODED_MODELS.find(({ modelName }) => modelName === modelFromApi.id ||
17169
17206
  modelName.startsWith(modelFromApi.id) ||
17170
17207
  modelFromApi.id.startsWith(modelName));
17171
17208
  if (modelFromList !== undefined) {
@@ -17181,12 +17218,12 @@ class OpenAiExecutionTools {
17181
17218
  return availableModels;
17182
17219
  }
17183
17220
  /**
17184
- * Calls OpenAI API to use a chat model.
17221
+ * Calls OpenAI compatible API to use a chat model.
17185
17222
  */
17186
17223
  async callChatModel(prompt) {
17187
17224
  var _a;
17188
17225
  if (this.options.isVerbose) {
17189
- console.info('💬 OpenAI callChatModel call', { prompt });
17226
+ console.info(`💬 ${this.title} callChatModel call`, { prompt });
17190
17227
  }
17191
17228
  const { content, parameters, modelRequirements, format } = prompt;
17192
17229
  const client = await this.getClient();
@@ -17247,20 +17284,20 @@ class OpenAiExecutionTools {
17247
17284
  }
17248
17285
  const complete = $getCurrentDate();
17249
17286
  if (!rawResponse.choices[0]) {
17250
- throw new PipelineExecutionError('No choises from OpenAI');
17287
+ throw new PipelineExecutionError(`No choises from ${this.title}`);
17251
17288
  }
17252
17289
  if (rawResponse.choices.length > 1) {
17253
17290
  // TODO: This should be maybe only warning
17254
- throw new PipelineExecutionError('More than one choise from OpenAI');
17291
+ throw new PipelineExecutionError(`More than one choise from ${this.title}`);
17255
17292
  }
17256
17293
  const resultContent = rawResponse.choices[0].message.content;
17257
- const usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
17294
+ const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
17258
17295
  if (resultContent === null) {
17259
- throw new PipelineExecutionError('No response message from OpenAI');
17296
+ throw new PipelineExecutionError(`No response message from ${this.title}`);
17260
17297
  }
17261
17298
  return exportJson({
17262
17299
  name: 'promptResult',
17263
- message: `Result of \`OpenAiExecutionTools.callChatModel\``,
17300
+ message: `Result of \`OpenAiCompatibleExecutionTools.callChatModel\``,
17264
17301
  order: [],
17265
17302
  value: {
17266
17303
  content: resultContent,
@@ -17283,7 +17320,7 @@ class OpenAiExecutionTools {
17283
17320
  async callCompletionModel(prompt) {
17284
17321
  var _a;
17285
17322
  if (this.options.isVerbose) {
17286
- console.info('🖋 OpenAI callCompletionModel call', { prompt });
17323
+ console.info(`🖋 ${this.title} callCompletionModel call`, { prompt });
17287
17324
  }
17288
17325
  const { content, parameters, modelRequirements } = prompt;
17289
17326
  const client = await this.getClient();
@@ -17324,17 +17361,17 @@ class OpenAiExecutionTools {
17324
17361
  }
17325
17362
  const complete = $getCurrentDate();
17326
17363
  if (!rawResponse.choices[0]) {
17327
- throw new PipelineExecutionError('No choises from OpenAI');
17364
+ throw new PipelineExecutionError(`No choises from ${this.title}`);
17328
17365
  }
17329
17366
  if (rawResponse.choices.length > 1) {
17330
17367
  // TODO: This should be maybe only warning
17331
- throw new PipelineExecutionError('More than one choise from OpenAI');
17368
+ throw new PipelineExecutionError(`More than one choise from ${this.title}`);
17332
17369
  }
17333
17370
  const resultContent = rawResponse.choices[0].text;
17334
- const usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
17371
+ const usage = this.computeUsage(content || '', resultContent || '', rawResponse);
17335
17372
  return exportJson({
17336
17373
  name: 'promptResult',
17337
- message: `Result of \`OpenAiExecutionTools.callCompletionModel\``,
17374
+ message: `Result of \`OpenAiCompatibleExecutionTools.callCompletionModel\``,
17338
17375
  order: [],
17339
17376
  value: {
17340
17377
  content: resultContent,
@@ -17352,11 +17389,11 @@ class OpenAiExecutionTools {
17352
17389
  });
17353
17390
  }
17354
17391
  /**
17355
- * Calls OpenAI API to use a embedding model
17392
+ * Calls OpenAI compatible API to use a embedding model
17356
17393
  */
17357
17394
  async callEmbeddingModel(prompt) {
17358
17395
  if (this.options.isVerbose) {
17359
- console.info('🖋 OpenAI embedding call', { prompt });
17396
+ console.info(`🖋 ${this.title} embedding call`, { prompt });
17360
17397
  }
17361
17398
  const { content, parameters, modelRequirements } = prompt;
17362
17399
  const client = await this.getClient();
@@ -17391,12 +17428,12 @@ class OpenAiExecutionTools {
17391
17428
  throw new PipelineExecutionError(`Expected exactly 1 data item in response, got ${rawResponse.data.length}`);
17392
17429
  }
17393
17430
  const resultContent = rawResponse.data[0].embedding;
17394
- const usage = computeOpenAiUsage(content || '', '',
17431
+ const usage = this.computeUsage(content || '', '',
17395
17432
  // <- Note: Embedding does not have result content
17396
17433
  rawResponse);
17397
17434
  return exportJson({
17398
17435
  name: 'promptResult',
17399
- message: `Result of \`OpenAiExecutionTools.callEmbeddingModel\``,
17436
+ message: `Result of \`OpenAiCompatibleExecutionTools.callEmbeddingModel\``,
17400
17437
  order: [],
17401
17438
  value: {
17402
17439
  content: resultContent,
@@ -17419,65 +17456,171 @@ class OpenAiExecutionTools {
17419
17456
  */
17420
17457
  getDefaultModel(defaultModelName) {
17421
17458
  // Note: Match exact or prefix for model families
17422
- const model = OPENAI_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
17459
+ const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
17423
17460
  if (model === undefined) {
17424
- throw new UnexpectedError(spaceTrim((block) => `
17425
- Cannot find model in OpenAI models with name "${defaultModelName}" which should be used as default.
17461
+ throw new PipelineExecutionError(spaceTrim((block) => `
17462
+ Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
17426
17463
 
17427
17464
  Available models:
17428
- ${block(OPENAI_MODELS.map(({ modelName }) => `- "${modelName}"`).join('\n'))}
17465
+ ${block(this.HARDCODED_MODELS.map(({ modelName }) => `- "${modelName}"`).join('\n'))}
17466
+
17467
+ Model "${defaultModelName}" is probably not available anymore, not installed, inaccessible or misconfigured.
17429
17468
 
17430
17469
  `));
17431
17470
  }
17432
17471
  return model;
17433
17472
  }
17434
- /**
17435
- * Default model for chat variant.
17436
- */
17437
- getDefaultChatModel() {
17438
- return this.getDefaultModel('gpt-4o');
17439
- }
17440
- /**
17441
- * Default model for completion variant.
17442
- */
17443
- getDefaultCompletionModel() {
17444
- return this.getDefaultModel('gpt-3.5-turbo-instruct');
17445
- }
17446
- /**
17447
- * Default model for completion variant.
17448
- */
17449
- getDefaultEmbeddingModel() {
17450
- return this.getDefaultModel('text-embedding-3-large');
17451
- }
17452
17473
  }
17453
17474
  /**
17454
- * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
17455
- * TODO: Maybe Create some common util for callChatModel and callCompletionModel
17456
- * TODO: Maybe make custom OpenAiError
17475
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
17476
+ * TODO: [🛄] Maybe make custom `OpenAiCompatibleError`
17457
17477
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
17458
17478
  * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
17459
17479
  */
17460
17480
 
17461
17481
  /**
17462
- * Execution Tools for calling OpenAI API
17482
+ * List of available models in Ollama library
17463
17483
  *
17464
- * Note: This can be also used for other OpenAI compatible APIs, like Ollama
17484
+ * Note: Done at 2025-05-19
17465
17485
  *
17466
- * @public exported from `@promptbook/openai`
17486
+ * @see https://ollama.com/library
17487
+ * @public exported from `@promptbook/ollama`
17467
17488
  */
17468
- const createOpenAiExecutionTools = Object.assign((options) => {
17469
- // TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
17470
- if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
17471
- options = { ...options, dangerouslyAllowBrowser: true };
17472
- }
17473
- return new OpenAiExecutionTools(options);
17474
- }, {
17475
- packageName: '@promptbook/openai',
17476
- className: 'OpenAiExecutionTools',
17489
+ const OLLAMA_MODELS = exportJson({
17490
+ name: 'OLLAMA_MODELS',
17491
+ value: [
17492
+ {
17493
+ modelVariant: 'CHAT',
17494
+ modelTitle: 'llama2',
17495
+ modelName: 'llama2',
17496
+ modelDescription: 'Meta Llama 2, a general-purpose large language model.',
17497
+ },
17498
+ {
17499
+ modelVariant: 'CHAT',
17500
+ modelTitle: 'llama2-chat',
17501
+ modelName: 'llama2-chat',
17502
+ modelDescription: 'Meta Llama 2 Chat, optimized for conversational tasks.',
17503
+ },
17504
+ {
17505
+ modelVariant: 'CHAT',
17506
+ modelTitle: 'alpaca-7b',
17507
+ modelName: 'alpaca-7b',
17508
+ modelDescription: 'Stanford Alpaca 7B, instruction-tuned LLaMA model.',
17509
+ },
17510
+ {
17511
+ modelVariant: 'CHAT',
17512
+ modelTitle: 'alpaca-30b',
17513
+ modelName: 'alpaca-30b',
17514
+ modelDescription: 'Stanford Alpaca 30B, larger instruction-tuned LLaMA model.',
17515
+ },
17516
+ {
17517
+ modelVariant: 'CHAT',
17518
+ modelTitle: 'vicuna-13b',
17519
+ modelName: 'vicuna-13b',
17520
+ modelDescription: 'Vicuna 13B, fine-tuned LLaMA for chat and instruction.',
17521
+ },
17522
+ {
17523
+ modelVariant: 'CHAT',
17524
+ modelTitle: 'falcon-7b',
17525
+ modelName: 'falcon-7b',
17526
+ modelDescription: 'Falcon 7B, a performant open large language model.',
17527
+ },
17528
+ {
17529
+ modelVariant: 'CHAT',
17530
+ modelTitle: 'falcon-40b',
17531
+ modelName: 'falcon-40b',
17532
+ modelDescription: 'Falcon 40B, a larger open large language model.',
17533
+ },
17534
+ {
17535
+ modelVariant: 'CHAT',
17536
+ modelTitle: 'bloom-7b',
17537
+ modelName: 'bloom-7b',
17538
+ modelDescription: 'BLOOM 7B, multilingual large language model.',
17539
+ },
17540
+ {
17541
+ modelVariant: 'CHAT',
17542
+ modelTitle: 'mistral-7b',
17543
+ modelName: 'mistral-7b',
17544
+ modelDescription: 'Mistral 7B, efficient and fast open LLM.',
17545
+ },
17546
+ {
17547
+ modelVariant: 'CHAT',
17548
+ modelTitle: 'gorilla',
17549
+ modelName: 'gorilla',
17550
+ modelDescription: 'Gorilla, open-source LLM for tool use and APIs.',
17551
+ },
17552
+ {
17553
+ modelVariant: 'CHAT',
17554
+ modelTitle: 'cerebras-13b',
17555
+ modelName: 'cerebras-13b',
17556
+ modelDescription: 'Cerebras-GPT 13B, open large language model.',
17557
+ },
17558
+ {
17559
+ modelVariant: 'CHAT',
17560
+ modelTitle: 'openchat-7b',
17561
+ modelName: 'openchat-7b',
17562
+ modelDescription: 'OpenChat 7B, fine-tuned for conversational tasks.',
17563
+ },
17564
+ {
17565
+ modelVariant: 'CHAT',
17566
+ modelTitle: 'openchat-13b',
17567
+ modelName: 'openchat-13b',
17568
+ modelDescription: 'OpenChat 13B, larger conversational LLM.',
17569
+ },
17570
+ {
17571
+ modelVariant: 'CHAT',
17572
+ modelTitle: 'mpt-7b-chat',
17573
+ modelName: 'mpt-7b-chat',
17574
+ modelDescription: 'MPT-7B Chat, optimized for dialogue and chat.',
17575
+ },
17576
+ {
17577
+ modelVariant: 'CHAT',
17578
+ modelTitle: 'mpt-7b-instruct',
17579
+ modelName: 'mpt-7b-instruct',
17580
+ modelDescription: 'MPT-7B Instruct, instruction-tuned variant.',
17581
+ },
17582
+ {
17583
+ modelVariant: 'CHAT',
17584
+ modelTitle: 'command-7b',
17585
+ modelName: 'command-7b',
17586
+ modelDescription: 'Command 7B, instruction-following LLM.',
17587
+ },
17588
+ {
17589
+ modelVariant: 'CHAT',
17590
+ modelTitle: 'starcoder',
17591
+ modelName: 'starcoder',
17592
+ modelDescription: 'StarCoder, code generation large language model.',
17593
+ },
17594
+ {
17595
+ modelVariant: 'CHAT',
17596
+ modelTitle: 'starcoder2',
17597
+ modelName: 'starcoder2',
17598
+ modelDescription: 'StarCoder2, improved code generation model.',
17599
+ },
17600
+ {
17601
+ modelVariant: 'CHAT',
17602
+ modelTitle: 'mixtral-7b-chat',
17603
+ modelName: 'mixtral-7b-chat',
17604
+ modelDescription: 'Mixtral 7B Chat, Mixture-of-Experts conversational model.',
17605
+ },
17606
+ {
17607
+ modelVariant: 'CHAT',
17608
+ modelTitle: 'mixtral-8x7b',
17609
+ modelName: 'mixtral-8x7b',
17610
+ modelDescription: 'Mixtral 8x7B, Mixture-of-Experts large language model.',
17611
+ },
17612
+ {
17613
+ modelVariant: 'CHAT',
17614
+ modelTitle: 'mixtral-8x7b-instruct',
17615
+ modelName: 'mixtral-8x7b-instruct',
17616
+ modelDescription: 'Mixtral 8x7B Instruct, instruction-tuned Mixture-of-Experts model.',
17617
+ },
17618
+ // <- [🕕]
17619
+ ],
17477
17620
  });
17478
17621
  /**
17479
- * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
17480
- * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
17622
+ * TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
17623
+ * Note: [💞] Ignore a discrepancy between file name and entity name
17481
17624
  */
17482
17625
 
17483
17626
  /**
@@ -17485,22 +17628,79 @@ const createOpenAiExecutionTools = Object.assign((options) => {
17485
17628
  *
17486
17629
  * @public exported from `@promptbook/ollama`
17487
17630
  */
17488
- const DEFAULT_OLLAMA_BASE_URL = 'http://localhost:11434'; // <- TODO: !!!! What is the correct base URL? /v1?
17631
+ const DEFAULT_OLLAMA_BASE_URL = 'http://localhost:11434/v1';
17489
17632
 
17490
17633
  /**
17491
17634
  * Execution Tools for calling Ollama API
17492
17635
  *
17493
17636
  * @public exported from `@promptbook/ollama`
17494
17637
  */
17495
- const createOllamaExecutionTools = Object.assign((ollamaOptions) => {
17496
- const openAiCompatibleOptions = {
17497
- baseURL: DEFAULT_OLLAMA_BASE_URL,
17498
- ...ollamaOptions,
17499
- userId: 'ollama',
17500
- };
17501
- // TODO: !!!! Listing the models - do it dynamically in OpenAiExecutionTools
17502
- // TODO: !!!! Do not allow to create Assistant from OpenAi compatible tools
17503
- return createOpenAiExecutionTools(openAiCompatibleOptions);
17638
+ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
17639
+ /* <- TODO: [🍚] `, Destroyable` */
17640
+ constructor(ollamaOptions) {
17641
+ const openAiCompatibleOptions = {
17642
+ baseURL: DEFAULT_OLLAMA_BASE_URL,
17643
+ ...ollamaOptions,
17644
+ userId: 'ollama',
17645
+ };
17646
+ super(openAiCompatibleOptions);
17647
+ }
17648
+ get title() {
17649
+ return 'Ollama';
17650
+ }
17651
+ get description() {
17652
+ return 'Use all models provided by Ollama';
17653
+ }
17654
+ /**
17655
+ * List all available models (non dynamically)
17656
+ *
17657
+ * Note: Purpose of this is to provide more information about models than standard listing from API
17658
+ */
17659
+ get HARDCODED_MODELS() {
17660
+ return OLLAMA_MODELS;
17661
+ }
17662
+ /**
17663
+ * Computes the usage of the Ollama API based on the response from Ollama
17664
+ */
17665
+ computeUsage(...args) {
17666
+ return {
17667
+ ...computeOpenAiUsage(...args),
17668
+ 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
17669
+ };
17670
+ }
17671
+ /**
17672
+ * Default model for chat variant.
17673
+ */
17674
+ getDefaultChatModel() {
17675
+ return this.getDefaultModel('llama2'); // <- TODO: [🧠] Pick the best default model
17676
+ // <- TODO: [🛄] When 'llama2' not installed, maybe better error message
17677
+ }
17678
+ /**
17679
+ * Default model for completion variant.
17680
+ */
17681
+ getDefaultCompletionModel() {
17682
+ return this.getDefaultModel('llama2'); // <- TODO: [🧠] Pick the best default model
17683
+ // <- TODO: [🛄] When 'llama2' not installed, maybe better error message
17684
+ }
17685
+ /**
17686
+ * Default model for completion variant.
17687
+ */
17688
+ getDefaultEmbeddingModel() {
17689
+ return this.getDefaultModel('text-embedding-3-large'); // <- TODO: [🧠] Pick the best default model
17690
+ // <- TODO: [🛄]
17691
+ }
17692
+ }
17693
+ /**
17694
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
17695
+ */
17696
+
17697
+ /**
17698
+ * Execution Tools for calling Ollama API
17699
+ *
17700
+ * @public exported from `@promptbook/ollama`
17701
+ */
17702
+ const createOllamaExecutionTools = Object.assign((options) => {
17703
+ return new OllamaExecutionTools(options);
17504
17704
  }, {
17505
17705
  packageName: '@promptbook/ollama',
17506
17706
  className: 'OllamaExecutionTools',
@@ -17615,6 +17815,67 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
17615
17815
  * Note: [💞] Ignore a discrepancy between file name and entity name
17616
17816
  */
17617
17817
 
17818
+ /**
17819
+ * Execution Tools for calling OpenAI API
17820
+ *
17821
+ * @public exported from `@promptbook/openai`
17822
+ */
17823
+ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
17824
+ constructor() {
17825
+ super(...arguments);
17826
+ /**
17827
+ * Computes the usage of the OpenAI API based on the response from OpenAI
17828
+ */
17829
+ this.computeUsage = computeOpenAiUsage;
17830
+ // <- Note: [🤖] getDefaultXxxModel
17831
+ }
17832
+ /* <- TODO: [🍚] `, Destroyable` */
17833
+ get title() {
17834
+ return 'OpenAI';
17835
+ }
17836
+ get description() {
17837
+ return 'Use all models provided by OpenAI';
17838
+ }
17839
+ /*
17840
+ Note: Commenting this out to avoid circular dependency
17841
+ /**
17842
+ * Create (sub)tools for calling OpenAI API Assistants
17843
+ *
17844
+ * @param assistantId Which assistant to use
17845
+ * @returns Tools for calling OpenAI API Assistants with same token
17846
+ * /
17847
+ public createAssistantSubtools(assistantId: string_token): OpenAiAssistantExecutionTools {
17848
+ return new OpenAiAssistantExecutionTools({ ...this.options, assistantId });
17849
+ }
17850
+ */
17851
+ /**
17852
+ * List all available models (non dynamically)
17853
+ *
17854
+ * Note: Purpose of this is to provide more information about models than standard listing from API
17855
+ */
17856
+ get HARDCODED_MODELS() {
17857
+ return OPENAI_MODELS;
17858
+ }
17859
+ /**
17860
+ * Default model for chat variant.
17861
+ */
17862
+ getDefaultChatModel() {
17863
+ return this.getDefaultModel('gpt-4o');
17864
+ }
17865
+ /**
17866
+ * Default model for completion variant.
17867
+ */
17868
+ getDefaultCompletionModel() {
17869
+ return this.getDefaultModel('gpt-3.5-turbo-instruct');
17870
+ }
17871
+ /**
17872
+ * Default model for completion variant.
17873
+ */
17874
+ getDefaultEmbeddingModel() {
17875
+ return this.getDefaultModel('text-embedding-3-large');
17876
+ }
17877
+ }
17878
+
17618
17879
  /**
17619
17880
  * Execution Tools for calling OpenAI API Assistants
17620
17881
  *
@@ -17802,6 +18063,27 @@ const createOpenAiAssistantExecutionTools = Object.assign((options) => {
17802
18063
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
17803
18064
  */
17804
18065
 
18066
+ /**
18067
+ * Execution Tools for calling OpenAI API
18068
+ *
18069
+ * Note: This can be also used for other OpenAI compatible APIs, like Ollama
18070
+ *
18071
+ * @public exported from `@promptbook/openai`
18072
+ */
18073
+ const createOpenAiExecutionTools = Object.assign((options) => {
18074
+ if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
18075
+ options = { ...options, dangerouslyAllowBrowser: true };
18076
+ }
18077
+ return new OpenAiExecutionTools(options);
18078
+ }, {
18079
+ packageName: '@promptbook/openai',
18080
+ className: 'OpenAiExecutionTools',
18081
+ });
18082
+ /**
18083
+ * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
18084
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
18085
+ */
18086
+
17805
18087
  /**
17806
18088
  * Registration of LLM provider
17807
18089
  *