@promptbook/core 0.104.0-5 โ 0.104.0-7
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 +24 -52
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +8 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +6 -6
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -3
- package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
- package/esm/typings/src/types/typeAliases.d.ts +11 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +24 -51
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
package/esm/typings/servers.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ type ServerConfiguration = {
|
|
|
22
22
|
*/
|
|
23
23
|
urls: Array<string_promptbook_server_url>;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Core Promptbook server configuration.
|
|
27
|
+
*
|
|
28
|
+
* This server is also used for auto-federation in the Agents Server.
|
|
29
|
+
*
|
|
30
|
+
* @public exported from `@promptbook/core`
|
|
31
|
+
*/
|
|
32
|
+
export declare const CORE_SERVER: ServerConfiguration;
|
|
25
33
|
/**
|
|
26
34
|
* Available remote servers for the Promptbook
|
|
27
35
|
*
|
|
@@ -191,6 +191,7 @@ import { SectionTypes } from '../types/SectionType';
|
|
|
191
191
|
import { TaskTypes } from '../types/TaskType';
|
|
192
192
|
import { aboutPromptbookInformation } from '../utils/misc/aboutPromptbookInformation';
|
|
193
193
|
import { $generateBookBoilerplate } from '../utils/random/$generateBookBoilerplate';
|
|
194
|
+
import { CORE_SERVER } from '../../servers';
|
|
194
195
|
import { REMOTE_SERVER_URLS } from '../../servers';
|
|
195
196
|
import { AUTO_FEDERATED_AGENT_SERVER_URLS } from '../../servers';
|
|
196
197
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
@@ -386,5 +387,6 @@ export { SectionTypes };
|
|
|
386
387
|
export { TaskTypes };
|
|
387
388
|
export { aboutPromptbookInformation };
|
|
388
389
|
export { $generateBookBoilerplate };
|
|
390
|
+
export { CORE_SERVER };
|
|
389
391
|
export { REMOTE_SERVER_URLS };
|
|
390
392
|
export { AUTO_FEDERATED_AGENT_SERVER_URLS };
|
|
@@ -206,6 +206,7 @@ import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
|
206
206
|
import type { string_business_category_name } from '../types/typeAliases';
|
|
207
207
|
import type { string_model_name } from '../types/typeAliases';
|
|
208
208
|
import type { string_prompt } from '../types/typeAliases';
|
|
209
|
+
import type { string_prompt_image } from '../types/typeAliases';
|
|
209
210
|
import type { string_template } from '../types/typeAliases';
|
|
210
211
|
import type { string_text_prompt } from '../types/typeAliases';
|
|
211
212
|
import type { string_chat_prompt } from '../types/typeAliases';
|
|
@@ -573,6 +574,7 @@ export type { string_char_emoji };
|
|
|
573
574
|
export type { string_business_category_name };
|
|
574
575
|
export type { string_model_name };
|
|
575
576
|
export type { string_prompt };
|
|
577
|
+
export type { string_prompt_image };
|
|
576
578
|
export type { string_template };
|
|
577
579
|
export type { string_text_prompt };
|
|
578
580
|
export type { string_chat_prompt };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
|
-
import type { string_model_name } from '../../types/typeAliases';
|
|
3
|
+
import type { string_agent_name, string_model_name, string_system_message, string_url_image } from '../../types/typeAliases';
|
|
4
4
|
import type { AgentModelRequirements } from './AgentModelRequirements';
|
|
5
5
|
import type { string_book } from './string_book';
|
|
6
6
|
/**
|
|
@@ -27,18 +27,18 @@ export declare function extractMcpServers(agentSource: string_book): string[];
|
|
|
27
27
|
* @deprecated Use createAgentModelRequirements instead
|
|
28
28
|
* @private
|
|
29
29
|
*/
|
|
30
|
-
export declare function createAgentSystemMessage(agentSource: string_book): Promise<
|
|
30
|
+
export declare function createAgentSystemMessage(agentSource: string_book): Promise<string_system_message>;
|
|
31
31
|
/**
|
|
32
32
|
* Extracts the agent name from the first line of the agent source
|
|
33
33
|
* @deprecated Use parseAgentSource instead
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
|
-
export declare function extractAgentName(agentSource: string_book):
|
|
36
|
+
export declare function extractAgentName(agentSource: string_book): string_agent_name;
|
|
37
37
|
/**
|
|
38
|
-
* Extracts the profile image URL from agent source or returns
|
|
38
|
+
* Extracts the profile image URL from agent source or returns default avatar fallback
|
|
39
39
|
* @param agentSource The agent source string that may contain META IMAGE line
|
|
40
|
-
* @returns Profile image URL (from source or
|
|
40
|
+
* @returns Profile image URL (from source or default avatar fallback)
|
|
41
41
|
* @deprecated Use parseAgentSource instead
|
|
42
42
|
* @private
|
|
43
43
|
*/
|
|
44
|
-
export declare function extractAgentProfileImage(agentSource: string_book):
|
|
44
|
+
export declare function extractAgentProfileImage(agentSource: string_book): string_url_image | null;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { string_agent_name, string_url_image } from '../../types/typeAliases';
|
|
1
|
+
import type { string_agent_name, string_agent_permanent_id, string_url_image } from '../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Generates an image for the agent to use as profile image
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param agentId - The permanent ID of the agent
|
|
6
6
|
* @returns The placeholder profile image URL for the agent
|
|
7
7
|
*
|
|
8
8
|
* @public exported from `@promptbook/core`
|
|
9
9
|
*/
|
|
10
|
-
export declare function generatePlaceholderAgentProfileImageUrl(
|
|
10
|
+
export declare function generatePlaceholderAgentProfileImageUrl(agentIdOrName: string_agent_permanent_id | string_agent_name, agentsServerUrl?: URL): string_url_image;
|
|
11
11
|
/**
|
|
12
12
|
* TODO: [๐คน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
|
|
13
13
|
*/
|
|
@@ -17,7 +17,17 @@ export type CompletionModelRequirements = CommonModelRequirements & {
|
|
|
17
17
|
/**
|
|
18
18
|
* Completion model variant
|
|
19
19
|
*/
|
|
20
|
-
modelVariant: 'COMPLETION';
|
|
20
|
+
readonly modelVariant: 'COMPLETION';
|
|
21
|
+
/**
|
|
22
|
+
* The temperature of the model
|
|
23
|
+
*
|
|
24
|
+
* Note: [๐ฑ] Promptbook is using just `temperature` (not `top_k` and `top_p`)
|
|
25
|
+
*/
|
|
26
|
+
readonly temperature?: number_model_temperature;
|
|
27
|
+
/**
|
|
28
|
+
* Maximum number of tokens that can be generated by the model
|
|
29
|
+
*/
|
|
30
|
+
readonly maxTokens?: number;
|
|
21
31
|
};
|
|
22
32
|
/**
|
|
23
33
|
* Model requirements for the chat variant
|
|
@@ -28,11 +38,21 @@ export type ChatModelRequirements = CommonModelRequirements & {
|
|
|
28
38
|
/**
|
|
29
39
|
* Chat model variant
|
|
30
40
|
*/
|
|
31
|
-
modelVariant: 'CHAT';
|
|
41
|
+
readonly modelVariant: 'CHAT';
|
|
32
42
|
/**
|
|
33
43
|
* System message to be used in the model
|
|
34
44
|
*/
|
|
35
45
|
readonly systemMessage?: string_system_message;
|
|
46
|
+
/**
|
|
47
|
+
* The temperature of the model
|
|
48
|
+
*
|
|
49
|
+
* Note: [๐ฑ] Promptbook is using just `temperature` (not `top_k` and `top_p`)
|
|
50
|
+
*/
|
|
51
|
+
readonly temperature?: number_model_temperature;
|
|
52
|
+
/**
|
|
53
|
+
* Maximum number of tokens that can be generated by the model
|
|
54
|
+
*/
|
|
55
|
+
readonly maxTokens?: number;
|
|
36
56
|
};
|
|
37
57
|
/**
|
|
38
58
|
* Model requirements for the image generation variant
|
|
@@ -43,7 +63,21 @@ export type ImageGenerationModelRequirements = CommonModelRequirements & {
|
|
|
43
63
|
/**
|
|
44
64
|
* Image generation model variant
|
|
45
65
|
*/
|
|
46
|
-
modelVariant: 'IMAGE_GENERATION';
|
|
66
|
+
readonly modelVariant: 'IMAGE_GENERATION';
|
|
67
|
+
/**
|
|
68
|
+
* Size of the generated image
|
|
69
|
+
*
|
|
70
|
+
* e.g. '1536x1536'
|
|
71
|
+
*/
|
|
72
|
+
readonly size?: '1024x1024' | '1792x1024' | '1024x1792' | `${number}x${number}`;
|
|
73
|
+
/**
|
|
74
|
+
* Quality of the generated image
|
|
75
|
+
*/
|
|
76
|
+
readonly quality?: 'standard' | 'hd';
|
|
77
|
+
/**
|
|
78
|
+
* Style of the generated image
|
|
79
|
+
*/
|
|
80
|
+
readonly style?: 'vivid' | 'natural';
|
|
47
81
|
};
|
|
48
82
|
/**
|
|
49
83
|
* Model requirements for the embedding variant
|
|
@@ -54,7 +88,7 @@ export type EmbeddingModelRequirements = CommonModelRequirements & {
|
|
|
54
88
|
/**
|
|
55
89
|
* Embedding model variant
|
|
56
90
|
*/
|
|
57
|
-
modelVariant: 'EMBEDDING';
|
|
91
|
+
readonly modelVariant: 'EMBEDDING';
|
|
58
92
|
};
|
|
59
93
|
/**
|
|
60
94
|
* Common properties for all model requirements variants
|
|
@@ -84,20 +118,10 @@ export type CommonModelRequirements = {
|
|
|
84
118
|
* @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
|
|
85
119
|
*/
|
|
86
120
|
readonly modelName?: string_model_name;
|
|
87
|
-
/**
|
|
88
|
-
* The temperature of the model
|
|
89
|
-
*
|
|
90
|
-
* Note: [๐ฑ] Promptbook is using just `temperature` (not `top_k` and `top_p`)
|
|
91
|
-
*/
|
|
92
|
-
readonly temperature?: number_model_temperature;
|
|
93
121
|
/**
|
|
94
122
|
* Seed for the model
|
|
95
123
|
*/
|
|
96
124
|
readonly seed?: number_seed;
|
|
97
|
-
/**
|
|
98
|
-
* Maximum number of tokens that can be generated by the model
|
|
99
|
-
*/
|
|
100
|
-
readonly maxTokens?: number;
|
|
101
125
|
};
|
|
102
126
|
/**
|
|
103
127
|
* TODO: [๐ง ][๐] `seed` should maybe be somewhere else (not in `ModelRequirements`) (similar that `user` identification is not here)
|
|
@@ -14,9 +14,15 @@ export type string_model_name = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-3
|
|
|
14
14
|
/**
|
|
15
15
|
* Semantic helper
|
|
16
16
|
*
|
|
17
|
-
* For example `"
|
|
17
|
+
* For example `"How many eyes does a cat have?"`
|
|
18
18
|
*/
|
|
19
19
|
export type string_prompt = string;
|
|
20
|
+
/**
|
|
21
|
+
* Semantic helper
|
|
22
|
+
*
|
|
23
|
+
* For example `"A cat wearing a hat"`
|
|
24
|
+
*/
|
|
25
|
+
export type string_prompt_image = string;
|
|
20
26
|
/**
|
|
21
27
|
* Semantic helper
|
|
22
28
|
*
|
|
@@ -140,6 +146,8 @@ export type string_title = string;
|
|
|
140
146
|
* Semantic helper
|
|
141
147
|
*
|
|
142
148
|
* For example `"My AI Assistant"`
|
|
149
|
+
*
|
|
150
|
+
* TODO: !!!! Brand the type
|
|
143
151
|
*/
|
|
144
152
|
export type string_agent_name = string;
|
|
145
153
|
/**
|
|
@@ -158,6 +166,8 @@ export type string_agent_hash = string_sha256;
|
|
|
158
166
|
* Semantic helper
|
|
159
167
|
*
|
|
160
168
|
* For example `"3mJr7AoUXx2Wqd"`
|
|
169
|
+
*
|
|
170
|
+
* TODO: !!!! Brand the type
|
|
161
171
|
*/
|
|
162
172
|
export type string_agent_permanent_id = string_base_58;
|
|
163
173
|
/**
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.104.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.104.0-6`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-7';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
* Core Promptbook server configuration.
|
|
39
39
|
*
|
|
40
40
|
* This server is also used for auto-federation in the Agents Server.
|
|
41
|
+
*
|
|
42
|
+
* @public exported from `@promptbook/core`
|
|
41
43
|
*/
|
|
42
44
|
const CORE_SERVER = {
|
|
43
45
|
title: 'Promptbook Core',
|
|
@@ -11438,44 +11440,6 @@
|
|
|
11438
11440
|
* TODO: [๐บ] Use some intermediate util splitWords
|
|
11439
11441
|
*/
|
|
11440
11442
|
|
|
11441
|
-
/**
|
|
11442
|
-
* Generates a gravatar URL based on agent name for fallback avatar
|
|
11443
|
-
*
|
|
11444
|
-
* @param agentName The agent name to generate avatar for
|
|
11445
|
-
* @returns Gravatar URL
|
|
11446
|
-
*
|
|
11447
|
-
* @private - [๐คน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
|
|
11448
|
-
*/
|
|
11449
|
-
function generateGravatarUrl(agentName) {
|
|
11450
|
-
// Use a default name if none provided
|
|
11451
|
-
const safeName = agentName || 'Anonymous Agent';
|
|
11452
|
-
// Create a simple hash from the name for consistent avatar
|
|
11453
|
-
let hash = 0;
|
|
11454
|
-
for (let i = 0; i < safeName.length; i++) {
|
|
11455
|
-
const char = safeName.charCodeAt(i);
|
|
11456
|
-
hash = (hash << 5) - hash + char;
|
|
11457
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
11458
|
-
}
|
|
11459
|
-
const avatarId = Math.abs(hash).toString();
|
|
11460
|
-
return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
|
|
11461
|
-
}
|
|
11462
|
-
|
|
11463
|
-
/**
|
|
11464
|
-
* Generates an image for the agent to use as profile image
|
|
11465
|
-
*
|
|
11466
|
-
* @param agentName The agent name to generate avatar for
|
|
11467
|
-
* @returns The placeholder profile image URL for the agent
|
|
11468
|
-
*
|
|
11469
|
-
* @public exported from `@promptbook/core`
|
|
11470
|
-
*/
|
|
11471
|
-
function generatePlaceholderAgentProfileImageUrl(agentName) {
|
|
11472
|
-
// Note: [๐คน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
|
|
11473
|
-
return generateGravatarUrl(agentName);
|
|
11474
|
-
}
|
|
11475
|
-
/**
|
|
11476
|
-
* TODO: [๐คน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
|
|
11477
|
-
*/
|
|
11478
|
-
|
|
11479
11443
|
/**
|
|
11480
11444
|
* Creates a Mermaid graph based on the promptbook
|
|
11481
11445
|
*
|
|
@@ -11957,10 +11921,6 @@
|
|
|
11957
11921
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
11958
11922
|
meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
|
|
11959
11923
|
}
|
|
11960
|
-
// Generate gravatar fallback if no meta image specified
|
|
11961
|
-
if (!meta.image) {
|
|
11962
|
-
meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
|
|
11963
|
-
}
|
|
11964
11924
|
// Generate fullname fallback if no meta fullname specified
|
|
11965
11925
|
if (!meta.fullname) {
|
|
11966
11926
|
meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
@@ -12164,6 +12124,21 @@
|
|
|
12164
12124
|
// <- [๐ฑโ๐] Buttons into genesis book
|
|
12165
12125
|
// <- TODO: [๐ฑโ๐] generateBookBoilerplate and deprecate `DEFAULT_BOOK`
|
|
12166
12126
|
|
|
12127
|
+
/**
|
|
12128
|
+
* Generates an image for the agent to use as profile image
|
|
12129
|
+
*
|
|
12130
|
+
* @param agentId - The permanent ID of the agent
|
|
12131
|
+
* @returns The placeholder profile image URL for the agent
|
|
12132
|
+
*
|
|
12133
|
+
* @public exported from `@promptbook/core`
|
|
12134
|
+
*/
|
|
12135
|
+
function generatePlaceholderAgentProfileImageUrl(agentIdOrName, agentsServerUrl = new URL(CORE_SERVER.urls[0])) {
|
|
12136
|
+
return `${agentsServerUrl}agents/${agentIdOrName}/images/default-avatar.png`;
|
|
12137
|
+
}
|
|
12138
|
+
/**
|
|
12139
|
+
* TODO: [๐คน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
|
|
12140
|
+
*/
|
|
12141
|
+
|
|
12167
12142
|
/**
|
|
12168
12143
|
* Base58 characters
|
|
12169
12144
|
*/
|
|
@@ -14207,11 +14182,7 @@
|
|
|
14207
14182
|
// TODO: [๐] DRY
|
|
14208
14183
|
if ($taskJson.modelRequirements[command.key] !== undefined) {
|
|
14209
14184
|
if ($taskJson.modelRequirements[command.key] === command.value) {
|
|
14210
|
-
console.warn(`Multiple commands \`MODEL ${{
|
|
14211
|
-
modelName: 'NAME',
|
|
14212
|
-
modelVariant: 'VARIANT',
|
|
14213
|
-
maxTokens: '???',
|
|
14214
|
-
}[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
|
|
14185
|
+
console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
|
|
14215
14186
|
// <- TODO: [๐ฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
14216
14187
|
}
|
|
14217
14188
|
else {
|
|
@@ -18563,13 +18534,14 @@
|
|
|
18563
18534
|
const modelName = currentModelRequirements.modelName || this.getDefaultImageGenerationModel().modelName;
|
|
18564
18535
|
const modelSettings = {
|
|
18565
18536
|
model: modelName,
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18537
|
+
size: currentModelRequirements.size,
|
|
18538
|
+
quality: currentModelRequirements.quality,
|
|
18539
|
+
style: currentModelRequirements.style,
|
|
18569
18540
|
};
|
|
18570
18541
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
18571
18542
|
const rawRequest = {
|
|
18572
18543
|
...modelSettings,
|
|
18544
|
+
size: modelSettings.size || '1024x1024',
|
|
18573
18545
|
prompt: rawPromptContent,
|
|
18574
18546
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
18575
18547
|
response_format: 'url', // TODO: [๐ง ] Maybe allow b64_json
|
|
@@ -21468,6 +21440,7 @@
|
|
|
21468
21440
|
exports.BoilerplateFormfactorDefinition = BoilerplateFormfactorDefinition;
|
|
21469
21441
|
exports.CLAIM = CLAIM;
|
|
21470
21442
|
exports.CLI_APP_ID = CLI_APP_ID;
|
|
21443
|
+
exports.CORE_SERVER = CORE_SERVER;
|
|
21471
21444
|
exports.CallbackInterfaceTools = CallbackInterfaceTools;
|
|
21472
21445
|
exports.ChatbotFormfactorDefinition = ChatbotFormfactorDefinition;
|
|
21473
21446
|
exports.CollectionError = CollectionError;
|