@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/umd/index.umd.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.66.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.66.0-4';
|
|
43
43
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -854,7 +854,7 @@
|
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-
|
|
857
|
+
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"}];
|
|
858
858
|
|
|
859
859
|
/**
|
|
860
860
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -6905,7 +6905,7 @@
|
|
|
6905
6905
|
};
|
|
6906
6906
|
}
|
|
6907
6907
|
/**
|
|
6908
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
6908
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
6909
6909
|
*/
|
|
6910
6910
|
|
|
6911
6911
|
/**
|
|
@@ -7128,7 +7128,7 @@
|
|
|
7128
7128
|
* TODO: [🍆] JSON mode
|
|
7129
7129
|
* TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
|
|
7130
7130
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7131
|
-
* TODO: Maybe make custom
|
|
7131
|
+
* TODO: Maybe make custom OpenAiError
|
|
7132
7132
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7133
7133
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7134
7134
|
* TODO: [📅] Maybe instead of `RemoteLlmExecutionToolsOptions` use `proxyWithAnonymousRemoteServer` (if implemented)
|
|
@@ -7139,7 +7139,7 @@
|
|
|
7139
7139
|
*
|
|
7140
7140
|
* @public exported from `@promptbook/anthropic-claude`
|
|
7141
7141
|
*/
|
|
7142
|
-
|
|
7142
|
+
var createAnthropicClaudeExecutionTools = Object.assign(function (options) {
|
|
7143
7143
|
if (options.isProxied) {
|
|
7144
7144
|
return new RemoteLlmExecutionTools(__assign(__assign({}, options), { isAnonymous: true, llmToolsConfiguration: [
|
|
7145
7145
|
{
|
|
@@ -7150,14 +7150,17 @@
|
|
|
7150
7150
|
},
|
|
7151
7151
|
], models: ANTHROPIC_CLAUDE_MODELS }));
|
|
7152
7152
|
}
|
|
7153
|
-
return new AnthropicClaudeExecutionTools(
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7153
|
+
return new AnthropicClaudeExecutionTools(options);
|
|
7154
|
+
}, {
|
|
7155
|
+
packageName: '@promptbook/anthropic-claude',
|
|
7156
|
+
className: 'AnthropicClaudeExecutionTools',
|
|
7157
|
+
});
|
|
7157
7158
|
/**
|
|
7158
7159
|
* TODO: [🧠] !!!! Make anonymous this with all LLM providers
|
|
7159
|
-
* TODO: [🧠] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
7160
|
+
* TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
7160
7161
|
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
7162
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
7163
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
7161
7164
|
*/
|
|
7162
7165
|
|
|
7163
7166
|
/**
|
|
@@ -7759,7 +7762,7 @@
|
|
|
7759
7762
|
}());
|
|
7760
7763
|
/**
|
|
7761
7764
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7762
|
-
* TODO: Maybe make custom
|
|
7765
|
+
* TODO: Maybe make custom AzureOpenAiError
|
|
7763
7766
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7764
7767
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7765
7768
|
*/
|
|
@@ -7773,7 +7776,7 @@
|
|
|
7773
7776
|
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
7774
7777
|
* @private internal utility of `OpenAiExecutionTools`
|
|
7775
7778
|
*/
|
|
7776
|
-
function
|
|
7779
|
+
function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
7777
7780
|
resultContent, rawResponse) {
|
|
7778
7781
|
var _a, _b;
|
|
7779
7782
|
if (rawResponse.usage === undefined) {
|
|
@@ -7799,11 +7802,11 @@
|
|
|
7799
7802
|
};
|
|
7800
7803
|
}
|
|
7801
7804
|
/**
|
|
7802
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
7805
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
7803
7806
|
*/
|
|
7804
7807
|
|
|
7805
7808
|
/**
|
|
7806
|
-
* Execution Tools for calling OpenAI API
|
|
7809
|
+
* Execution Tools for calling OpenAI API
|
|
7807
7810
|
*
|
|
7808
7811
|
* @public exported from `@promptbook/openai`
|
|
7809
7812
|
*/
|
|
@@ -7902,7 +7905,7 @@
|
|
|
7902
7905
|
resultContent = rawResponse.choices[0].message.content;
|
|
7903
7906
|
// eslint-disable-next-line prefer-const
|
|
7904
7907
|
complete = getCurrentIsoDate();
|
|
7905
|
-
usage =
|
|
7908
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7906
7909
|
if (resultContent === null) {
|
|
7907
7910
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
7908
7911
|
}
|
|
@@ -7971,7 +7974,7 @@
|
|
|
7971
7974
|
resultContent = rawResponse.choices[0].text;
|
|
7972
7975
|
// eslint-disable-next-line prefer-const
|
|
7973
7976
|
complete = getCurrentIsoDate();
|
|
7974
|
-
usage =
|
|
7977
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7975
7978
|
return [2 /*return*/, {
|
|
7976
7979
|
content: resultContent,
|
|
7977
7980
|
modelName: rawResponse.model || modelName,
|
|
@@ -8028,7 +8031,7 @@
|
|
|
8028
8031
|
resultContent = rawResponse.data[0].embedding;
|
|
8029
8032
|
// eslint-disable-next-line prefer-const
|
|
8030
8033
|
complete = getCurrentIsoDate();
|
|
8031
|
-
usage =
|
|
8034
|
+
usage = computeOpenAiUsage(content, '', rawResponse);
|
|
8032
8035
|
return [2 /*return*/, {
|
|
8033
8036
|
content: resultContent,
|
|
8034
8037
|
modelName: rawResponse.model || modelName,
|
|
@@ -8102,18 +8105,37 @@
|
|
|
8102
8105
|
/**
|
|
8103
8106
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
8104
8107
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
8105
|
-
* TODO: Maybe make custom
|
|
8108
|
+
* TODO: Maybe make custom OpenAiError
|
|
8106
8109
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
8107
8110
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
8108
8111
|
*/
|
|
8109
8112
|
|
|
8110
8113
|
/**
|
|
8114
|
+
* Execution Tools for calling OpenAI API
|
|
8115
|
+
*
|
|
8116
|
+
* @public exported from `@promptbook/openai`
|
|
8117
|
+
*/
|
|
8118
|
+
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
8119
|
+
// TODO: !!!!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
8120
|
+
return new OpenAiExecutionTools(options);
|
|
8121
|
+
}, {
|
|
8122
|
+
packageName: '@promptbook/openai',
|
|
8123
|
+
className: 'OpenAiExecutionTools',
|
|
8124
|
+
});
|
|
8125
|
+
/**
|
|
8126
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
8127
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
8128
|
+
*/
|
|
8129
|
+
|
|
8130
|
+
/**
|
|
8131
|
+
* @@@
|
|
8132
|
+
*
|
|
8133
|
+
* TODO: !!!!!! Remove EXECUTION_TOOLS_CLASSES and use $llmToolsRegister instead
|
|
8134
|
+
*
|
|
8111
8135
|
* @private internal type for `createLlmToolsFromConfiguration`
|
|
8112
8136
|
*/
|
|
8113
8137
|
var EXECUTION_TOOLS_CLASSES = {
|
|
8114
|
-
createOpenAiExecutionTools:
|
|
8115
|
-
return new OpenAiExecutionTools(__assign(__assign({}, options), { dangerouslyAllowBrowser: true /* <- TODO: [🧠] !!! Some mechanism for auto-detection of browser, maybe hide in `OpenAiExecutionTools` */ }));
|
|
8116
|
-
},
|
|
8138
|
+
createOpenAiExecutionTools: createOpenAiExecutionTools,
|
|
8117
8139
|
createAnthropicClaudeExecutionTools: createAnthropicClaudeExecutionTools,
|
|
8118
8140
|
createAzureOpenAiExecutionTools: function (options) {
|
|
8119
8141
|
return new AzureOpenAiExecutionTools(
|
|
@@ -8139,7 +8161,11 @@
|
|
|
8139
8161
|
if (options === void 0) { options = {}; }
|
|
8140
8162
|
var _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
8141
8163
|
var llmTools = configuration.map(function (llmConfiguration) {
|
|
8142
|
-
|
|
8164
|
+
var constructor = EXECUTION_TOOLS_CLASSES["create".concat(llmConfiguration.className)];
|
|
8165
|
+
if (!constructor) {
|
|
8166
|
+
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 "); }));
|
|
8167
|
+
}
|
|
8168
|
+
return constructor(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
|
|
8143
8169
|
});
|
|
8144
8170
|
return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
|
|
8145
8171
|
}
|
|
@@ -8152,6 +8178,38 @@
|
|
|
8152
8178
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8153
8179
|
*/
|
|
8154
8180
|
|
|
8181
|
+
/**
|
|
8182
|
+
* Register is @@@
|
|
8183
|
+
*
|
|
8184
|
+
* @private internal utility, exported are only signleton instances of this class
|
|
8185
|
+
*/
|
|
8186
|
+
var Register = /** @class */ (function () {
|
|
8187
|
+
function Register(storage) {
|
|
8188
|
+
this.storage = storage;
|
|
8189
|
+
}
|
|
8190
|
+
Register.prototype.list = function () {
|
|
8191
|
+
// <- TODO: ReadonlyDeep<Array<TRegistered>>
|
|
8192
|
+
return this.storage;
|
|
8193
|
+
};
|
|
8194
|
+
Register.prototype.register = function (registered) {
|
|
8195
|
+
// !!!!!! <- TODO: What to return here
|
|
8196
|
+
// TODO: !!!!!! Compare if same is not already registered
|
|
8197
|
+
this.storage.push(registered);
|
|
8198
|
+
};
|
|
8199
|
+
return Register;
|
|
8200
|
+
}());
|
|
8201
|
+
|
|
8202
|
+
/**
|
|
8203
|
+
* @@@
|
|
8204
|
+
*
|
|
8205
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
8206
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
8207
|
+
* @public exported from `@promptbook/core`
|
|
8208
|
+
*/
|
|
8209
|
+
var $llmToolsMetadataRegister = new Register([
|
|
8210
|
+
// TODO: !!!!!! Take from global scope
|
|
8211
|
+
]);
|
|
8212
|
+
|
|
8155
8213
|
/**
|
|
8156
8214
|
* @@@
|
|
8157
8215
|
*
|
|
@@ -8169,28 +8227,10 @@
|
|
|
8169
8227
|
throw new EnvironmentMismatchError('Function `createLlmToolsFromEnv` works only in Node.js environment');
|
|
8170
8228
|
}
|
|
8171
8229
|
dotenv__namespace.config();
|
|
8172
|
-
var llmToolsConfiguration =
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
packageName: '@promptbook/openai',
|
|
8177
|
-
className: 'OpenAiExecutionTools',
|
|
8178
|
-
options: {
|
|
8179
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
8180
|
-
},
|
|
8181
|
-
});
|
|
8182
|
-
}
|
|
8183
|
-
if (typeof process.env.ANTHROPIC_CLAUDE_API_KEY === 'string') {
|
|
8184
|
-
llmToolsConfiguration.push({
|
|
8185
|
-
title: 'Claude (from env)',
|
|
8186
|
-
packageName: '@promptbook/antrhopic-claude',
|
|
8187
|
-
className: 'AnthropicClaudeExecutionTools',
|
|
8188
|
-
options: {
|
|
8189
|
-
apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
|
|
8190
|
-
},
|
|
8191
|
-
});
|
|
8192
|
-
}
|
|
8193
|
-
// <- Note: [🦑] Add here new LLM provider
|
|
8230
|
+
var llmToolsConfiguration = $llmToolsMetadataRegister
|
|
8231
|
+
.list()
|
|
8232
|
+
.map(function (metadata) { return metadata.createConfigurationFromEnv(process.env); })
|
|
8233
|
+
.filter(function (configuration) { return configuration !== null; });
|
|
8194
8234
|
return llmToolsConfiguration;
|
|
8195
8235
|
}
|
|
8196
8236
|
/**
|
|
@@ -8225,7 +8265,7 @@
|
|
|
8225
8265
|
var configuration = createLlmToolsFromConfigurationFromEnv();
|
|
8226
8266
|
if (configuration.length === 0) {
|
|
8227
8267
|
// TODO: [🥃]
|
|
8228
|
-
throw new Error(spaceTrim__default["default"]("\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 "));
|
|
8268
|
+
throw new Error(spaceTrim__default["default"]("\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 "));
|
|
8229
8269
|
}
|
|
8230
8270
|
return createLlmToolsFromConfiguration(configuration, options);
|
|
8231
8271
|
}
|
|
@@ -8443,6 +8483,7 @@
|
|
|
8443
8483
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
8444
8484
|
*/
|
|
8445
8485
|
|
|
8486
|
+
// TODO: !!!!!! Probbably all LLM tools should be registered in `@promptbook/cli`
|
|
8446
8487
|
/**
|
|
8447
8488
|
* Initializes `make` command for Promptbook CLI utilities
|
|
8448
8489
|
*
|
|
@@ -8627,7 +8668,7 @@
|
|
|
8627
8668
|
});
|
|
8628
8669
|
}
|
|
8629
8670
|
/**
|
|
8630
|
-
* TODO: [🥃] !!! Allow `ptbk make` without llm tools
|
|
8671
|
+
* TODO: [🥃] !!! Allow `ptbk make` without configuring any llm tools
|
|
8631
8672
|
* TODO: Maybe remove this command - "about" command should be enough?
|
|
8632
8673
|
* TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
|
|
8633
8674
|
* Note: [🟡] This code should never be published outside of `@promptbook/cli`
|