@promptbook/node 0.66.0-1 → 0.66.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 +48 -22
- 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 +6 -2
- 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/llm-providers/_common/$llmToolsConfigurationBoilerplatesRegister.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsRegister.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +2 -10
- 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/utils/Register.d.ts +22 -0
- package/package.json +2 -2
- package/umd/index.umd.js +48 -22
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -17,7 +17,7 @@ import OpenAI from 'openai';
|
|
|
17
17
|
/**
|
|
18
18
|
* The version of the Promptbook library
|
|
19
19
|
*/
|
|
20
|
-
var PROMPTBOOK_VERSION = '0.66.0-
|
|
20
|
+
var PROMPTBOOK_VERSION = '0.66.0-3';
|
|
21
21
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
22
22
|
|
|
23
23
|
/*! *****************************************************************************
|
|
@@ -696,7 +696,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-
|
|
699
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-3",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-3",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-3",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-3",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"}];
|
|
700
700
|
|
|
701
701
|
/**
|
|
702
702
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -6650,7 +6650,7 @@ resultContent, rawResponse) {
|
|
|
6650
6650
|
};
|
|
6651
6651
|
}
|
|
6652
6652
|
/**
|
|
6653
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
6653
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
6654
6654
|
*/
|
|
6655
6655
|
|
|
6656
6656
|
/**
|
|
@@ -6873,7 +6873,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
|
|
|
6873
6873
|
* TODO: [🍆] JSON mode
|
|
6874
6874
|
* TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
|
|
6875
6875
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
6876
|
-
* TODO: Maybe make custom
|
|
6876
|
+
* TODO: Maybe make custom OpenAiError
|
|
6877
6877
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
6878
6878
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
6879
6879
|
* TODO: [📅] Maybe instead of `RemoteLlmExecutionToolsOptions` use `proxyWithAnonymousRemoteServer` (if implemented)
|
|
@@ -6884,7 +6884,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
|
|
|
6884
6884
|
*
|
|
6885
6885
|
* @public exported from `@promptbook/anthropic-claude`
|
|
6886
6886
|
*/
|
|
6887
|
-
|
|
6887
|
+
var createAnthropicClaudeExecutionTools = Object.assign(function (options) {
|
|
6888
6888
|
if (options.isProxied) {
|
|
6889
6889
|
return new RemoteLlmExecutionTools(__assign(__assign({}, options), { isAnonymous: true, llmToolsConfiguration: [
|
|
6890
6890
|
{
|
|
@@ -6895,14 +6895,17 @@ function createAnthropicClaudeExecutionTools(options) {
|
|
|
6895
6895
|
},
|
|
6896
6896
|
], models: ANTHROPIC_CLAUDE_MODELS }));
|
|
6897
6897
|
}
|
|
6898
|
-
return new AnthropicClaudeExecutionTools(
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6898
|
+
return new AnthropicClaudeExecutionTools(options);
|
|
6899
|
+
}, {
|
|
6900
|
+
packageName: '@promptbook/anthropic-claude',
|
|
6901
|
+
className: 'AnthropicClaudeExecutionTools',
|
|
6902
|
+
});
|
|
6902
6903
|
/**
|
|
6903
6904
|
* TODO: [🧠] !!!! Make anonymous this with all LLM providers
|
|
6904
|
-
* TODO: [🧠] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
6905
|
+
* TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
6905
6906
|
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
6907
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
6908
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
6906
6909
|
*/
|
|
6907
6910
|
|
|
6908
6911
|
/**
|
|
@@ -7504,7 +7507,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
7504
7507
|
}());
|
|
7505
7508
|
/**
|
|
7506
7509
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7507
|
-
* TODO: Maybe make custom
|
|
7510
|
+
* TODO: Maybe make custom AzureOpenAiError
|
|
7508
7511
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7509
7512
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7510
7513
|
*/
|
|
@@ -7518,7 +7521,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
7518
7521
|
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
7519
7522
|
* @private internal utility of `OpenAiExecutionTools`
|
|
7520
7523
|
*/
|
|
7521
|
-
function
|
|
7524
|
+
function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
7522
7525
|
resultContent, rawResponse) {
|
|
7523
7526
|
var _a, _b;
|
|
7524
7527
|
if (rawResponse.usage === undefined) {
|
|
@@ -7544,11 +7547,11 @@ resultContent, rawResponse) {
|
|
|
7544
7547
|
};
|
|
7545
7548
|
}
|
|
7546
7549
|
/**
|
|
7547
|
-
* TODO: [🤝] DRY Maybe some common abstraction between `
|
|
7550
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
7548
7551
|
*/
|
|
7549
7552
|
|
|
7550
7553
|
/**
|
|
7551
|
-
* Execution Tools for calling OpenAI API
|
|
7554
|
+
* Execution Tools for calling OpenAI API
|
|
7552
7555
|
*
|
|
7553
7556
|
* @public exported from `@promptbook/openai`
|
|
7554
7557
|
*/
|
|
@@ -7647,7 +7650,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7647
7650
|
resultContent = rawResponse.choices[0].message.content;
|
|
7648
7651
|
// eslint-disable-next-line prefer-const
|
|
7649
7652
|
complete = getCurrentIsoDate();
|
|
7650
|
-
usage =
|
|
7653
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7651
7654
|
if (resultContent === null) {
|
|
7652
7655
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
7653
7656
|
}
|
|
@@ -7716,7 +7719,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7716
7719
|
resultContent = rawResponse.choices[0].text;
|
|
7717
7720
|
// eslint-disable-next-line prefer-const
|
|
7718
7721
|
complete = getCurrentIsoDate();
|
|
7719
|
-
usage =
|
|
7722
|
+
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
7720
7723
|
return [2 /*return*/, {
|
|
7721
7724
|
content: resultContent,
|
|
7722
7725
|
modelName: rawResponse.model || modelName,
|
|
@@ -7773,7 +7776,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7773
7776
|
resultContent = rawResponse.data[0].embedding;
|
|
7774
7777
|
// eslint-disable-next-line prefer-const
|
|
7775
7778
|
complete = getCurrentIsoDate();
|
|
7776
|
-
usage =
|
|
7779
|
+
usage = computeOpenAiUsage(content, '', rawResponse);
|
|
7777
7780
|
return [2 /*return*/, {
|
|
7778
7781
|
content: resultContent,
|
|
7779
7782
|
modelName: rawResponse.model || modelName,
|
|
@@ -7847,18 +7850,37 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
7847
7850
|
/**
|
|
7848
7851
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
7849
7852
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
7850
|
-
* TODO: Maybe make custom
|
|
7853
|
+
* TODO: Maybe make custom OpenAiError
|
|
7851
7854
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
7852
7855
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
7853
7856
|
*/
|
|
7854
7857
|
|
|
7855
7858
|
/**
|
|
7859
|
+
* Execution Tools for calling OpenAI API
|
|
7860
|
+
*
|
|
7861
|
+
* @public exported from `@promptbook/openai`
|
|
7862
|
+
*/
|
|
7863
|
+
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
7864
|
+
// TODO: !!!!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
7865
|
+
return new OpenAiExecutionTools(options);
|
|
7866
|
+
}, {
|
|
7867
|
+
packageName: '@promptbook/openai',
|
|
7868
|
+
className: 'OpenAiExecutionTools',
|
|
7869
|
+
});
|
|
7870
|
+
/**
|
|
7871
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
7872
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
7873
|
+
*/
|
|
7874
|
+
|
|
7875
|
+
/**
|
|
7876
|
+
* @@@
|
|
7877
|
+
*
|
|
7878
|
+
* TODO: !!!!!! Not centralized - register each provider to each package
|
|
7879
|
+
*
|
|
7856
7880
|
* @private internal type for `createLlmToolsFromConfiguration`
|
|
7857
7881
|
*/
|
|
7858
7882
|
var EXECUTION_TOOLS_CLASSES = {
|
|
7859
|
-
createOpenAiExecutionTools:
|
|
7860
|
-
return new OpenAiExecutionTools(__assign(__assign({}, options), { dangerouslyAllowBrowser: true /* <- TODO: [🧠] !!! Some mechanism for auto-detection of browser, maybe hide in `OpenAiExecutionTools` */ }));
|
|
7861
|
-
},
|
|
7883
|
+
createOpenAiExecutionTools: createOpenAiExecutionTools,
|
|
7862
7884
|
createAnthropicClaudeExecutionTools: createAnthropicClaudeExecutionTools,
|
|
7863
7885
|
createAzureOpenAiExecutionTools: function (options) {
|
|
7864
7886
|
return new AzureOpenAiExecutionTools(
|
|
@@ -7884,7 +7906,11 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
7884
7906
|
if (options === void 0) { options = {}; }
|
|
7885
7907
|
var _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
7886
7908
|
var llmTools = configuration.map(function (llmConfiguration) {
|
|
7887
|
-
|
|
7909
|
+
var constructor = EXECUTION_TOOLS_CLASSES["create".concat(llmConfiguration.className)];
|
|
7910
|
+
if (!constructor) {
|
|
7911
|
+
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 "); }));
|
|
7912
|
+
}
|
|
7913
|
+
return constructor(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
|
|
7888
7914
|
});
|
|
7889
7915
|
return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
|
|
7890
7916
|
}
|