@promptbook/javascript 0.105.0-10 → 0.105.0-12
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 +162 -6
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +8 -4
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +22 -0
- package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
- package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
- package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
- package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +3 -0
- package/esm/typings/src/types/Prompt.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +162 -6
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
18
18
|
* @generated
|
|
19
19
|
* @see https://github.com/webgptorg/promptbook
|
|
20
20
|
*/
|
|
21
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
21
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-12';
|
|
22
22
|
/**
|
|
23
23
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
24
24
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5576,6 +5576,148 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5576
5576
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5577
5577
|
*/
|
|
5578
5578
|
|
|
5579
|
+
/**
|
|
5580
|
+
* USE IMAGE GENERATOR commitment definition
|
|
5581
|
+
*
|
|
5582
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
|
|
5583
|
+
* to create images based on text prompts.
|
|
5584
|
+
*
|
|
5585
|
+
* Example usage in agent source:
|
|
5586
|
+
*
|
|
5587
|
+
* ```book
|
|
5588
|
+
* USE IMAGE GENERATOR
|
|
5589
|
+
* USE IMAGE GENERATOR Create realistic images of nature
|
|
5590
|
+
* ```
|
|
5591
|
+
*
|
|
5592
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
5593
|
+
*/
|
|
5594
|
+
class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
5595
|
+
constructor(type = 'USE IMAGE GENERATOR') {
|
|
5596
|
+
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
5597
|
+
}
|
|
5598
|
+
/**
|
|
5599
|
+
* Short one-line description of USE IMAGE GENERATOR.
|
|
5600
|
+
*/
|
|
5601
|
+
get description() {
|
|
5602
|
+
return 'Enable the agent to use an image generation tool for creating images from text prompts.';
|
|
5603
|
+
}
|
|
5604
|
+
/**
|
|
5605
|
+
* Icon for this commitment.
|
|
5606
|
+
*/
|
|
5607
|
+
get icon() {
|
|
5608
|
+
return '🖼️';
|
|
5609
|
+
}
|
|
5610
|
+
/**
|
|
5611
|
+
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
5612
|
+
*/
|
|
5613
|
+
get documentation() {
|
|
5614
|
+
return spaceTrim$1(`
|
|
5615
|
+
# USE IMAGE GENERATOR
|
|
5616
|
+
|
|
5617
|
+
Enables the agent to use an image generation tool to create images based on text prompts.
|
|
5618
|
+
|
|
5619
|
+
## Key aspects
|
|
5620
|
+
|
|
5621
|
+
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
5622
|
+
- The actual image generation is handled by the agent runtime using LLM execution tools.
|
|
5623
|
+
- Allows the agent to generate visual content based on user requests.
|
|
5624
|
+
- Returns the URL of the generated image.
|
|
5625
|
+
|
|
5626
|
+
## Examples
|
|
5627
|
+
|
|
5628
|
+
\`\`\`book
|
|
5629
|
+
Visual Artist
|
|
5630
|
+
|
|
5631
|
+
PERSONA You are a creative visual artist who can generate images.
|
|
5632
|
+
USE IMAGE GENERATOR
|
|
5633
|
+
RULE Always describe the generated image to the user.
|
|
5634
|
+
\`\`\`
|
|
5635
|
+
|
|
5636
|
+
\`\`\`book
|
|
5637
|
+
Interior Designer
|
|
5638
|
+
|
|
5639
|
+
PERSONA You are an interior designer who helps users visualize their space.
|
|
5640
|
+
USE IMAGE GENERATOR Professional interior design renders.
|
|
5641
|
+
ACTION Generate a preview of the designed room.
|
|
5642
|
+
\`\`\`
|
|
5643
|
+
`);
|
|
5644
|
+
}
|
|
5645
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
5646
|
+
// Get existing tools array or create new one
|
|
5647
|
+
const existingTools = requirements.tools || [];
|
|
5648
|
+
// Add 'generate_image' to tools if not already present
|
|
5649
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
5650
|
+
? existingTools
|
|
5651
|
+
: [
|
|
5652
|
+
...existingTools,
|
|
5653
|
+
{
|
|
5654
|
+
name: 'generate_image',
|
|
5655
|
+
description: spaceTrim$1(`
|
|
5656
|
+
Generate an image from a text prompt.
|
|
5657
|
+
Use this tool when the user asks to create, draw, or generate an image.
|
|
5658
|
+
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
5659
|
+
`),
|
|
5660
|
+
parameters: {
|
|
5661
|
+
type: 'object',
|
|
5662
|
+
properties: {
|
|
5663
|
+
prompt: {
|
|
5664
|
+
type: 'string',
|
|
5665
|
+
description: 'The detailed description of the image to generate',
|
|
5666
|
+
},
|
|
5667
|
+
},
|
|
5668
|
+
required: ['prompt'],
|
|
5669
|
+
},
|
|
5670
|
+
},
|
|
5671
|
+
];
|
|
5672
|
+
// Return requirements with updated tools and metadata
|
|
5673
|
+
return this.appendToSystemMessage({
|
|
5674
|
+
...requirements,
|
|
5675
|
+
tools: updatedTools,
|
|
5676
|
+
metadata: {
|
|
5677
|
+
...requirements.metadata,
|
|
5678
|
+
useImageGenerator: content || true,
|
|
5679
|
+
},
|
|
5680
|
+
}, spaceTrim$1(`
|
|
5681
|
+
You have access to an image generator. Use it to create images based on user requests.
|
|
5682
|
+
When you generate an image, you will receive a URL of the generated image.
|
|
5683
|
+
`));
|
|
5684
|
+
}
|
|
5685
|
+
/**
|
|
5686
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
5687
|
+
*/
|
|
5688
|
+
getToolTitles() {
|
|
5689
|
+
return {
|
|
5690
|
+
generate_image: 'Generate image',
|
|
5691
|
+
};
|
|
5692
|
+
}
|
|
5693
|
+
/**
|
|
5694
|
+
* Gets the `generate_image` tool function implementation.
|
|
5695
|
+
*/
|
|
5696
|
+
getToolFunctions() {
|
|
5697
|
+
return {
|
|
5698
|
+
async generate_image(args, ...extra) {
|
|
5699
|
+
console.log('!!!! [Tool] generate_image called', { args });
|
|
5700
|
+
const { prompt } = args;
|
|
5701
|
+
if (!prompt) {
|
|
5702
|
+
throw new Error('Image prompt is required');
|
|
5703
|
+
}
|
|
5704
|
+
const { llmTools } = extra[0] || {};
|
|
5705
|
+
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
5706
|
+
throw new Error('Image generation is not supported by the current model provider');
|
|
5707
|
+
}
|
|
5708
|
+
const result = await llmTools.callImageGenerationModel({
|
|
5709
|
+
content: prompt,
|
|
5710
|
+
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
5711
|
+
});
|
|
5712
|
+
return result.content;
|
|
5713
|
+
},
|
|
5714
|
+
};
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5717
|
+
/**
|
|
5718
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5719
|
+
*/
|
|
5720
|
+
|
|
5579
5721
|
/**
|
|
5580
5722
|
* USE MCP commitment definition
|
|
5581
5723
|
*
|
|
@@ -5824,8 +5966,12 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5824
5966
|
useSearchEngine: content || true,
|
|
5825
5967
|
},
|
|
5826
5968
|
}, spaceTrim$1(`
|
|
5827
|
-
|
|
5969
|
+
Tools:
|
|
5970
|
+
You have access to the web search engine via the tool "web_search".
|
|
5971
|
+
Use it to find up-to-date information or facts that you don't know.
|
|
5828
5972
|
When you need to know some information from the internet, use the tool provided to you.
|
|
5973
|
+
Do not make up information when you can search for it.
|
|
5974
|
+
Do not tell the user you cannot search for information, YOU CAN.
|
|
5829
5975
|
`));
|
|
5830
5976
|
}
|
|
5831
5977
|
/**
|
|
@@ -5850,9 +5996,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5850
5996
|
const searchEngine = new SerpSearchEngine();
|
|
5851
5997
|
const results = await searchEngine.search(query, options);
|
|
5852
5998
|
return spaceTrim$1((block) => `
|
|
5853
|
-
Search results for "${query}"${Object.keys(options).length === 0
|
|
5854
|
-
? ''
|
|
5855
|
-
: ` with options ${JSON.stringify(options)}`}:
|
|
5999
|
+
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
5856
6000
|
|
|
5857
6001
|
${block(results
|
|
5858
6002
|
.map((result) => spaceTrim$1(`
|
|
@@ -5956,8 +6100,11 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5956
6100
|
...requirements.metadata,
|
|
5957
6101
|
},
|
|
5958
6102
|
}, spaceTrim$1(`
|
|
5959
|
-
|
|
6103
|
+
Tool:
|
|
6104
|
+
You have access to the current date and time via the tool "get_current_time".
|
|
6105
|
+
Use it to answer questions about the current date and time.
|
|
5960
6106
|
When you need to know the current date or time, use the tool provided to you.
|
|
6107
|
+
Do not make up the current date or time; always use the tool to get accurate information.
|
|
5961
6108
|
`));
|
|
5962
6109
|
}
|
|
5963
6110
|
/**
|
|
@@ -6139,6 +6286,15 @@ const COMMITMENT_REGISTRY = [
|
|
|
6139
6286
|
new UseBrowserCommitmentDefinition(),
|
|
6140
6287
|
new UseSearchEngineCommitmentDefinition(),
|
|
6141
6288
|
new UseTimeCommitmentDefinition(),
|
|
6289
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATOR'),
|
|
6290
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6291
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATION'),
|
|
6292
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6293
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATOR'),
|
|
6294
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6295
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATION'),
|
|
6296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6297
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE'),
|
|
6142
6298
|
new UseMcpCommitmentDefinition(),
|
|
6143
6299
|
new UseCommitmentDefinition(),
|
|
6144
6300
|
// Not yet implemented commitments (using placeholder)
|