@promptbook/remote-server 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
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-12';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11493,6 +11493,148 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11493
11493
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11494
11494
|
*/
|
|
11495
11495
|
|
|
11496
|
+
/**
|
|
11497
|
+
* USE IMAGE GENERATOR commitment definition
|
|
11498
|
+
*
|
|
11499
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
|
|
11500
|
+
* to create images based on text prompts.
|
|
11501
|
+
*
|
|
11502
|
+
* Example usage in agent source:
|
|
11503
|
+
*
|
|
11504
|
+
* ```book
|
|
11505
|
+
* USE IMAGE GENERATOR
|
|
11506
|
+
* USE IMAGE GENERATOR Create realistic images of nature
|
|
11507
|
+
* ```
|
|
11508
|
+
*
|
|
11509
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
11510
|
+
*/
|
|
11511
|
+
class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
11512
|
+
constructor(type = 'USE IMAGE GENERATOR') {
|
|
11513
|
+
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
11514
|
+
}
|
|
11515
|
+
/**
|
|
11516
|
+
* Short one-line description of USE IMAGE GENERATOR.
|
|
11517
|
+
*/
|
|
11518
|
+
get description() {
|
|
11519
|
+
return 'Enable the agent to use an image generation tool for creating images from text prompts.';
|
|
11520
|
+
}
|
|
11521
|
+
/**
|
|
11522
|
+
* Icon for this commitment.
|
|
11523
|
+
*/
|
|
11524
|
+
get icon() {
|
|
11525
|
+
return '🖼️';
|
|
11526
|
+
}
|
|
11527
|
+
/**
|
|
11528
|
+
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
11529
|
+
*/
|
|
11530
|
+
get documentation() {
|
|
11531
|
+
return spaceTrim$1(`
|
|
11532
|
+
# USE IMAGE GENERATOR
|
|
11533
|
+
|
|
11534
|
+
Enables the agent to use an image generation tool to create images based on text prompts.
|
|
11535
|
+
|
|
11536
|
+
## Key aspects
|
|
11537
|
+
|
|
11538
|
+
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
11539
|
+
- The actual image generation is handled by the agent runtime using LLM execution tools.
|
|
11540
|
+
- Allows the agent to generate visual content based on user requests.
|
|
11541
|
+
- Returns the URL of the generated image.
|
|
11542
|
+
|
|
11543
|
+
## Examples
|
|
11544
|
+
|
|
11545
|
+
\`\`\`book
|
|
11546
|
+
Visual Artist
|
|
11547
|
+
|
|
11548
|
+
PERSONA You are a creative visual artist who can generate images.
|
|
11549
|
+
USE IMAGE GENERATOR
|
|
11550
|
+
RULE Always describe the generated image to the user.
|
|
11551
|
+
\`\`\`
|
|
11552
|
+
|
|
11553
|
+
\`\`\`book
|
|
11554
|
+
Interior Designer
|
|
11555
|
+
|
|
11556
|
+
PERSONA You are an interior designer who helps users visualize their space.
|
|
11557
|
+
USE IMAGE GENERATOR Professional interior design renders.
|
|
11558
|
+
ACTION Generate a preview of the designed room.
|
|
11559
|
+
\`\`\`
|
|
11560
|
+
`);
|
|
11561
|
+
}
|
|
11562
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
11563
|
+
// Get existing tools array or create new one
|
|
11564
|
+
const existingTools = requirements.tools || [];
|
|
11565
|
+
// Add 'generate_image' to tools if not already present
|
|
11566
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
11567
|
+
? existingTools
|
|
11568
|
+
: [
|
|
11569
|
+
...existingTools,
|
|
11570
|
+
{
|
|
11571
|
+
name: 'generate_image',
|
|
11572
|
+
description: spaceTrim$1(`
|
|
11573
|
+
Generate an image from a text prompt.
|
|
11574
|
+
Use this tool when the user asks to create, draw, or generate an image.
|
|
11575
|
+
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
11576
|
+
`),
|
|
11577
|
+
parameters: {
|
|
11578
|
+
type: 'object',
|
|
11579
|
+
properties: {
|
|
11580
|
+
prompt: {
|
|
11581
|
+
type: 'string',
|
|
11582
|
+
description: 'The detailed description of the image to generate',
|
|
11583
|
+
},
|
|
11584
|
+
},
|
|
11585
|
+
required: ['prompt'],
|
|
11586
|
+
},
|
|
11587
|
+
},
|
|
11588
|
+
];
|
|
11589
|
+
// Return requirements with updated tools and metadata
|
|
11590
|
+
return this.appendToSystemMessage({
|
|
11591
|
+
...requirements,
|
|
11592
|
+
tools: updatedTools,
|
|
11593
|
+
metadata: {
|
|
11594
|
+
...requirements.metadata,
|
|
11595
|
+
useImageGenerator: content || true,
|
|
11596
|
+
},
|
|
11597
|
+
}, spaceTrim$1(`
|
|
11598
|
+
You have access to an image generator. Use it to create images based on user requests.
|
|
11599
|
+
When you generate an image, you will receive a URL of the generated image.
|
|
11600
|
+
`));
|
|
11601
|
+
}
|
|
11602
|
+
/**
|
|
11603
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
11604
|
+
*/
|
|
11605
|
+
getToolTitles() {
|
|
11606
|
+
return {
|
|
11607
|
+
generate_image: 'Generate image',
|
|
11608
|
+
};
|
|
11609
|
+
}
|
|
11610
|
+
/**
|
|
11611
|
+
* Gets the `generate_image` tool function implementation.
|
|
11612
|
+
*/
|
|
11613
|
+
getToolFunctions() {
|
|
11614
|
+
return {
|
|
11615
|
+
async generate_image(args, ...extra) {
|
|
11616
|
+
console.log('!!!! [Tool] generate_image called', { args });
|
|
11617
|
+
const { prompt } = args;
|
|
11618
|
+
if (!prompt) {
|
|
11619
|
+
throw new Error('Image prompt is required');
|
|
11620
|
+
}
|
|
11621
|
+
const { llmTools } = extra[0] || {};
|
|
11622
|
+
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
11623
|
+
throw new Error('Image generation is not supported by the current model provider');
|
|
11624
|
+
}
|
|
11625
|
+
const result = await llmTools.callImageGenerationModel({
|
|
11626
|
+
content: prompt,
|
|
11627
|
+
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
11628
|
+
});
|
|
11629
|
+
return result.content;
|
|
11630
|
+
},
|
|
11631
|
+
};
|
|
11632
|
+
}
|
|
11633
|
+
}
|
|
11634
|
+
/**
|
|
11635
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11636
|
+
*/
|
|
11637
|
+
|
|
11496
11638
|
/**
|
|
11497
11639
|
* USE MCP commitment definition
|
|
11498
11640
|
*
|
|
@@ -11741,8 +11883,12 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11741
11883
|
useSearchEngine: content || true,
|
|
11742
11884
|
},
|
|
11743
11885
|
}, spaceTrim$1(`
|
|
11744
|
-
|
|
11886
|
+
Tools:
|
|
11887
|
+
You have access to the web search engine via the tool "web_search".
|
|
11888
|
+
Use it to find up-to-date information or facts that you don't know.
|
|
11745
11889
|
When you need to know some information from the internet, use the tool provided to you.
|
|
11890
|
+
Do not make up information when you can search for it.
|
|
11891
|
+
Do not tell the user you cannot search for information, YOU CAN.
|
|
11746
11892
|
`));
|
|
11747
11893
|
}
|
|
11748
11894
|
/**
|
|
@@ -11767,9 +11913,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11767
11913
|
const searchEngine = new SerpSearchEngine();
|
|
11768
11914
|
const results = await searchEngine.search(query, options);
|
|
11769
11915
|
return spaceTrim$1((block) => `
|
|
11770
|
-
Search results for "${query}"${Object.keys(options).length === 0
|
|
11771
|
-
? ''
|
|
11772
|
-
: ` with options ${JSON.stringify(options)}`}:
|
|
11916
|
+
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
11773
11917
|
|
|
11774
11918
|
${block(results
|
|
11775
11919
|
.map((result) => spaceTrim$1(`
|
|
@@ -11873,8 +12017,11 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11873
12017
|
...requirements.metadata,
|
|
11874
12018
|
},
|
|
11875
12019
|
}, spaceTrim$1(`
|
|
11876
|
-
|
|
12020
|
+
Tool:
|
|
12021
|
+
You have access to the current date and time via the tool "get_current_time".
|
|
12022
|
+
Use it to answer questions about the current date and time.
|
|
11877
12023
|
When you need to know the current date or time, use the tool provided to you.
|
|
12024
|
+
Do not make up the current date or time; always use the tool to get accurate information.
|
|
11878
12025
|
`));
|
|
11879
12026
|
}
|
|
11880
12027
|
/**
|
|
@@ -12056,6 +12203,15 @@ const COMMITMENT_REGISTRY = [
|
|
|
12056
12203
|
new UseBrowserCommitmentDefinition(),
|
|
12057
12204
|
new UseSearchEngineCommitmentDefinition(),
|
|
12058
12205
|
new UseTimeCommitmentDefinition(),
|
|
12206
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATOR'),
|
|
12207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12208
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATION'),
|
|
12209
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12210
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATOR'),
|
|
12211
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12212
|
+
new UseImageGeneratorCommitmentDefinition('IMAGE GENERATION'),
|
|
12213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12214
|
+
new UseImageGeneratorCommitmentDefinition('USE IMAGE'),
|
|
12059
12215
|
new UseMcpCommitmentDefinition(),
|
|
12060
12216
|
new UseCommitmentDefinition(),
|
|
12061
12217
|
// Not yet implemented commitments (using placeholder)
|