@promptbook/core 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 +1 -1
- package/umd/index.umd.js +24 -73
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-1';
|
|
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
|
|
@@ -14734,8 +14734,8 @@ class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14734
14734
|
/**
|
|
14735
14735
|
* USE IMAGE GENERATOR commitment definition
|
|
14736
14736
|
*
|
|
14737
|
-
* The `USE IMAGE GENERATOR` commitment indicates that the agent
|
|
14738
|
-
*
|
|
14737
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent can output
|
|
14738
|
+
* markdown placeholders for UI-driven image generation.
|
|
14739
14739
|
*
|
|
14740
14740
|
* Example usage in agent source:
|
|
14741
14741
|
*
|
|
@@ -14750,11 +14750,14 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14750
14750
|
constructor(type = 'USE IMAGE GENERATOR') {
|
|
14751
14751
|
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
14752
14752
|
}
|
|
14753
|
+
get requiresContent() {
|
|
14754
|
+
return false;
|
|
14755
|
+
}
|
|
14753
14756
|
/**
|
|
14754
14757
|
* Short one-line description of USE IMAGE GENERATOR.
|
|
14755
14758
|
*/
|
|
14756
14759
|
get description() {
|
|
14757
|
-
return 'Enable the agent to
|
|
14760
|
+
return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
|
|
14758
14761
|
}
|
|
14759
14762
|
/**
|
|
14760
14763
|
* Icon for this commitment.
|
|
@@ -14769,21 +14772,21 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14769
14772
|
return spaceTrim$1(`
|
|
14770
14773
|
# USE IMAGE GENERATOR
|
|
14771
14774
|
|
|
14772
|
-
Enables the agent to
|
|
14775
|
+
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
14773
14776
|
|
|
14774
14777
|
## Key aspects
|
|
14775
14778
|
|
|
14776
14779
|
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
14777
|
-
- The
|
|
14778
|
-
-
|
|
14779
|
-
-
|
|
14780
|
+
- The agent does **not** call an image-generation tool directly.
|
|
14781
|
+
- The agent inserts markdown notation: \`\`.
|
|
14782
|
+
- The user interface detects the notation and generates the image asynchronously.
|
|
14780
14783
|
|
|
14781
14784
|
## Examples
|
|
14782
14785
|
|
|
14783
14786
|
\`\`\`book
|
|
14784
14787
|
Visual Artist
|
|
14785
14788
|
|
|
14786
|
-
PERSONA You are a creative visual artist
|
|
14789
|
+
PERSONA You are a creative visual artist.
|
|
14787
14790
|
USE IMAGE GENERATOR
|
|
14788
14791
|
RULE Always describe the generated image to the user.
|
|
14789
14792
|
\`\`\`
|
|
@@ -14793,80 +14796,28 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14793
14796
|
|
|
14794
14797
|
PERSONA You are an interior designer who helps users visualize their space.
|
|
14795
14798
|
USE IMAGE GENERATOR Professional interior design renders.
|
|
14796
|
-
ACTION
|
|
14799
|
+
ACTION Add one generated image placeholder whenever a user asks for a visual.
|
|
14797
14800
|
\`\`\`
|
|
14798
14801
|
`);
|
|
14799
14802
|
}
|
|
14800
14803
|
applyToAgentModelRequirements(requirements, content) {
|
|
14801
|
-
|
|
14802
|
-
const existingTools = requirements.tools || [];
|
|
14803
|
-
// Add 'generate_image' to tools if not already present
|
|
14804
|
-
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
14805
|
-
? existingTools
|
|
14806
|
-
: [
|
|
14807
|
-
...existingTools,
|
|
14808
|
-
{
|
|
14809
|
-
name: 'generate_image',
|
|
14810
|
-
description: spaceTrim$1(`
|
|
14811
|
-
Generate an image from a text prompt.
|
|
14812
|
-
Use this tool when the user asks to create, draw, or generate an image.
|
|
14813
|
-
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
14814
|
-
`),
|
|
14815
|
-
parameters: {
|
|
14816
|
-
type: 'object',
|
|
14817
|
-
properties: {
|
|
14818
|
-
prompt: {
|
|
14819
|
-
type: 'string',
|
|
14820
|
-
description: 'The detailed description of the image to generate',
|
|
14821
|
-
},
|
|
14822
|
-
},
|
|
14823
|
-
required: ['prompt'],
|
|
14824
|
-
},
|
|
14825
|
-
},
|
|
14826
|
-
];
|
|
14827
|
-
// Return requirements with updated tools and metadata
|
|
14804
|
+
const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
|
|
14828
14805
|
return this.appendToSystemMessage({
|
|
14829
14806
|
...requirements,
|
|
14830
|
-
tools: updatedTools,
|
|
14831
14807
|
_metadata: {
|
|
14832
14808
|
...requirements._metadata,
|
|
14833
14809
|
useImageGenerator: content || true,
|
|
14834
14810
|
},
|
|
14835
|
-
}, spaceTrim$1(`
|
|
14836
|
-
|
|
14837
|
-
|
|
14838
|
-
|
|
14839
|
-
|
|
14840
|
-
|
|
14841
|
-
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
generate_image: 'Generate image',
|
|
14846
|
-
};
|
|
14847
|
-
}
|
|
14848
|
-
/**
|
|
14849
|
-
* Gets the `generate_image` tool function implementation.
|
|
14850
|
-
*/
|
|
14851
|
-
getToolFunctions() {
|
|
14852
|
-
return {
|
|
14853
|
-
async generate_image(args, ...extra) {
|
|
14854
|
-
console.log('!!!! [Tool] generate_image called', { args });
|
|
14855
|
-
const { prompt } = args;
|
|
14856
|
-
if (!prompt) {
|
|
14857
|
-
throw new Error('Image prompt is required');
|
|
14858
|
-
}
|
|
14859
|
-
const { llmTools } = extra[0] || {};
|
|
14860
|
-
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
14861
|
-
throw new Error('Image generation is not supported by the current model provider');
|
|
14862
|
-
}
|
|
14863
|
-
const result = await llmTools.callImageGenerationModel({
|
|
14864
|
-
content: prompt,
|
|
14865
|
-
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
14866
|
-
});
|
|
14867
|
-
return result.content;
|
|
14868
|
-
},
|
|
14869
|
-
};
|
|
14811
|
+
}, spaceTrim$1((block) => `
|
|
14812
|
+
Image generation:
|
|
14813
|
+
- You do not generate images directly and you do not call any image tool.
|
|
14814
|
+
- When the user asks for an image, include markdown notation in your message:
|
|
14815
|
+
\`\`
|
|
14816
|
+
- Keep \`<alt text>\` short and descriptive.
|
|
14817
|
+
- Keep \`<prompt>\` detailed so the generated image matches the request.
|
|
14818
|
+
- You can include normal explanatory text before and after the notation.
|
|
14819
|
+
${block(extraInstructions)}
|
|
14820
|
+
`));
|
|
14870
14821
|
}
|
|
14871
14822
|
}
|
|
14872
14823
|
/**
|