@promptbook/remote-server 0.111.0-0 → 0.111.0-1
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 -73
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +6 -0
- package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +3 -12
- package/esm/typings/src/utils/knowledge/simplifyKnowledgeLabel.d.ts +20 -0
- package/esm/typings/src/utils/knowledge/simplifyKnowledgeLabel.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +24 -73
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-1';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -15449,8 +15449,8 @@ class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15449
15449
|
/**
|
|
15450
15450
|
* USE IMAGE GENERATOR commitment definition
|
|
15451
15451
|
*
|
|
15452
|
-
* The `USE IMAGE GENERATOR` commitment indicates that the agent
|
|
15453
|
-
*
|
|
15452
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent can output
|
|
15453
|
+
* markdown placeholders for UI-driven image generation.
|
|
15454
15454
|
*
|
|
15455
15455
|
* Example usage in agent source:
|
|
15456
15456
|
*
|
|
@@ -15465,11 +15465,14 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15465
15465
|
constructor(type = 'USE IMAGE GENERATOR') {
|
|
15466
15466
|
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
15467
15467
|
}
|
|
15468
|
+
get requiresContent() {
|
|
15469
|
+
return false;
|
|
15470
|
+
}
|
|
15468
15471
|
/**
|
|
15469
15472
|
* Short one-line description of USE IMAGE GENERATOR.
|
|
15470
15473
|
*/
|
|
15471
15474
|
get description() {
|
|
15472
|
-
return 'Enable the agent to
|
|
15475
|
+
return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
|
|
15473
15476
|
}
|
|
15474
15477
|
/**
|
|
15475
15478
|
* Icon for this commitment.
|
|
@@ -15484,21 +15487,21 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15484
15487
|
return spaceTrim$1(`
|
|
15485
15488
|
# USE IMAGE GENERATOR
|
|
15486
15489
|
|
|
15487
|
-
Enables the agent to
|
|
15490
|
+
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
15488
15491
|
|
|
15489
15492
|
## Key aspects
|
|
15490
15493
|
|
|
15491
15494
|
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
15492
|
-
- The
|
|
15493
|
-
-
|
|
15494
|
-
-
|
|
15495
|
+
- The agent does **not** call an image-generation tool directly.
|
|
15496
|
+
- The agent inserts markdown notation: \`\`.
|
|
15497
|
+
- The user interface detects the notation and generates the image asynchronously.
|
|
15495
15498
|
|
|
15496
15499
|
## Examples
|
|
15497
15500
|
|
|
15498
15501
|
\`\`\`book
|
|
15499
15502
|
Visual Artist
|
|
15500
15503
|
|
|
15501
|
-
PERSONA You are a creative visual artist
|
|
15504
|
+
PERSONA You are a creative visual artist.
|
|
15502
15505
|
USE IMAGE GENERATOR
|
|
15503
15506
|
RULE Always describe the generated image to the user.
|
|
15504
15507
|
\`\`\`
|
|
@@ -15508,80 +15511,28 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15508
15511
|
|
|
15509
15512
|
PERSONA You are an interior designer who helps users visualize their space.
|
|
15510
15513
|
USE IMAGE GENERATOR Professional interior design renders.
|
|
15511
|
-
ACTION
|
|
15514
|
+
ACTION Add one generated image placeholder whenever a user asks for a visual.
|
|
15512
15515
|
\`\`\`
|
|
15513
15516
|
`);
|
|
15514
15517
|
}
|
|
15515
15518
|
applyToAgentModelRequirements(requirements, content) {
|
|
15516
|
-
|
|
15517
|
-
const existingTools = requirements.tools || [];
|
|
15518
|
-
// Add 'generate_image' to tools if not already present
|
|
15519
|
-
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
15520
|
-
? existingTools
|
|
15521
|
-
: [
|
|
15522
|
-
...existingTools,
|
|
15523
|
-
{
|
|
15524
|
-
name: 'generate_image',
|
|
15525
|
-
description: spaceTrim$1(`
|
|
15526
|
-
Generate an image from a text prompt.
|
|
15527
|
-
Use this tool when the user asks to create, draw, or generate an image.
|
|
15528
|
-
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
15529
|
-
`),
|
|
15530
|
-
parameters: {
|
|
15531
|
-
type: 'object',
|
|
15532
|
-
properties: {
|
|
15533
|
-
prompt: {
|
|
15534
|
-
type: 'string',
|
|
15535
|
-
description: 'The detailed description of the image to generate',
|
|
15536
|
-
},
|
|
15537
|
-
},
|
|
15538
|
-
required: ['prompt'],
|
|
15539
|
-
},
|
|
15540
|
-
},
|
|
15541
|
-
];
|
|
15542
|
-
// Return requirements with updated tools and metadata
|
|
15519
|
+
const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
|
|
15543
15520
|
return this.appendToSystemMessage({
|
|
15544
15521
|
...requirements,
|
|
15545
|
-
tools: updatedTools,
|
|
15546
15522
|
_metadata: {
|
|
15547
15523
|
...requirements._metadata,
|
|
15548
15524
|
useImageGenerator: content || true,
|
|
15549
15525
|
},
|
|
15550
|
-
}, spaceTrim$1(`
|
|
15551
|
-
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
generate_image: 'Generate image',
|
|
15561
|
-
};
|
|
15562
|
-
}
|
|
15563
|
-
/**
|
|
15564
|
-
* Gets the `generate_image` tool function implementation.
|
|
15565
|
-
*/
|
|
15566
|
-
getToolFunctions() {
|
|
15567
|
-
return {
|
|
15568
|
-
async generate_image(args, ...extra) {
|
|
15569
|
-
console.log('!!!! [Tool] generate_image called', { args });
|
|
15570
|
-
const { prompt } = args;
|
|
15571
|
-
if (!prompt) {
|
|
15572
|
-
throw new Error('Image prompt is required');
|
|
15573
|
-
}
|
|
15574
|
-
const { llmTools } = extra[0] || {};
|
|
15575
|
-
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
15576
|
-
throw new Error('Image generation is not supported by the current model provider');
|
|
15577
|
-
}
|
|
15578
|
-
const result = await llmTools.callImageGenerationModel({
|
|
15579
|
-
content: prompt,
|
|
15580
|
-
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
15581
|
-
});
|
|
15582
|
-
return result.content;
|
|
15583
|
-
},
|
|
15584
|
-
};
|
|
15526
|
+
}, spaceTrim$1((block) => `
|
|
15527
|
+
Image generation:
|
|
15528
|
+
- You do not generate images directly and you do not call any image tool.
|
|
15529
|
+
- When the user asks for an image, include markdown notation in your message:
|
|
15530
|
+
\`\`
|
|
15531
|
+
- Keep \`<alt text>\` short and descriptive.
|
|
15532
|
+
- Keep \`<prompt>\` detailed so the generated image matches the request.
|
|
15533
|
+
- You can include normal explanatory text before and after the notation.
|
|
15534
|
+
${block(extraInstructions)}
|
|
15535
|
+
`));
|
|
15585
15536
|
}
|
|
15586
15537
|
}
|
|
15587
15538
|
/**
|