@promptbook/core 0.66.0-1 → 0.66.0-5

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.
Files changed (45) hide show
  1. package/esm/index.es.js +167 -61
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +8 -2
  5. package/esm/typings/src/_packages/openai.index.d.ts +4 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -2
  7. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  8. package/esm/typings/src/config.d.ts +0 -7
  9. package/esm/typings/src/execution/AvailableModel.d.ts +20 -0
  10. package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -19
  11. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +10 -0
  12. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -1
  13. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +1 -1
  14. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +1 -1
  15. package/esm/typings/src/llm-providers/_common/$llmToolsMetadataRegister.d.ts +10 -0
  16. package/esm/typings/src/llm-providers/_common/$llmToolsRegister.d.ts +10 -0
  17. package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +7 -13
  18. package/esm/typings/src/llm-providers/_common/LlmToolsMetadata.d.ts +27 -0
  19. package/esm/typings/src/llm-providers/_common/LlmToolsOptions.d.ts +7 -0
  20. package/esm/typings/src/llm-providers/_common/config.d.ts +4 -0
  21. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
  22. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.test.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +7 -2
  26. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +8 -0
  27. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +11 -0
  28. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
  29. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  33. package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.d.ts → computeOpenAiUsage.d.ts} +2 -2
  34. package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.test.d.ts → computeOpenAiUsage.test.d.ts} +1 -1
  35. package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +15 -0
  36. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +8 -0
  38. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +11 -0
  39. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  40. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +2 -2
  41. package/esm/typings/src/personas/preparePersona.test.d.ts +1 -1
  42. package/esm/typings/src/utils/Register.d.ts +22 -0
  43. package/package.json +1 -1
  44. package/umd/index.umd.js +170 -61
  45. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * The version of the Promptbook library
21
21
  */
22
- var PROMPTBOOK_VERSION = '0.66.0-0';
22
+ var PROMPTBOOK_VERSION = '0.66.0-4';
23
23
  // TODO: !!!! List here all the versions and annotate + put into script
24
24
 
25
25
  /*! *****************************************************************************
@@ -600,44 +600,6 @@
600
600
  * @public exported from `@promptbook/core`
601
601
  */
602
602
  var DEFAULT_REMOTE_URL_PATH = '/promptbook/socket.io';
603
- // <- TODO: [🧜‍♂️]
604
- /**
605
- * @@@
606
- *
607
- * @public exported from `@promptbook/core`
608
- */
609
- var BOILERPLATE_LLM_TOOLS_CONFIGURATION_ = [
610
- {
611
- title: 'Open AI',
612
- packageName: '@promptbook/openai',
613
- className: 'OpenAiExecutionTools',
614
- options: {
615
- apiKey: 'sk-',
616
- },
617
- },
618
- {
619
- title: 'Anthropic Claude',
620
- packageName: '@promptbook/anthropic-claude',
621
- className: 'AnthropicClaudeExecutionTools',
622
- options: {
623
- apiKey: 'sk-ant-api03-',
624
- isProxied: true,
625
- remoteUrl: DEFAULT_REMOTE_URL,
626
- path: DEFAULT_REMOTE_URL_PATH,
627
- },
628
- },
629
- {
630
- title: 'Azure Open AI',
631
- packageName: '@promptbook/azure-openai',
632
- className: 'AzureOpenAiExecutionTools',
633
- options: {
634
- // TODO: !!!> resourceName
635
- // TODO: !!!> deploymentName
636
- apiKey: 'sk-',
637
- },
638
- },
639
- // <- Note: [🦑] Add here new LLM provider
640
- ];
641
603
  /**
642
604
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
643
605
  */
@@ -1688,7 +1650,7 @@
1688
1650
  });
1689
1651
  }
1690
1652
 
1691
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-0",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.66.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.66.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.66.0-0",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1653
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-4",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.66.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.66.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.66.0-4",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1692
1654
 
1693
1655
  var defaultDiacriticsRemovalMap = [
1694
1656
  {
@@ -6540,6 +6502,49 @@
6540
6502
  return CallbackInterfaceTools;
6541
6503
  }());
6542
6504
 
6505
+ /**
6506
+ * Register is @@@
6507
+ *
6508
+ * @private internal utility, exported are only signleton instances of this class
6509
+ */
6510
+ var Register = /** @class */ (function () {
6511
+ function Register(storage) {
6512
+ this.storage = storage;
6513
+ }
6514
+ Register.prototype.list = function () {
6515
+ // <- TODO: ReadonlyDeep<Array<TRegistered>>
6516
+ return this.storage;
6517
+ };
6518
+ Register.prototype.register = function (registered) {
6519
+ // !!!!!! <- TODO: What to return here
6520
+ // TODO: !!!!!! Compare if same is not already registered
6521
+ this.storage.push(registered);
6522
+ };
6523
+ return Register;
6524
+ }());
6525
+
6526
+ /**
6527
+ * @@@
6528
+ *
6529
+ * Note: `$` is used to indicate that this interacts with the global scope
6530
+ * @singleton Only one instance of each register is created per build, but thare can be more @@@
6531
+ * @public exported from `@promptbook/core`
6532
+ */
6533
+ var $llmToolsMetadataRegister = new Register([
6534
+ // TODO: !!!!!! Take from global scope
6535
+ ]);
6536
+
6537
+ /**
6538
+ * @@@
6539
+ *
6540
+ * Note: `$` is used to indicate that this interacts with the global scope
6541
+ * @singleton Only one instance of each register is created per build, but thare can be more @@@
6542
+ * @public exported from `@promptbook/core`
6543
+ */
6544
+ var $llmToolsRegister = new Register([
6545
+ // TODO: !!!!!! Take from global scope
6546
+ ]);
6547
+
6543
6548
  /**
6544
6549
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
6545
6550
  *
@@ -6853,7 +6858,7 @@
6853
6858
  };
6854
6859
  }
6855
6860
  /**
6856
- * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenaiUsage` and `computeAnthropicClaudeUsage`
6861
+ * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
6857
6862
  */
6858
6863
 
6859
6864
  /**
@@ -7076,7 +7081,7 @@
7076
7081
  * TODO: [🍆] JSON mode
7077
7082
  * TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
7078
7083
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
7079
- * TODO: Maybe make custom OpenaiError
7084
+ * TODO: Maybe make custom OpenAiError
7080
7085
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
7081
7086
  * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
7082
7087
  * TODO: [📅] Maybe instead of `RemoteLlmExecutionToolsOptions` use `proxyWithAnonymousRemoteServer` (if implemented)
@@ -7087,7 +7092,7 @@
7087
7092
  *
7088
7093
  * @public exported from `@promptbook/anthropic-claude`
7089
7094
  */
7090
- function createAnthropicClaudeExecutionTools(options) {
7095
+ var createAnthropicClaudeExecutionTools = Object.assign(function (options) {
7091
7096
  if (options.isProxied) {
7092
7097
  return new RemoteLlmExecutionTools(__assign(__assign({}, options), { isAnonymous: true, llmToolsConfiguration: [
7093
7098
  {
@@ -7098,14 +7103,17 @@
7098
7103
  },
7099
7104
  ], models: ANTHROPIC_CLAUDE_MODELS }));
7100
7105
  }
7101
- return new AnthropicClaudeExecutionTools(
7102
- // <- TODO: [🧱] Implement in a functional (not new Class) way
7103
- options);
7104
- }
7106
+ return new AnthropicClaudeExecutionTools(options);
7107
+ }, {
7108
+ packageName: '@promptbook/anthropic-claude',
7109
+ className: 'AnthropicClaudeExecutionTools',
7110
+ });
7105
7111
  /**
7106
7112
  * TODO: [🧠] !!!! Make anonymous this with all LLM providers
7107
- * TODO: [🧠] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
7113
+ * TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
7108
7114
  * TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
7115
+ * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
7116
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
7109
7117
  */
7110
7118
 
7111
7119
  /**
@@ -7707,7 +7715,7 @@
7707
7715
  }());
7708
7716
  /**
7709
7717
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
7710
- * TODO: Maybe make custom AzureOpenaiError
7718
+ * TODO: Maybe make custom AzureOpenAiError
7711
7719
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
7712
7720
  * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
7713
7721
  */
@@ -7721,7 +7729,7 @@
7721
7729
  * @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
7722
7730
  * @private internal utility of `OpenAiExecutionTools`
7723
7731
  */
7724
- function computeOpenaiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
7732
+ function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
7725
7733
  resultContent, rawResponse) {
7726
7734
  var _a, _b;
7727
7735
  if (rawResponse.usage === undefined) {
@@ -7747,11 +7755,11 @@
7747
7755
  };
7748
7756
  }
7749
7757
  /**
7750
- * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenaiUsage` and `computeAnthropicClaudeUsage`
7758
+ * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
7751
7759
  */
7752
7760
 
7753
7761
  /**
7754
- * Execution Tools for calling OpenAI API.
7762
+ * Execution Tools for calling OpenAI API
7755
7763
  *
7756
7764
  * @public exported from `@promptbook/openai`
7757
7765
  */
@@ -7850,7 +7858,7 @@
7850
7858
  resultContent = rawResponse.choices[0].message.content;
7851
7859
  // eslint-disable-next-line prefer-const
7852
7860
  complete = getCurrentIsoDate();
7853
- usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
7861
+ usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
7854
7862
  if (resultContent === null) {
7855
7863
  throw new PipelineExecutionError('No response message from OpenAI');
7856
7864
  }
@@ -7919,7 +7927,7 @@
7919
7927
  resultContent = rawResponse.choices[0].text;
7920
7928
  // eslint-disable-next-line prefer-const
7921
7929
  complete = getCurrentIsoDate();
7922
- usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
7930
+ usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
7923
7931
  return [2 /*return*/, {
7924
7932
  content: resultContent,
7925
7933
  modelName: rawResponse.model || modelName,
@@ -7976,7 +7984,7 @@
7976
7984
  resultContent = rawResponse.data[0].embedding;
7977
7985
  // eslint-disable-next-line prefer-const
7978
7986
  complete = getCurrentIsoDate();
7979
- usage = computeOpenaiUsage(content, '', rawResponse);
7987
+ usage = computeOpenAiUsage(content, '', rawResponse);
7980
7988
  return [2 /*return*/, {
7981
7989
  content: resultContent,
7982
7990
  modelName: rawResponse.model || modelName,
@@ -8050,18 +8058,37 @@
8050
8058
  /**
8051
8059
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
8052
8060
  * TODO: Maybe Create some common util for callChatModel and callCompletionModel
8053
- * TODO: Maybe make custom OpenaiError
8061
+ * TODO: Maybe make custom OpenAiError
8054
8062
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
8055
8063
  * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
8056
8064
  */
8057
8065
 
8058
8066
  /**
8067
+ * Execution Tools for calling OpenAI API
8068
+ *
8069
+ * @public exported from `@promptbook/openai`
8070
+ */
8071
+ var createOpenAiExecutionTools = Object.assign(function (options) {
8072
+ // TODO: !!!!!! If browser, auto add `dangerouslyAllowBrowser`
8073
+ return new OpenAiExecutionTools(options);
8074
+ }, {
8075
+ packageName: '@promptbook/openai',
8076
+ className: 'OpenAiExecutionTools',
8077
+ });
8078
+ /**
8079
+ * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
8080
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
8081
+ */
8082
+
8083
+ /**
8084
+ * @@@
8085
+ *
8086
+ * TODO: !!!!!! Remove EXECUTION_TOOLS_CLASSES and use $llmToolsRegister instead
8087
+ *
8059
8088
  * @private internal type for `createLlmToolsFromConfiguration`
8060
8089
  */
8061
8090
  var EXECUTION_TOOLS_CLASSES = {
8062
- createOpenAiExecutionTools: function (options) {
8063
- return new OpenAiExecutionTools(__assign(__assign({}, options), { dangerouslyAllowBrowser: true /* <- TODO: [🧠] !!! Some mechanism for auto-detection of browser, maybe hide in `OpenAiExecutionTools` */ }));
8064
- },
8091
+ createOpenAiExecutionTools: createOpenAiExecutionTools,
8065
8092
  createAnthropicClaudeExecutionTools: createAnthropicClaudeExecutionTools,
8066
8093
  createAzureOpenAiExecutionTools: function (options) {
8067
8094
  return new AzureOpenAiExecutionTools(
@@ -8087,7 +8114,11 @@
8087
8114
  if (options === void 0) { options = {}; }
8088
8115
  var _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
8089
8116
  var llmTools = configuration.map(function (llmConfiguration) {
8090
- return EXECUTION_TOOLS_CLASSES["create".concat(llmConfiguration.className)](__assign({ isVerbose: isVerbose }, llmConfiguration.options));
8117
+ var constructor = EXECUTION_TOOLS_CLASSES["create".concat(llmConfiguration.className)];
8118
+ if (!constructor) {
8119
+ throw new Error(spaceTrim__default["default"](function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "`\n\n\n @@@\n\n Available constructors are:\n ").concat(block('@@@'), "\n\n\n "); }));
8120
+ }
8121
+ return constructor(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
8091
8122
  });
8092
8123
  return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
8093
8124
  }
@@ -8329,6 +8360,81 @@
8329
8360
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
8330
8361
  */
8331
8362
 
8363
+ /**
8364
+ * @@@ registration1 of default configuration for Anthropic Claude
8365
+ *
8366
+ * Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
8367
+ *
8368
+ * @public exported from `@promptbook/core`
8369
+ */
8370
+ var _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register({
8371
+ title: 'Anthropic Claude',
8372
+ packageName: '@promptbook/anthropic-claude',
8373
+ className: 'AnthropicClaudeExecutionTools',
8374
+ getBoilerplateConfiguration: function () {
8375
+ return {
8376
+ title: 'Anthropic Claude (boilerplate)',
8377
+ packageName: '@promptbook/anthropic-claude',
8378
+ className: 'AnthropicClaudeExecutionTools',
8379
+ options: {
8380
+ apiKey: 'sk-ant-api03-',
8381
+ isProxied: true,
8382
+ remoteUrl: DEFAULT_REMOTE_URL,
8383
+ path: DEFAULT_REMOTE_URL_PATH,
8384
+ },
8385
+ };
8386
+ },
8387
+ createConfigurationFromEnv: function (env) {
8388
+ if (typeof env.ANTHROPIC_CLAUDE_API_KEY === 'string') {
8389
+ return {
8390
+ title: 'Claude (from env)',
8391
+ packageName: '@promptbook/antrhopic-claude',
8392
+ className: 'AnthropicClaudeExecutionTools',
8393
+ options: {
8394
+ apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
8395
+ },
8396
+ };
8397
+ }
8398
+ return null;
8399
+ },
8400
+ });
8401
+
8402
+ /**
8403
+ * @@@ registration1 of default configuration for Open AI
8404
+ *
8405
+ * Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
8406
+ *
8407
+ * @public exported from `@promptbook/core`
8408
+ */
8409
+ var _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
8410
+ title: 'Anthropic Claude',
8411
+ packageName: '@promptbook/anthropic-claude',
8412
+ className: 'AnthropicClaudeExecutionTools',
8413
+ getBoilerplateConfiguration: function () {
8414
+ return {
8415
+ title: 'Open AI (boilerplate)',
8416
+ packageName: '@promptbook/openai',
8417
+ className: 'OpenAiExecutionTools',
8418
+ options: {
8419
+ apiKey: 'sk-',
8420
+ },
8421
+ };
8422
+ },
8423
+ createConfigurationFromEnv: function (env) {
8424
+ if (typeof env.OPENAI_API_KEY === 'string') {
8425
+ return {
8426
+ title: 'Open AI (from env)',
8427
+ packageName: '@promptbook/openai',
8428
+ className: 'OpenAiExecutionTools',
8429
+ options: {
8430
+ apiKey: process.env.OPENAI_API_KEY,
8431
+ },
8432
+ };
8433
+ }
8434
+ return null;
8435
+ },
8436
+ });
8437
+
8332
8438
  /**
8333
8439
  * This class behaves like LocalStorage but separates keys by prefix
8334
8440
  *
@@ -8679,7 +8785,8 @@
8679
8785
  * TODO: [🧠] Should be in generated file GENERATOR_WARNING
8680
8786
  */
8681
8787
 
8682
- exports.BOILERPLATE_LLM_TOOLS_CONFIGURATION_ = BOILERPLATE_LLM_TOOLS_CONFIGURATION_;
8788
+ exports.$llmToolsMetadataRegister = $llmToolsMetadataRegister;
8789
+ exports.$llmToolsRegister = $llmToolsRegister;
8683
8790
  exports.BlockTypes = BlockTypes;
8684
8791
  exports.CLAIM = CLAIM;
8685
8792
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
@@ -8711,6 +8818,8 @@
8711
8818
  exports.UnexpectedError = UnexpectedError;
8712
8819
  exports.VersionMismatchError = VersionMismatchError;
8713
8820
  exports.ZERO_USAGE = ZERO_USAGE;
8821
+ exports._AnthropicClaudeMetadataRegistration = _AnthropicClaudeMetadataRegistration;
8822
+ exports._OpenAiMetadataRegistration = _OpenAiMetadataRegistration;
8714
8823
  exports.addUsage = addUsage;
8715
8824
  exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
8716
8825
  exports.cacheLlmTools = cacheLlmTools;