@promptbook/wizard 0.104.0-1 โ 0.104.0-10
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 +240 -87
- 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 +10 -2
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +6 -6
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.closed.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -3
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
- package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +21 -11
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +80 -14
- package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/types/Message.d.ts +49 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
- package/esm/typings/src/types/typeAliases.d.ts +23 -1
- package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +246 -93
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-10';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
* Core Promptbook server configuration.
|
|
59
59
|
*
|
|
60
60
|
* This server is also used for auto-federation in the Agents Server.
|
|
61
|
+
*
|
|
62
|
+
* @public exported from `@promptbook/core`
|
|
61
63
|
*/
|
|
62
64
|
const CORE_SERVER = {
|
|
63
65
|
title: 'Promptbook Core',
|
|
@@ -2538,6 +2540,7 @@
|
|
|
2538
2540
|
}
|
|
2539
2541
|
}
|
|
2540
2542
|
/**
|
|
2543
|
+
* TODO: !!!! Deprecate pipeline server and all of its components
|
|
2541
2544
|
* TODO: Maybe use `$exportJson`
|
|
2542
2545
|
* TODO: [๐ง ][๐] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
2543
2546
|
* TODO: [๐] Allow to list compatible models with each variant
|
|
@@ -4711,13 +4714,15 @@
|
|
|
4711
4714
|
*
|
|
4712
4715
|
* @public exported from `@promptbook/utils`
|
|
4713
4716
|
*/
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4717
|
+
function $isRunningInJest() {
|
|
4718
|
+
var _a;
|
|
4719
|
+
try {
|
|
4720
|
+
return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
|
|
4721
|
+
}
|
|
4722
|
+
catch (e) {
|
|
4723
|
+
return false;
|
|
4724
|
+
}
|
|
4719
4725
|
}
|
|
4720
|
-
`);
|
|
4721
4726
|
/**
|
|
4722
4727
|
* TODO: [๐บ]
|
|
4723
4728
|
*/
|
|
@@ -5577,13 +5582,14 @@
|
|
|
5577
5582
|
*
|
|
5578
5583
|
* @public exported from `@promptbook/utils`
|
|
5579
5584
|
*/
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
+
function $isRunningInBrowser() {
|
|
5586
|
+
try {
|
|
5587
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
5588
|
+
}
|
|
5589
|
+
catch (e) {
|
|
5590
|
+
return false;
|
|
5591
|
+
}
|
|
5585
5592
|
}
|
|
5586
|
-
`);
|
|
5587
5593
|
/**
|
|
5588
5594
|
* TODO: [๐บ]
|
|
5589
5595
|
*/
|
|
@@ -5595,17 +5601,17 @@
|
|
|
5595
5601
|
*
|
|
5596
5602
|
* @public exported from `@promptbook/utils`
|
|
5597
5603
|
*/
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5604
|
+
function $isRunningInWebWorker() {
|
|
5605
|
+
try {
|
|
5606
|
+
// Note: Check for importScripts which is specific to workers
|
|
5607
|
+
// and not available in the main browser thread
|
|
5608
|
+
return (typeof self !== 'undefined' &&
|
|
5609
|
+
typeof self.importScripts === 'function');
|
|
5610
|
+
}
|
|
5611
|
+
catch (e) {
|
|
5603
5612
|
return false;
|
|
5604
5613
|
}
|
|
5605
|
-
} catch (e) {
|
|
5606
|
-
return false;
|
|
5607
5614
|
}
|
|
5608
|
-
`);
|
|
5609
5615
|
/**
|
|
5610
5616
|
* TODO: [๐บ]
|
|
5611
5617
|
*/
|
|
@@ -5837,7 +5843,7 @@
|
|
|
5837
5843
|
let threadMessages = [];
|
|
5838
5844
|
if ('thread' in prompt && Array.isArray(prompt.thread)) {
|
|
5839
5845
|
threadMessages = prompt.thread.map((msg) => ({
|
|
5840
|
-
role: msg.
|
|
5846
|
+
role: msg.sender === 'assistant' ? 'assistant' : 'user',
|
|
5841
5847
|
content: msg.content,
|
|
5842
5848
|
}));
|
|
5843
5849
|
}
|
|
@@ -6250,13 +6256,14 @@
|
|
|
6250
6256
|
const modelName = currentModelRequirements.modelName || this.getDefaultImageGenerationModel().modelName;
|
|
6251
6257
|
const modelSettings = {
|
|
6252
6258
|
model: modelName,
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6259
|
+
size: currentModelRequirements.size,
|
|
6260
|
+
quality: currentModelRequirements.quality,
|
|
6261
|
+
style: currentModelRequirements.style,
|
|
6256
6262
|
};
|
|
6257
6263
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
6258
6264
|
const rawRequest = {
|
|
6259
6265
|
...modelSettings,
|
|
6266
|
+
size: modelSettings.size || '1024x1024',
|
|
6260
6267
|
prompt: rawPromptContent,
|
|
6261
6268
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
6262
6269
|
response_format: 'url', // TODO: [๐ง ] Maybe allow b64_json
|
|
@@ -6793,10 +6800,10 @@
|
|
|
6793
6800
|
// <- TODO: [๐]
|
|
6794
6801
|
}
|
|
6795
6802
|
/**
|
|
6796
|
-
* Default model for
|
|
6803
|
+
* Default model for completion variant.
|
|
6797
6804
|
*/
|
|
6798
6805
|
getDefaultImageGenerationModel() {
|
|
6799
|
-
return this.getDefaultModel('
|
|
6806
|
+
return this.getDefaultModel('dall-e-3');
|
|
6800
6807
|
// <- TODO: [๐]
|
|
6801
6808
|
}
|
|
6802
6809
|
}
|
|
@@ -7611,11 +7618,10 @@
|
|
|
7611
7618
|
throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
|
|
7612
7619
|
}
|
|
7613
7620
|
/**
|
|
7614
|
-
* Default model for
|
|
7621
|
+
* Default model for completion variant.
|
|
7615
7622
|
*/
|
|
7616
7623
|
getDefaultImageGenerationModel() {
|
|
7617
|
-
|
|
7618
|
-
// <- TODO: [๐]
|
|
7624
|
+
throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
|
|
7619
7625
|
}
|
|
7620
7626
|
}
|
|
7621
7627
|
/**
|
|
@@ -7707,13 +7713,14 @@
|
|
|
7707
7713
|
*
|
|
7708
7714
|
* @public exported from `@promptbook/utils`
|
|
7709
7715
|
*/
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7716
|
+
function $isRunningInNode() {
|
|
7717
|
+
try {
|
|
7718
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
7719
|
+
}
|
|
7720
|
+
catch (e) {
|
|
7721
|
+
return false;
|
|
7722
|
+
}
|
|
7715
7723
|
}
|
|
7716
|
-
`);
|
|
7717
7724
|
/**
|
|
7718
7725
|
* TODO: [๐บ]
|
|
7719
7726
|
*/
|
|
@@ -9426,6 +9433,15 @@
|
|
|
9426
9433
|
return promptResult;
|
|
9427
9434
|
};
|
|
9428
9435
|
}
|
|
9436
|
+
if (llmTools.callImageGenerationModel !== undefined) {
|
|
9437
|
+
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
9438
|
+
// console.info('[๐] callImageGenerationModel through countTotalUsage');
|
|
9439
|
+
const promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
9440
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
9441
|
+
spending.next(promptResult.usage);
|
|
9442
|
+
return promptResult;
|
|
9443
|
+
};
|
|
9444
|
+
}
|
|
9429
9445
|
// <- Note: [๐ค]
|
|
9430
9446
|
return proxyTools;
|
|
9431
9447
|
}
|
|
@@ -9535,6 +9551,12 @@
|
|
|
9535
9551
|
callEmbeddingModel(prompt) {
|
|
9536
9552
|
return this.callCommonModel(prompt);
|
|
9537
9553
|
}
|
|
9554
|
+
/**
|
|
9555
|
+
* Calls the best available embedding model
|
|
9556
|
+
*/
|
|
9557
|
+
callImageGenerationModel(prompt) {
|
|
9558
|
+
return this.callCommonModel(prompt);
|
|
9559
|
+
}
|
|
9538
9560
|
// <- Note: [๐ค]
|
|
9539
9561
|
/**
|
|
9540
9562
|
* Calls the best available model
|
|
@@ -9561,6 +9583,11 @@
|
|
|
9561
9583
|
continue llm;
|
|
9562
9584
|
}
|
|
9563
9585
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
9586
|
+
case 'IMAGE_GENERATION':
|
|
9587
|
+
if (llmExecutionTools.callImageGenerationModel === undefined) {
|
|
9588
|
+
continue llm;
|
|
9589
|
+
}
|
|
9590
|
+
return await llmExecutionTools.callImageGenerationModel(prompt);
|
|
9564
9591
|
// <- case [๐ค]:
|
|
9565
9592
|
default:
|
|
9566
9593
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
|
@@ -11264,8 +11291,9 @@
|
|
|
11264
11291
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
11265
11292
|
break variant;
|
|
11266
11293
|
case 'EMBEDDING':
|
|
11294
|
+
case 'IMAGE_GENERATION':
|
|
11267
11295
|
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
11268
|
-
|
|
11296
|
+
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
11269
11297
|
|
|
11270
11298
|
This should be catched during parsing
|
|
11271
11299
|
|
|
@@ -14133,6 +14161,114 @@
|
|
|
14133
14161
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
14134
14162
|
*/
|
|
14135
14163
|
|
|
14164
|
+
/**
|
|
14165
|
+
* DICTIONARY commitment definition
|
|
14166
|
+
*
|
|
14167
|
+
* The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
|
|
14168
|
+
* in its reasoning and responses. This ensures consistent terminology usage.
|
|
14169
|
+
*
|
|
14170
|
+
* Key features:
|
|
14171
|
+
* - Multiple DICTIONARY commitments are automatically merged into one
|
|
14172
|
+
* - Content is placed in a dedicated section of the system message
|
|
14173
|
+
* - Terms and definitions are stored in metadata.DICTIONARY for debugging
|
|
14174
|
+
* - Agent should use the defined terms correctly in responses
|
|
14175
|
+
*
|
|
14176
|
+
* Example usage in agent source:
|
|
14177
|
+
*
|
|
14178
|
+
* ```book
|
|
14179
|
+
* Legal Assistant
|
|
14180
|
+
*
|
|
14181
|
+
* PERSONA You are a knowledgeable legal assistant
|
|
14182
|
+
* DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
|
|
14183
|
+
* DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
|
|
14184
|
+
* DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
|
|
14185
|
+
* ```
|
|
14186
|
+
*
|
|
14187
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
14188
|
+
*/
|
|
14189
|
+
class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
14190
|
+
constructor() {
|
|
14191
|
+
super('DICTIONARY');
|
|
14192
|
+
}
|
|
14193
|
+
/**
|
|
14194
|
+
* Short one-line description of DICTIONARY.
|
|
14195
|
+
*/
|
|
14196
|
+
get description() {
|
|
14197
|
+
return 'Define terms and their meanings for consistent terminology usage.';
|
|
14198
|
+
}
|
|
14199
|
+
/**
|
|
14200
|
+
* Icon for this commitment.
|
|
14201
|
+
*/
|
|
14202
|
+
get icon() {
|
|
14203
|
+
return '๐';
|
|
14204
|
+
}
|
|
14205
|
+
/**
|
|
14206
|
+
* Markdown documentation for DICTIONARY commitment.
|
|
14207
|
+
*/
|
|
14208
|
+
get documentation() {
|
|
14209
|
+
return spaceTrim$1.spaceTrim(`
|
|
14210
|
+
# DICTIONARY
|
|
14211
|
+
|
|
14212
|
+
Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
|
|
14213
|
+
|
|
14214
|
+
## Key aspects
|
|
14215
|
+
|
|
14216
|
+
- Multiple \`DICTIONARY\` commitments are merged together.
|
|
14217
|
+
- Terms are defined in the format: "Term is definition"
|
|
14218
|
+
- The agent should use these terms consistently in responses.
|
|
14219
|
+
- Definitions help ensure accurate and consistent terminology.
|
|
14220
|
+
|
|
14221
|
+
## Examples
|
|
14222
|
+
|
|
14223
|
+
\`\`\`book
|
|
14224
|
+
Legal Assistant
|
|
14225
|
+
|
|
14226
|
+
PERSONA You are a knowledgeable legal assistant specializing in criminal law
|
|
14227
|
+
DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
|
|
14228
|
+
DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
|
|
14229
|
+
DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
|
|
14230
|
+
\`\`\`
|
|
14231
|
+
|
|
14232
|
+
\`\`\`book
|
|
14233
|
+
Medical Assistant
|
|
14234
|
+
|
|
14235
|
+
PERSONA You are a helpful medical assistant
|
|
14236
|
+
DICTIONARY Hypertension is persistently high blood pressure
|
|
14237
|
+
DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
|
|
14238
|
+
DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
|
|
14239
|
+
\`\`\`
|
|
14240
|
+
`);
|
|
14241
|
+
}
|
|
14242
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
14243
|
+
var _a;
|
|
14244
|
+
const trimmedContent = content.trim();
|
|
14245
|
+
if (!trimmedContent) {
|
|
14246
|
+
return requirements;
|
|
14247
|
+
}
|
|
14248
|
+
// Get existing dictionary entries from metadata
|
|
14249
|
+
const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
14250
|
+
// Merge the new dictionary entry with existing entries
|
|
14251
|
+
const mergedDictionary = existingDictionary
|
|
14252
|
+
? `${existingDictionary}\n${trimmedContent}`
|
|
14253
|
+
: trimmedContent;
|
|
14254
|
+
// Store the merged dictionary in metadata for debugging and inspection
|
|
14255
|
+
const updatedMetadata = {
|
|
14256
|
+
...requirements.metadata,
|
|
14257
|
+
DICTIONARY: mergedDictionary,
|
|
14258
|
+
};
|
|
14259
|
+
// Create the dictionary section for the system message
|
|
14260
|
+
// Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
|
|
14261
|
+
const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
|
|
14262
|
+
return {
|
|
14263
|
+
...this.appendToSystemMessage(requirements, dictionarySection),
|
|
14264
|
+
metadata: updatedMetadata,
|
|
14265
|
+
};
|
|
14266
|
+
}
|
|
14267
|
+
}
|
|
14268
|
+
/**
|
|
14269
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
14270
|
+
*/
|
|
14271
|
+
|
|
14136
14272
|
/**
|
|
14137
14273
|
* FORMAT commitment definition
|
|
14138
14274
|
*
|
|
@@ -16953,6 +17089,7 @@
|
|
|
16953
17089
|
new DeleteCommitmentDefinition('CANCEL'),
|
|
16954
17090
|
new DeleteCommitmentDefinition('DISCARD'),
|
|
16955
17091
|
new DeleteCommitmentDefinition('REMOVE'),
|
|
17092
|
+
new DictionaryCommitmentDefinition(),
|
|
16956
17093
|
new OpenCommitmentDefinition(),
|
|
16957
17094
|
new ClosedCommitmentDefinition(),
|
|
16958
17095
|
new UseBrowserCommitmentDefinition(),
|
|
@@ -17037,17 +17174,64 @@
|
|
|
17037
17174
|
};
|
|
17038
17175
|
}
|
|
17039
17176
|
const lines = agentSource.split('\n');
|
|
17040
|
-
|
|
17177
|
+
let agentName = null;
|
|
17178
|
+
let agentNameLineIndex = -1;
|
|
17179
|
+
// Find the agent name: first non-empty line that is not a commitment and not a horizontal line
|
|
17180
|
+
for (let i = 0; i < lines.length; i++) {
|
|
17181
|
+
const line = lines[i];
|
|
17182
|
+
if (line === undefined) {
|
|
17183
|
+
continue;
|
|
17184
|
+
}
|
|
17185
|
+
const trimmed = line.trim();
|
|
17186
|
+
if (!trimmed) {
|
|
17187
|
+
continue;
|
|
17188
|
+
}
|
|
17189
|
+
const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
|
|
17190
|
+
if (isHorizontal) {
|
|
17191
|
+
continue;
|
|
17192
|
+
}
|
|
17193
|
+
let isCommitment = false;
|
|
17194
|
+
for (const definition of COMMITMENT_REGISTRY) {
|
|
17195
|
+
const typeRegex = definition.createTypeRegex();
|
|
17196
|
+
const match = typeRegex.exec(trimmed);
|
|
17197
|
+
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
17198
|
+
isCommitment = true;
|
|
17199
|
+
break;
|
|
17200
|
+
}
|
|
17201
|
+
}
|
|
17202
|
+
if (!isCommitment) {
|
|
17203
|
+
agentName = trimmed;
|
|
17204
|
+
agentNameLineIndex = i;
|
|
17205
|
+
break;
|
|
17206
|
+
}
|
|
17207
|
+
}
|
|
17041
17208
|
const commitments = [];
|
|
17042
17209
|
const nonCommitmentLines = [];
|
|
17043
|
-
//
|
|
17044
|
-
|
|
17045
|
-
|
|
17210
|
+
// Add lines before agentName that are horizontal lines (they are non-commitment)
|
|
17211
|
+
for (let i = 0; i < agentNameLineIndex; i++) {
|
|
17212
|
+
const line = lines[i];
|
|
17213
|
+
if (line === undefined) {
|
|
17214
|
+
continue;
|
|
17215
|
+
}
|
|
17216
|
+
const trimmed = line.trim();
|
|
17217
|
+
if (!trimmed) {
|
|
17218
|
+
continue;
|
|
17219
|
+
}
|
|
17220
|
+
const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
|
|
17221
|
+
if (isHorizontal) {
|
|
17222
|
+
nonCommitmentLines.push(line);
|
|
17223
|
+
}
|
|
17224
|
+
// Note: Commitments before agentName are not added to nonCommitmentLines
|
|
17225
|
+
}
|
|
17226
|
+
// Add the agent name line to non-commitment lines
|
|
17227
|
+
if (agentNameLineIndex >= 0) {
|
|
17228
|
+
nonCommitmentLines.push(lines[agentNameLineIndex]);
|
|
17046
17229
|
}
|
|
17047
17230
|
// Parse commitments with multiline support
|
|
17048
17231
|
let currentCommitment = null;
|
|
17049
|
-
// Process lines starting from the
|
|
17050
|
-
|
|
17232
|
+
// Process lines starting from after the agent name line
|
|
17233
|
+
const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
|
|
17234
|
+
for (let i = startIndex; i < lines.length; i++) {
|
|
17051
17235
|
const line = lines[i];
|
|
17052
17236
|
if (line === undefined) {
|
|
17053
17237
|
continue;
|
|
@@ -17267,7 +17451,12 @@
|
|
|
17267
17451
|
};
|
|
17268
17452
|
}
|
|
17269
17453
|
// Apply each commitment in order using reduce-like pattern
|
|
17270
|
-
for (
|
|
17454
|
+
for (let i = 0; i < filteredCommitments.length; i++) {
|
|
17455
|
+
const commitment = filteredCommitments[i];
|
|
17456
|
+
// CLOSED commitment should work only if its the last commitment in the book
|
|
17457
|
+
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
17458
|
+
continue;
|
|
17459
|
+
}
|
|
17271
17460
|
const definition = getCommitmentDefinition(commitment.type);
|
|
17272
17461
|
if (definition) {
|
|
17273
17462
|
try {
|
|
@@ -17362,44 +17551,6 @@
|
|
|
17362
17551
|
* TODO: [๐บ] Use some intermediate util splitWords
|
|
17363
17552
|
*/
|
|
17364
17553
|
|
|
17365
|
-
/**
|
|
17366
|
-
* Generates a gravatar URL based on agent name for fallback avatar
|
|
17367
|
-
*
|
|
17368
|
-
* @param agentName The agent name to generate avatar for
|
|
17369
|
-
* @returns Gravatar URL
|
|
17370
|
-
*
|
|
17371
|
-
* @private - [๐คน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
|
|
17372
|
-
*/
|
|
17373
|
-
function generateGravatarUrl(agentName) {
|
|
17374
|
-
// Use a default name if none provided
|
|
17375
|
-
const safeName = agentName || 'Anonymous Agent';
|
|
17376
|
-
// Create a simple hash from the name for consistent avatar
|
|
17377
|
-
let hash = 0;
|
|
17378
|
-
for (let i = 0; i < safeName.length; i++) {
|
|
17379
|
-
const char = safeName.charCodeAt(i);
|
|
17380
|
-
hash = (hash << 5) - hash + char;
|
|
17381
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
17382
|
-
}
|
|
17383
|
-
const avatarId = Math.abs(hash).toString();
|
|
17384
|
-
return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
|
|
17385
|
-
}
|
|
17386
|
-
|
|
17387
|
-
/**
|
|
17388
|
-
* Generates an image for the agent to use as profile image
|
|
17389
|
-
*
|
|
17390
|
-
* @param agentName The agent name to generate avatar for
|
|
17391
|
-
* @returns The placeholder profile image URL for the agent
|
|
17392
|
-
*
|
|
17393
|
-
* @public exported from `@promptbook/core`
|
|
17394
|
-
*/
|
|
17395
|
-
function generatePlaceholderAgentProfileImageUrl(agentName) {
|
|
17396
|
-
// Note: [๐คน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
|
|
17397
|
-
return generateGravatarUrl(agentName);
|
|
17398
|
-
}
|
|
17399
|
-
/**
|
|
17400
|
-
* TODO: [๐คน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
|
|
17401
|
-
*/
|
|
17402
|
-
|
|
17403
17554
|
/**
|
|
17404
17555
|
* Computes SHA-256 hash of the given object
|
|
17405
17556
|
*
|
|
@@ -17824,10 +17975,6 @@
|
|
|
17824
17975
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
17825
17976
|
meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
|
|
17826
17977
|
}
|
|
17827
|
-
// Generate gravatar fallback if no meta image specified
|
|
17828
|
-
if (!meta.image) {
|
|
17829
|
-
meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
|
|
17830
|
-
}
|
|
17831
17978
|
// Generate fullname fallback if no meta fullname specified
|
|
17832
17979
|
if (!meta.fullname) {
|
|
17833
17980
|
meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
@@ -17839,6 +17986,7 @@
|
|
|
17839
17986
|
return {
|
|
17840
17987
|
agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
|
|
17841
17988
|
agentHash,
|
|
17989
|
+
permanentId: meta.id,
|
|
17842
17990
|
personaDescription,
|
|
17843
17991
|
initialMessage,
|
|
17844
17992
|
meta,
|
|
@@ -18564,7 +18712,7 @@
|
|
|
18564
18712
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
18565
18713
|
${morePieces.join('; ')}
|
|
18566
18714
|
`);
|
|
18567
|
-
if ($isRunningInNode) {
|
|
18715
|
+
if ($isRunningInNode()) {
|
|
18568
18716
|
if (isInstalled && isFullyConfigured) {
|
|
18569
18717
|
providerMessage = colors__default["default"].green(providerMessage);
|
|
18570
18718
|
}
|
|
@@ -18961,6 +19109,9 @@
|
|
|
18961
19109
|
case 'EMBEDDING':
|
|
18962
19110
|
promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
18963
19111
|
break variant;
|
|
19112
|
+
case 'IMAGE_GENERATION':
|
|
19113
|
+
promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
19114
|
+
break variant;
|
|
18964
19115
|
// <- case [๐ค]:
|
|
18965
19116
|
default:
|
|
18966
19117
|
throw new PipelineExecutionError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -18997,12 +19148,13 @@
|
|
|
18997
19148
|
}
|
|
18998
19149
|
}
|
|
18999
19150
|
catch (error) {
|
|
19151
|
+
assertsError(error);
|
|
19000
19152
|
// If validation throws an unexpected error, don't cache
|
|
19001
19153
|
shouldCache = false;
|
|
19002
19154
|
if (isVerbose) {
|
|
19003
19155
|
console.info('Not caching result due to validation error for key:', key, {
|
|
19004
19156
|
content: promptResult.content,
|
|
19005
|
-
validationError:
|
|
19157
|
+
validationError: serializeError(error),
|
|
19006
19158
|
});
|
|
19007
19159
|
}
|
|
19008
19160
|
}
|
|
@@ -19048,6 +19200,11 @@
|
|
|
19048
19200
|
return /* not await */ callCommonModel(prompt);
|
|
19049
19201
|
};
|
|
19050
19202
|
}
|
|
19203
|
+
if (llmTools.callImageGenerationModel !== undefined) {
|
|
19204
|
+
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
19205
|
+
return /* not await */ callCommonModel(prompt);
|
|
19206
|
+
};
|
|
19207
|
+
}
|
|
19051
19208
|
// <- Note: [๐ค]
|
|
19052
19209
|
return proxyTools;
|
|
19053
19210
|
}
|
|
@@ -21177,11 +21334,7 @@
|
|
|
21177
21334
|
// TODO: [๐] DRY
|
|
21178
21335
|
if ($taskJson.modelRequirements[command.key] !== undefined) {
|
|
21179
21336
|
if ($taskJson.modelRequirements[command.key] === command.value) {
|
|
21180
|
-
console.warn(`Multiple commands \`MODEL ${{
|
|
21181
|
-
modelName: 'NAME',
|
|
21182
|
-
modelVariant: 'VARIANT',
|
|
21183
|
-
maxTokens: '???',
|
|
21184
|
-
}[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
|
|
21337
|
+
console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
|
|
21185
21338
|
// <- TODO: [๐ฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
21186
21339
|
}
|
|
21187
21340
|
else {
|