@promptbook/cli 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.
- package/esm/index.es.js +87 -46
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -0
- package/esm/typings/src/_packages/core.index.d.ts +8 -2
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +10 -2
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/config.d.ts +0 -7
- package/esm/typings/src/execution/AvailableModel.d.ts +20 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +10 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/$llmToolsMetadataRegister.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsRegister.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +7 -13
- package/esm/typings/src/llm-providers/_common/LlmToolsMetadata.d.ts +27 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsOptions.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/config.d.ts +4 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.test.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +7 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.d.ts → computeOpenAiUsage.d.ts} +2 -2
- package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.test.d.ts → computeOpenAiUsage.test.d.ts} +1 -1
- package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +15 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/personas/preparePersona.test.d.ts +1 -1
- package/esm/typings/src/utils/Register.d.ts +22 -0
- package/package.json +1 -1
- package/umd/index.umd.js +87 -46
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ import glob from 'glob-promise';
|
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook library
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_VERSION = '0.66.0-
|
|
23
|
+
var PROMPTBOOK_VERSION = '0.66.0-4';
|
|
24
24
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
25
25
|
|
|
26
26
|
/*! *****************************************************************************
|
|
@@ -835,7 +835,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
837
|
|
|
838
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-
|
|
838
|
+
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"}];
|
|
839
839
|
|
|
840
840
|
/**
|
|
841
841
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -6886,7 +6886,7 @@ resultContent, rawResponse) {
|
|
|
6886
6886
|
};
|
|
6887
6887
|
}
|
|
6888
6888
|
/**
|
|
6889
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
6889
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
6890
6890
|
*/
|
|
6891
6891
|
|
|
6892
6892
|
/**
|
|
@@ -7109,7 +7109,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
|
|
|
7109
7109
|
* TODO: [🍆] JSON mode
|
|
7110
7110
|
* TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
|
|
7111
7111
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7112
|
-
* TODO: Maybe make custom
|
|
7112
|
+
* TODO: Maybe make custom OpenAiError
|
|
7113
7113
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7114
7114
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7115
7115
|
* TODO: [📅] Maybe instead of `RemoteLlmExecutionToolsOptions` use `proxyWithAnonymousRemoteServer` (if implemented)
|
|
@@ -7120,7 +7120,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
|
|
|
7120
7120
|
*
|
|
7121
7121
|
* @public exported from `@promptbook/anthropic-claude`
|
|
7122
7122
|
*/
|
|
7123
|
-
|
|
7123
|
+
var createAnthropicClaudeExecutionTools = Object.assign(function (options) {
|
|
7124
7124
|
if (options.isProxied) {
|
|
7125
7125
|
return new RemoteLlmExecutionTools(__assign(__assign({}, options), { isAnonymous: true, llmToolsConfiguration: [
|
|
7126
7126
|
{
|
|
@@ -7131,14 +7131,17 @@ function createAnthropicClaudeExecutionTools(options) {
|
|
|
7131
7131
|
},
|
|
7132
7132
|
], models: ANTHROPIC_CLAUDE_MODELS }));
|
|
7133
7133
|
}
|
|
7134
|
-
return new AnthropicClaudeExecutionTools(
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7134
|
+
return new AnthropicClaudeExecutionTools(options);
|
|
7135
|
+
}, {
|
|
7136
|
+
packageName: '@promptbook/anthropic-claude',
|
|
7137
|
+
className: 'AnthropicClaudeExecutionTools',
|
|
7138
|
+
});
|
|
7138
7139
|
/**
|
|
7139
7140
|
* TODO: [🧠] !!!! Make anonymous this with all LLM providers
|
|
7140
|
-
* TODO: [🧠] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
7141
|
+
* TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
7141
7142
|
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
7143
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
7144
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
7142
7145
|
*/
|
|
7143
7146
|
|
|
7144
7147
|
/**
|
|
@@ -7740,7 +7743,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
7740
7743
|
}());
|
|
7741
7744
|
/**
|
|
7742
7745
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7743
|
-
* TODO: Maybe make custom
|
|
7746
|
+
* TODO: Maybe make custom AzureOpenAiError
|
|
7744
7747
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7745
7748
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7746
7749
|
*/
|
|
@@ -7754,7 +7757,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
7754
7757
|
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
7755
7758
|
* @private internal utility of `OpenAiExecutionTools`
|
|
7756
7759
|
*/
|
|
7757
|
-
function
|
|
7760
|
+
function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
7758
7761
|
resultContent, rawResponse) {
|
|
7759
7762
|
var _a, _b;
|
|
7760
7763
|
if (rawResponse.usage === undefined) {
|
|
@@ -7780,11 +7783,11 @@ resultContent, rawResponse) {
|
|
|
7780
7783
|
};
|
|
7781
7784
|
}
|
|
7782
7785
|
/**
|
|
7783
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
7786
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
7784
7787
|
*/
|
|
7785
7788
|
|
|
7786
7789
|
/**
|
|
7787
|
-
* Execution Tools for calling OpenAI API
|
|
7790
|
+
* Execution Tools for calling OpenAI API
|
|
7788
7791
|
*
|
|
7789
7792
|
* @public exported from `@promptbook/openai`
|
|
7790
7793
|
*/
|
|
@@ -7883,7 +7886,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7883
7886
|
resultContent = rawResponse.choices[0].message.content;
|
|
7884
7887
|
// eslint-disable-next-line prefer-const
|
|
7885
7888
|
complete = getCurrentIsoDate();
|
|
7886
|
-
usage =
|
|
7889
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7887
7890
|
if (resultContent === null) {
|
|
7888
7891
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
7889
7892
|
}
|
|
@@ -7952,7 +7955,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7952
7955
|
resultContent = rawResponse.choices[0].text;
|
|
7953
7956
|
// eslint-disable-next-line prefer-const
|
|
7954
7957
|
complete = getCurrentIsoDate();
|
|
7955
|
-
usage =
|
|
7958
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7956
7959
|
return [2 /*return*/, {
|
|
7957
7960
|
content: resultContent,
|
|
7958
7961
|
modelName: rawResponse.model || modelName,
|
|
@@ -8009,7 +8012,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
8009
8012
|
resultContent = rawResponse.data[0].embedding;
|
|
8010
8013
|
// eslint-disable-next-line prefer-const
|
|
8011
8014
|
complete = getCurrentIsoDate();
|
|
8012
|
-
usage =
|
|
8015
|
+
usage = computeOpenAiUsage(content, '', rawResponse);
|
|
8013
8016
|
return [2 /*return*/, {
|
|
8014
8017
|
content: resultContent,
|
|
8015
8018
|
modelName: rawResponse.model || modelName,
|
|
@@ -8083,18 +8086,37 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
8083
8086
|
/**
|
|
8084
8087
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
8085
8088
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
8086
|
-
* TODO: Maybe make custom
|
|
8089
|
+
* TODO: Maybe make custom OpenAiError
|
|
8087
8090
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
8088
8091
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
8089
8092
|
*/
|
|
8090
8093
|
|
|
8091
8094
|
/**
|
|
8095
|
+
* Execution Tools for calling OpenAI API
|
|
8096
|
+
*
|
|
8097
|
+
* @public exported from `@promptbook/openai`
|
|
8098
|
+
*/
|
|
8099
|
+
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
8100
|
+
// TODO: !!!!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
8101
|
+
return new OpenAiExecutionTools(options);
|
|
8102
|
+
}, {
|
|
8103
|
+
packageName: '@promptbook/openai',
|
|
8104
|
+
className: 'OpenAiExecutionTools',
|
|
8105
|
+
});
|
|
8106
|
+
/**
|
|
8107
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
8108
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
8109
|
+
*/
|
|
8110
|
+
|
|
8111
|
+
/**
|
|
8112
|
+
* @@@
|
|
8113
|
+
*
|
|
8114
|
+
* TODO: !!!!!! Remove EXECUTION_TOOLS_CLASSES and use $llmToolsRegister instead
|
|
8115
|
+
*
|
|
8092
8116
|
* @private internal type for `createLlmToolsFromConfiguration`
|
|
8093
8117
|
*/
|
|
8094
8118
|
var EXECUTION_TOOLS_CLASSES = {
|
|
8095
|
-
createOpenAiExecutionTools:
|
|
8096
|
-
return new OpenAiExecutionTools(__assign(__assign({}, options), { dangerouslyAllowBrowser: true /* <- TODO: [🧠] !!! Some mechanism for auto-detection of browser, maybe hide in `OpenAiExecutionTools` */ }));
|
|
8097
|
-
},
|
|
8119
|
+
createOpenAiExecutionTools: createOpenAiExecutionTools,
|
|
8098
8120
|
createAnthropicClaudeExecutionTools: createAnthropicClaudeExecutionTools,
|
|
8099
8121
|
createAzureOpenAiExecutionTools: function (options) {
|
|
8100
8122
|
return new AzureOpenAiExecutionTools(
|
|
@@ -8120,7 +8142,11 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
8120
8142
|
if (options === void 0) { options = {}; }
|
|
8121
8143
|
var _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
8122
8144
|
var llmTools = configuration.map(function (llmConfiguration) {
|
|
8123
|
-
|
|
8145
|
+
var constructor = EXECUTION_TOOLS_CLASSES["create".concat(llmConfiguration.className)];
|
|
8146
|
+
if (!constructor) {
|
|
8147
|
+
throw new Error(spaceTrim(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 "); }));
|
|
8148
|
+
}
|
|
8149
|
+
return constructor(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
|
|
8124
8150
|
});
|
|
8125
8151
|
return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
|
|
8126
8152
|
}
|
|
@@ -8133,6 +8159,38 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
8133
8159
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8134
8160
|
*/
|
|
8135
8161
|
|
|
8162
|
+
/**
|
|
8163
|
+
* Register is @@@
|
|
8164
|
+
*
|
|
8165
|
+
* @private internal utility, exported are only signleton instances of this class
|
|
8166
|
+
*/
|
|
8167
|
+
var Register = /** @class */ (function () {
|
|
8168
|
+
function Register(storage) {
|
|
8169
|
+
this.storage = storage;
|
|
8170
|
+
}
|
|
8171
|
+
Register.prototype.list = function () {
|
|
8172
|
+
// <- TODO: ReadonlyDeep<Array<TRegistered>>
|
|
8173
|
+
return this.storage;
|
|
8174
|
+
};
|
|
8175
|
+
Register.prototype.register = function (registered) {
|
|
8176
|
+
// !!!!!! <- TODO: What to return here
|
|
8177
|
+
// TODO: !!!!!! Compare if same is not already registered
|
|
8178
|
+
this.storage.push(registered);
|
|
8179
|
+
};
|
|
8180
|
+
return Register;
|
|
8181
|
+
}());
|
|
8182
|
+
|
|
8183
|
+
/**
|
|
8184
|
+
* @@@
|
|
8185
|
+
*
|
|
8186
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
8187
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
8188
|
+
* @public exported from `@promptbook/core`
|
|
8189
|
+
*/
|
|
8190
|
+
var $llmToolsMetadataRegister = new Register([
|
|
8191
|
+
// TODO: !!!!!! Take from global scope
|
|
8192
|
+
]);
|
|
8193
|
+
|
|
8136
8194
|
/**
|
|
8137
8195
|
* @@@
|
|
8138
8196
|
*
|
|
@@ -8150,28 +8208,10 @@ function createLlmToolsFromConfigurationFromEnv() {
|
|
|
8150
8208
|
throw new EnvironmentMismatchError('Function `createLlmToolsFromEnv` works only in Node.js environment');
|
|
8151
8209
|
}
|
|
8152
8210
|
dotenv.config();
|
|
8153
|
-
var llmToolsConfiguration =
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
packageName: '@promptbook/openai',
|
|
8158
|
-
className: 'OpenAiExecutionTools',
|
|
8159
|
-
options: {
|
|
8160
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
8161
|
-
},
|
|
8162
|
-
});
|
|
8163
|
-
}
|
|
8164
|
-
if (typeof process.env.ANTHROPIC_CLAUDE_API_KEY === 'string') {
|
|
8165
|
-
llmToolsConfiguration.push({
|
|
8166
|
-
title: 'Claude (from env)',
|
|
8167
|
-
packageName: '@promptbook/antrhopic-claude',
|
|
8168
|
-
className: 'AnthropicClaudeExecutionTools',
|
|
8169
|
-
options: {
|
|
8170
|
-
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
|
|
8171
|
-
},
|
|
8172
|
-
});
|
|
8173
|
-
}
|
|
8174
|
-
// <- Note: [🦑] Add here new LLM provider
|
|
8211
|
+
var llmToolsConfiguration = $llmToolsMetadataRegister
|
|
8212
|
+
.list()
|
|
8213
|
+
.map(function (metadata) { return metadata.createConfigurationFromEnv(process.env); })
|
|
8214
|
+
.filter(function (configuration) { return configuration !== null; });
|
|
8175
8215
|
return llmToolsConfiguration;
|
|
8176
8216
|
}
|
|
8177
8217
|
/**
|
|
@@ -8206,7 +8246,7 @@ function createLlmToolsFromEnv(options) {
|
|
|
8206
8246
|
var configuration = createLlmToolsFromConfigurationFromEnv();
|
|
8207
8247
|
if (configuration.length === 0) {
|
|
8208
8248
|
// TODO: [🥃]
|
|
8209
|
-
throw new Error(spaceTrim("\n No LLM tools found in the environment\n\n Please set one of environment variables:\n - OPENAI_API_KEY\n - ANTHROPIC_CLAUDE_API_KEY\n "));
|
|
8249
|
+
throw new Error(spaceTrim("\n No LLM tools found in the environment\n\n !!!!!!!@@@@You have maybe forgotten to two things:\n\n Please set one of environment variables:\n - OPENAI_API_KEY\n - ANTHROPIC_CLAUDE_API_KEY\n "));
|
|
8210
8250
|
}
|
|
8211
8251
|
return createLlmToolsFromConfiguration(configuration, options);
|
|
8212
8252
|
}
|
|
@@ -8424,6 +8464,7 @@ function getLlmToolsForCli(options) {
|
|
|
8424
8464
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
8425
8465
|
*/
|
|
8426
8466
|
|
|
8467
|
+
// TODO: !!!!!! Probbably all LLM tools should be registered in `@promptbook/cli`
|
|
8427
8468
|
/**
|
|
8428
8469
|
* Initializes `make` command for Promptbook CLI utilities
|
|
8429
8470
|
*
|
|
@@ -8608,7 +8649,7 @@ function initializeMakeCommand(program) {
|
|
|
8608
8649
|
});
|
|
8609
8650
|
}
|
|
8610
8651
|
/**
|
|
8611
|
-
* TODO: [🥃] !!! Allow `ptbk make` without llm tools
|
|
8652
|
+
* TODO: [🥃] !!! Allow `ptbk make` without configuring any llm tools
|
|
8612
8653
|
* TODO: Maybe remove this command - "about" command should be enough?
|
|
8613
8654
|
* TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
|
|
8614
8655
|
* Note: [🟡] This code should never be published outside of `@promptbook/cli`
|