@promptbook/cli 0.67.0-2 â 0.67.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/README.md +21 -37
- package/esm/index.es.js +22 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -2
- package/esm/typings/src/config.d.ts +12 -0
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +1 -6
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +16 -6
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +12 -3
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/remote/playground/playground.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +2 -4
- package/package.json +1 -1
- package/umd/index.umd.js +22 -5
- package/umd/index.umd.js.map +1 -1
|
@@ -157,7 +157,7 @@ import type { string_protocol } from '../types/typeAliases';
|
|
|
157
157
|
import type { string_email } from '../types/typeAliases';
|
|
158
158
|
import type { string_emails } from '../types/typeAliases';
|
|
159
159
|
import type { string_uuid } from '../types/typeAliases';
|
|
160
|
-
import type {
|
|
160
|
+
import type { string_user_id } from '../types/typeAliases';
|
|
161
161
|
import type { string_sha256 } from '../types/typeAliases';
|
|
162
162
|
import type { string_semantic_version } from '../types/typeAliases';
|
|
163
163
|
import type { string_version_dependency } from '../types/typeAliases';
|
|
@@ -383,7 +383,7 @@ export type { string_protocol };
|
|
|
383
383
|
export type { string_email };
|
|
384
384
|
export type { string_emails };
|
|
385
385
|
export type { string_uuid };
|
|
386
|
-
export type {
|
|
386
|
+
export type { string_user_id };
|
|
387
387
|
export type { string_sha256 };
|
|
388
388
|
export type { string_semantic_version };
|
|
389
389
|
export type { string_version_dependency };
|
|
@@ -30,6 +30,18 @@ export declare const LOOP_LIMIT = 1000;
|
|
|
30
30
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
31
31
|
*/
|
|
32
32
|
export declare const CHARACTER_LOOP_LIMIT = 100000;
|
|
33
|
+
/**
|
|
34
|
+
* Timeout for the connections in milliseconds
|
|
35
|
+
*
|
|
36
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
37
|
+
*/
|
|
38
|
+
export declare const CONNECTION_TIMEOUT_MS: number;
|
|
39
|
+
/**
|
|
40
|
+
* How many times to retry the connections
|
|
41
|
+
*
|
|
42
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
43
|
+
*/
|
|
44
|
+
export declare const CONNECTION_RETRIES_LIMIT = 5;
|
|
33
45
|
/**
|
|
34
46
|
* The maximum number of (LLM) tasks running in parallel
|
|
35
47
|
*
|
package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { client_id } from '../../../types/typeAliases';
|
|
2
1
|
import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
|
|
3
2
|
/**
|
|
4
3
|
* Socket.io progress for remote text generation
|
|
@@ -11,10 +10,6 @@ export type PromptbookServer_ListModels_CollectionRequest = {
|
|
|
11
10
|
* Collection mode
|
|
12
11
|
*/
|
|
13
12
|
isAnonymous: false;
|
|
14
|
-
/**
|
|
15
|
-
* Client responsible for the requests
|
|
16
|
-
*/
|
|
17
|
-
readonly clientId: client_id;
|
|
18
13
|
};
|
|
19
14
|
export type PromptbookServer_ListModels_AnonymousRequest = {
|
|
20
15
|
/**
|
|
@@ -29,6 +24,6 @@ export type PromptbookServer_ListModels_AnonymousRequest = {
|
|
|
29
24
|
/**
|
|
30
25
|
* TODO: [ðĄ] DRY `PromptbookServer_Prompt_Request` and `PromptbookServer_ListModels_Request`
|
|
31
26
|
* TODO: [ð§ ][ð] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
32
|
-
* TODO: [ð§ ][ðĪš] Pass `
|
|
27
|
+
* TODO: [ð§ ][ðĪš] Pass `userId` in `PromptbookServer_ListModels_Request`
|
|
33
28
|
* TODO: [ð] Listing models (and checking configuration) probbably should go through REST API not Socket.io
|
|
34
29
|
*/
|
package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Prompt } from '../../../types/Prompt';
|
|
2
|
-
import type {
|
|
2
|
+
import type { string_user_id } from '../../../types/typeAliases';
|
|
3
3
|
import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
|
|
4
4
|
/**
|
|
5
5
|
* Socket.io progress for remote text generation
|
|
@@ -11,11 +11,14 @@ export type PromptbookServer_Prompt_CollectionRequest = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Collection mode
|
|
13
13
|
*/
|
|
14
|
-
isAnonymous: false;
|
|
14
|
+
readonly isAnonymous: false;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Identifier of the end user
|
|
17
|
+
*
|
|
18
|
+
* Note: this is passed to the certain model providers to identify misuse
|
|
19
|
+
* Note: In anonymous mode it is not required to identify
|
|
17
20
|
*/
|
|
18
|
-
readonly
|
|
21
|
+
readonly userId: string_user_id;
|
|
19
22
|
/**
|
|
20
23
|
* The Prompt to execute
|
|
21
24
|
*/
|
|
@@ -25,7 +28,14 @@ export type PromptbookServer_Prompt_AnonymousRequest = {
|
|
|
25
28
|
/**
|
|
26
29
|
* Anonymous mode
|
|
27
30
|
*/
|
|
28
|
-
isAnonymous: true;
|
|
31
|
+
readonly isAnonymous: true;
|
|
32
|
+
/**
|
|
33
|
+
* Identifier of the end user
|
|
34
|
+
*
|
|
35
|
+
* Note: this is passed to the certain model providers to identify misuse
|
|
36
|
+
* Note: In anonymous mode it is not required to identify
|
|
37
|
+
*/
|
|
38
|
+
readonly userId?: string_user_id;
|
|
29
39
|
/**
|
|
30
40
|
* Configuration for the LLM tools
|
|
31
41
|
*/
|
|
@@ -38,4 +48,4 @@ export type PromptbookServer_Prompt_AnonymousRequest = {
|
|
|
38
48
|
/**
|
|
39
49
|
* TODO: [ðĄ] DRY `PromptbookServer_Prompt_Request` and `PromptbookServer_ListModels_Request`
|
|
40
50
|
* TODO: [ð§ ][ð] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
41
|
-
*/
|
|
51
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
|
|
2
|
-
import type { client_id } from '../../../types/typeAliases';
|
|
3
2
|
import type { string_base_url } from '../../../types/typeAliases';
|
|
4
3
|
import type { string_uri } from '../../../types/typeAliases';
|
|
4
|
+
import type { string_user_id } from '../../../types/typeAliases';
|
|
5
5
|
import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
|
|
6
6
|
/**
|
|
7
7
|
* Options for `RemoteLlmExecutionTools`
|
|
@@ -34,15 +34,24 @@ export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
|
34
34
|
* Configuration for the LLM tools
|
|
35
35
|
*/
|
|
36
36
|
readonly llmToolsConfiguration: LlmToolsConfiguration;
|
|
37
|
+
/**
|
|
38
|
+
* Identifier of the end user
|
|
39
|
+
*
|
|
40
|
+
* Note: this is passed to the certain model providers to identify misuse
|
|
41
|
+
* Note: In anonymous mode it is not required to identify
|
|
42
|
+
*/
|
|
43
|
+
readonly userId?: string_user_id;
|
|
37
44
|
} | {
|
|
38
45
|
/**
|
|
39
46
|
* Use anonymous server with client identification and fixed collection
|
|
40
47
|
*/
|
|
41
48
|
isAnonymous: false;
|
|
42
49
|
/**
|
|
43
|
-
*
|
|
50
|
+
* Identifier of the end user
|
|
51
|
+
*
|
|
52
|
+
* Note: this is passed to the certain model providers to identify misuse
|
|
44
53
|
*/
|
|
45
|
-
readonly
|
|
54
|
+
readonly userId: string_user_id;
|
|
46
55
|
});
|
|
47
56
|
/**
|
|
48
57
|
* TODO: [ð§ ][ð] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PipelineCollection } from '../../../collection/PipelineCollection';
|
|
2
2
|
import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
|
|
3
3
|
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
4
|
-
import type { client_id } from '../../../types/typeAliases';
|
|
5
4
|
import type { string_uri } from '../../../types/typeAliases';
|
|
5
|
+
import type { string_user_id } from '../../../types/typeAliases';
|
|
6
6
|
/**
|
|
7
7
|
* @@@
|
|
8
8
|
*
|
|
@@ -50,7 +50,7 @@ export type CollectionRemoteServerOptions = {
|
|
|
50
50
|
/**
|
|
51
51
|
* Creates llm execution tools for each client
|
|
52
52
|
*/
|
|
53
|
-
createLlmExecutionTools(
|
|
53
|
+
createLlmExecutionTools(userId: string_user_id | undefined): LlmExecutionTools;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
56
|
* TODO: Constrain anonymous mode for specific models / providers
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
2
|
+
import '../../openai/register-constructor';
|
|
@@ -391,11 +391,9 @@ export type string_uuid = string & {
|
|
|
391
391
|
readonly _type: 'uuid';
|
|
392
392
|
};
|
|
393
393
|
/**
|
|
394
|
-
*
|
|
394
|
+
* End user identifier;
|
|
395
395
|
*/
|
|
396
|
-
export type
|
|
397
|
-
readonly _type: 'client_id';
|
|
398
|
-
};
|
|
396
|
+
export type string_user_id = string;
|
|
399
397
|
/**
|
|
400
398
|
* Semantic helper
|
|
401
399
|
*
|
package/package.json
CHANGED
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.67.0-
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.67.0-3';
|
|
43
43
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -426,6 +426,18 @@
|
|
|
426
426
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
427
427
|
*/
|
|
428
428
|
var LOOP_LIMIT = 1000;
|
|
429
|
+
/**
|
|
430
|
+
* Timeout for the connections in milliseconds
|
|
431
|
+
*
|
|
432
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
433
|
+
*/
|
|
434
|
+
var CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
435
|
+
/**
|
|
436
|
+
* How many times to retry the connections
|
|
437
|
+
*
|
|
438
|
+
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
439
|
+
*/
|
|
440
|
+
var CONNECTION_RETRIES_LIMIT = 5;
|
|
429
441
|
/**
|
|
430
442
|
* The maximum number of (LLM) tasks running in parallel
|
|
431
443
|
*
|
|
@@ -1041,7 +1053,7 @@
|
|
|
1041
1053
|
});
|
|
1042
1054
|
}
|
|
1043
1055
|
|
|
1044
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.0-
|
|
1056
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.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.67.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.67.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.67.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"}];
|
|
1045
1057
|
|
|
1046
1058
|
/**
|
|
1047
1059
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -6972,6 +6984,9 @@
|
|
|
6972
6984
|
});
|
|
6973
6985
|
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled });
|
|
6974
6986
|
});
|
|
6987
|
+
if (metadata.length === 0) {
|
|
6988
|
+
return "No LLM providers are available.";
|
|
6989
|
+
}
|
|
6975
6990
|
return spaceTrim__default["default"](function (block) { return "\n Available LLM providers are:\n ".concat(block(metadata
|
|
6976
6991
|
.map(function (_a, i) {
|
|
6977
6992
|
var packageName = _a.packageName, className = _a.className, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
|
|
@@ -7933,7 +7948,6 @@
|
|
|
7933
7948
|
else {
|
|
7934
7949
|
socket.emit('listModels-request', {
|
|
7935
7950
|
isAnonymous: false,
|
|
7936
|
-
clientId: this.options.clientId,
|
|
7937
7951
|
} /* <- TODO: [ðĪ] */);
|
|
7938
7952
|
}
|
|
7939
7953
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
@@ -7963,6 +7977,8 @@
|
|
|
7963
7977
|
// <- TODO: [ð§ą] Implement in a functional (not new Class) way
|
|
7964
7978
|
function (resolve, reject) {
|
|
7965
7979
|
var socket = socket_ioClient.io(_this.options.remoteUrl, {
|
|
7980
|
+
retries: CONNECTION_RETRIES_LIMIT,
|
|
7981
|
+
timeout: CONNECTION_TIMEOUT_MS,
|
|
7966
7982
|
path: _this.options.path,
|
|
7967
7983
|
// path: `${this.remoteUrl.pathname}/socket.io`,
|
|
7968
7984
|
transports: [/*'websocket', <- TODO: [ðŽ] Make websocket transport work */ 'polling'],
|
|
@@ -7974,7 +7990,7 @@
|
|
|
7974
7990
|
// TODO: !!!! Better timeout handling
|
|
7975
7991
|
setTimeout(function () {
|
|
7976
7992
|
reject(new Error("Timeout while connecting to ".concat(_this.options.remoteUrl)));
|
|
7977
|
-
},
|
|
7993
|
+
}, CONNECTION_TIMEOUT_MS);
|
|
7978
7994
|
});
|
|
7979
7995
|
};
|
|
7980
7996
|
/**
|
|
@@ -8019,6 +8035,7 @@
|
|
|
8019
8035
|
if (this.options.isAnonymous) {
|
|
8020
8036
|
socket.emit('prompt-request', {
|
|
8021
8037
|
isAnonymous: true,
|
|
8038
|
+
userId: this.options.userId,
|
|
8022
8039
|
llmToolsConfiguration: this.options.llmToolsConfiguration,
|
|
8023
8040
|
prompt: prompt,
|
|
8024
8041
|
} /* <- TODO: [ðĪ] */);
|
|
@@ -8026,7 +8043,7 @@
|
|
|
8026
8043
|
else {
|
|
8027
8044
|
socket.emit('prompt-request', {
|
|
8028
8045
|
isAnonymous: false,
|
|
8029
|
-
|
|
8046
|
+
userId: this.options.userId,
|
|
8030
8047
|
prompt: prompt,
|
|
8031
8048
|
} /* <- TODO: [ðĪ] */);
|
|
8032
8049
|
}
|