@promptbook/fake-llm 0.105.0-10 → 0.105.0-11
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/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
|
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
20
20
|
* @generated
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
23
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-11';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6107,6 +6107,148 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6107
6107
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6108
6108
|
*/
|
|
6109
6109
|
|
|
6110
|
+
/**
|
|
6111
|
+
* USE IMAGE GENERATOR commitment definition
|
|
6112
|
+
*
|
|
6113
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
|
|
6114
|
+
* to create images based on text prompts.
|
|
6115
|
+
*
|
|
6116
|
+
* Example usage in agent source:
|
|
6117
|
+
*
|
|
6118
|
+
* ```book
|
|
6119
|
+
* USE IMAGE GENERATOR
|
|
6120
|
+
* USE IMAGE GENERATOR Create realistic images of nature
|
|
6121
|
+
* ```
|
|
6122
|
+
*
|
|
6123
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
6124
|
+
*/
|
|
6125
|
+
class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
6126
|
+
constructor(type = 'USE IMAGE GENERATOR') {
|
|
6127
|
+
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
6128
|
+
}
|
|
6129
|
+
/**
|
|
6130
|
+
* Short one-line description of USE IMAGE GENERATOR.
|
|
6131
|
+
*/
|
|
6132
|
+
get description() {
|
|
6133
|
+
return 'Enable the agent to use an image generation tool for creating images from text prompts.';
|
|
6134
|
+
}
|
|
6135
|
+
/**
|
|
6136
|
+
* Icon for this commitment.
|
|
6137
|
+
*/
|
|
6138
|
+
get icon() {
|
|
6139
|
+
return '🖼️';
|
|
6140
|
+
}
|
|
6141
|
+
/**
|
|
6142
|
+
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
6143
|
+
*/
|
|
6144
|
+
get documentation() {
|
|
6145
|
+
return spaceTrim$1(`
|
|
6146
|
+
# USE IMAGE GENERATOR
|
|
6147
|
+
|
|
6148
|
+
Enables the agent to use an image generation tool to create images based on text prompts.
|
|
6149
|
+
|
|
6150
|
+
## Key aspects
|
|
6151
|
+
|
|
6152
|
+
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
6153
|
+
- The actual image generation is handled by the agent runtime using LLM execution tools.
|
|
6154
|
+
- Allows the agent to generate visual content based on user requests.
|
|
6155
|
+
- Returns the URL of the generated image.
|
|
6156
|
+
|
|
6157
|
+
## Examples
|
|
6158
|
+
|
|
6159
|
+
\`\`\`book
|
|
6160
|
+
Visual Artist
|
|
6161
|
+
|
|
6162
|
+
PERSONA You are a creative visual artist who can generate images.
|
|
6163
|
+
USE IMAGE GENERATOR
|
|
6164
|
+
RULE Always describe the generated image to the user.
|
|
6165
|
+
\`\`\`
|
|
6166
|
+
|
|
6167
|
+
\`\`\`book
|
|
6168
|
+
Interior Designer
|
|
6169
|
+
|
|
6170
|
+
PERSONA You are an interior designer who helps users visualize their space.
|
|
6171
|
+
USE IMAGE GENERATOR Professional interior design renders.
|
|
6172
|
+
ACTION Generate a preview of the designed room.
|
|
6173
|
+
\`\`\`
|
|
6174
|
+
`);
|
|
6175
|
+
}
|
|
6176
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
6177
|
+
// Get existing tools array or create new one
|
|
6178
|
+
const existingTools = requirements.tools || [];
|
|
6179
|
+
// Add 'generate_image' to tools if not already present
|
|
6180
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
6181
|
+
? existingTools
|
|
6182
|
+
: [
|
|
6183
|
+
...existingTools,
|
|
6184
|
+
{
|
|
6185
|
+
name: 'generate_image',
|
|
6186
|
+
description: spaceTrim$1(`
|
|
6187
|
+
Generate an image from a text prompt.
|
|
6188
|
+
Use this tool when the user asks to create, draw, or generate an image.
|
|
6189
|
+
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
6190
|
+
`),
|
|
6191
|
+
parameters: {
|
|
6192
|
+
type: 'object',
|
|
6193
|
+
properties: {
|
|
6194
|
+
prompt: {
|
|
6195
|
+
type: 'string',
|
|
6196
|
+
description: 'The detailed description of the image to generate',
|
|
6197
|
+
},
|
|
6198
|
+
},
|
|
6199
|
+
required: ['prompt'],
|
|
6200
|
+
},
|
|
6201
|
+
},
|
|
6202
|
+
];
|
|
6203
|
+
// Return requirements with updated tools and metadata
|
|
6204
|
+
return this.appendToSystemMessage({
|
|
6205
|
+
...requirements,
|
|
6206
|
+
tools: updatedTools,
|
|
6207
|
+
metadata: {
|
|
6208
|
+
...requirements.metadata,
|
|
6209
|
+
useImageGenerator: content || true,
|
|
6210
|
+
},
|
|
6211
|
+
}, spaceTrim$1(`
|
|
6212
|
+
You have access to an image generator. Use it to create images based on user requests.
|
|
6213
|
+
When you generate an image, you will receive a URL of the generated image.
|
|
6214
|
+
`));
|
|
6215
|
+
}
|
|
6216
|
+
/**
|
|
6217
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
6218
|
+
*/
|
|
6219
|
+
getToolTitles() {
|
|
6220
|
+
return {
|
|
6221
|
+
generate_image: 'Generate image',
|
|
6222
|
+
};
|
|
6223
|
+
}
|
|
6224
|
+
/**
|
|
6225
|
+
* Gets the `generate_image` tool function implementation.
|
|
6226
|
+
*/
|
|
6227
|
+
getToolFunctions() {
|
|
6228
|
+
return {
|
|
6229
|
+
async generate_image(args, ...extra) {
|
|
6230
|
+
console.log('!!!! [Tool] generate_image called', { args });
|
|
6231
|
+
const { prompt } = args;
|
|
6232
|
+
if (!prompt) {
|
|
6233
|
+
throw new Error('Image prompt is required');
|
|
6234
|
+
}
|
|
6235
|
+
const { llmTools } = extra[0] || {};
|
|
6236
|
+
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
6237
|
+
throw new Error('Image generation is not supported by the current model provider');
|
|
6238
|
+
}
|
|
6239
|
+
const result = await llmTools.callImageGenerationModel({
|
|
6240
|
+
content: prompt,
|
|
6241
|
+
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
6242
|
+
});
|
|
6243
|
+
return result.content;
|
|
6244
|
+
},
|
|
6245
|
+
};
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6248
|
+
/**
|
|
6249
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6250
|
+
*/
|
|
6251
|
+
|
|
6110
6252
|
/**
|
|
6111
6253
|
* USE MCP commitment definition
|
|
6112
6254
|
*
|
|
@@ -6355,8 +6497,12 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6355
6497
|
useSearchEngine: content || true,
|
|
6356
6498
|
},
|
|
6357
6499
|
}, spaceTrim$1(`
|
|
6358
|
-
|
|
6500
|
+
Tools:
|
|
6501
|
+
You have access to the web search engine via the tool "web_search".
|
|
6502
|
+
Use it to find up-to-date information or facts that you don't know.
|
|
6359
6503
|
When you need to know some information from the internet, use the tool provided to you.
|
|
6504
|
+
Do not make up information when you can search for it.
|
|
6505
|
+
Do not tell the user you cannot search for information, YOU CAN.
|
|
6360
6506
|
`));
|
|
6361
6507
|
}
|
|
6362
6508
|
/**
|
|
@@ -6381,9 +6527,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6381
6527
|
const searchEngine = new SerpSearchEngine();
|
|
6382
6528
|
const results = await searchEngine.search(query, options);
|
|
6383
6529
|
return spaceTrim$1((block) => `
|
|
6384
|
-
Search results for "${query}"${Object.keys(options).length === 0
|
|
6385
|
-
? ''
|
|
6386
|
-
: ` with options ${JSON.stringify(options)}`}:
|
|
6530
|
+
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
6387
6531
|
|
|
6388
6532
|
${block(results
|
|
6389
6533
|
.map((result) => spaceTrim$1(`
|
|
@@ -6487,8 +6631,11 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6487
6631
|
...requirements.metadata,
|
|
6488
6632
|
},
|
|
6489
6633
|
}, spaceTrim$1(`
|
|
6490
|
-
|
|
6634
|
+
Tool:
|
|
6635
|
+
You have access to the current date and time via the tool "get_current_time".
|
|
6636
|
+
Use it to answer questions about the current date and time.
|
|
6491
6637
|
When you need to know the current date or time, use the tool provided to you.
|
|
6638
|
+
Do not make up the current date or time; always use the tool to get accurate information.
|
|
6492
6639
|
`));
|
|
6493
6640
|
}
|
|
6494
6641
|
/**
|
|
@@ -6670,6 +6817,15 @@ const COMMITMENT_REGISTRY = [
|
|
|
6670
6817
|
new UseBrowserCommitmentDefinition(),
|
|
6671
6818
|
new UseSearchEngineCommitmentDefinition(),
|
|
6672
6819
|
new UseTimeCommitmentDefinition(),
|
|
6820
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATOR'),
|
|
6821
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6822
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATION'),
|
|
6823
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6824
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATOR'),
|
|
6825
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6826
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATION'),
|
|
6827
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6828
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE'),
|
|
6673
6829
|
new UseMcpCommitmentDefinition(),
|
|
6674
6830
|
new UseCommitmentDefinition(),
|
|
6675
6831
|
// Not yet implemented commitments (using placeholder)
|