@promptbook/wizard 0.111.0-0 → 0.111.0-2

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 CHANGED
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.111.0-0';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.111.0-2';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -22079,8 +22079,8 @@ class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
22079
22079
  /**
22080
22080
  * USE IMAGE GENERATOR commitment definition
22081
22081
  *
22082
- * The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
22083
- * to create images based on text prompts.
22082
+ * The `USE IMAGE GENERATOR` commitment indicates that the agent can output
22083
+ * markdown placeholders for UI-driven image generation.
22084
22084
  *
22085
22085
  * Example usage in agent source:
22086
22086
  *
@@ -22095,11 +22095,14 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
22095
22095
  constructor(type = 'USE IMAGE GENERATOR') {
22096
22096
  super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
22097
22097
  }
22098
+ get requiresContent() {
22099
+ return false;
22100
+ }
22098
22101
  /**
22099
22102
  * Short one-line description of USE IMAGE GENERATOR.
22100
22103
  */
22101
22104
  get description() {
22102
- return 'Enable the agent to use an image generation tool for creating images from text prompts.';
22105
+ return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
22103
22106
  }
22104
22107
  /**
22105
22108
  * Icon for this commitment.
@@ -22114,21 +22117,21 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
22114
22117
  return spaceTrim$1(`
22115
22118
  # USE IMAGE GENERATOR
22116
22119
 
22117
- Enables the agent to use an image generation tool to create images based on text prompts.
22120
+ Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
22118
22121
 
22119
22122
  ## Key aspects
22120
22123
 
22121
22124
  - The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
22122
- - The actual image generation is handled by the agent runtime using LLM execution tools.
22123
- - Allows the agent to generate visual content based on user requests.
22124
- - Returns the URL of the generated image.
22125
+ - The agent does **not** call an image-generation tool directly.
22126
+ - The agent inserts markdown notation: \`![alt](?image-prompt=...)\`.
22127
+ - The user interface detects the notation and generates the image asynchronously.
22125
22128
 
22126
22129
  ## Examples
22127
22130
 
22128
22131
  \`\`\`book
22129
22132
  Visual Artist
22130
22133
 
22131
- PERSONA You are a creative visual artist who can generate images.
22134
+ PERSONA You are a creative visual artist.
22132
22135
  USE IMAGE GENERATOR
22133
22136
  RULE Always describe the generated image to the user.
22134
22137
  \`\`\`
@@ -22138,80 +22141,28 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
22138
22141
 
22139
22142
  PERSONA You are an interior designer who helps users visualize their space.
22140
22143
  USE IMAGE GENERATOR Professional interior design renders.
22141
- ACTION Generate a preview of the designed room.
22144
+ ACTION Add one generated image placeholder whenever a user asks for a visual.
22142
22145
  \`\`\`
22143
22146
  `);
22144
22147
  }
22145
22148
  applyToAgentModelRequirements(requirements, content) {
22146
- // Get existing tools array or create new one
22147
- const existingTools = requirements.tools || [];
22148
- // Add 'generate_image' to tools if not already present
22149
- const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
22150
- ? existingTools
22151
- : [
22152
- ...existingTools,
22153
- {
22154
- name: 'generate_image',
22155
- description: spaceTrim$1(`
22156
- Generate an image from a text prompt.
22157
- Use this tool when the user asks to create, draw, or generate an image.
22158
- ${!content ? '' : `Style instructions / guidelines: ${content}`}
22159
- `),
22160
- parameters: {
22161
- type: 'object',
22162
- properties: {
22163
- prompt: {
22164
- type: 'string',
22165
- description: 'The detailed description of the image to generate',
22166
- },
22167
- },
22168
- required: ['prompt'],
22169
- },
22170
- },
22171
- ];
22172
- // Return requirements with updated tools and metadata
22149
+ const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
22173
22150
  return this.appendToSystemMessage({
22174
22151
  ...requirements,
22175
- tools: updatedTools,
22176
22152
  _metadata: {
22177
22153
  ...requirements._metadata,
22178
22154
  useImageGenerator: content || true,
22179
22155
  },
22180
- }, spaceTrim$1(`
22181
- You have access to an image generator. Use it to create images based on user requests.
22182
- When you generate an image, you will receive a URL of the generated image.
22183
- `));
22184
- }
22185
- /**
22186
- * Gets human-readable titles for tool functions provided by this commitment.
22187
- */
22188
- getToolTitles() {
22189
- return {
22190
- generate_image: 'Generate image',
22191
- };
22192
- }
22193
- /**
22194
- * Gets the `generate_image` tool function implementation.
22195
- */
22196
- getToolFunctions() {
22197
- return {
22198
- async generate_image(args, ...extra) {
22199
- console.log('!!!! [Tool] generate_image called', { args });
22200
- const { prompt } = args;
22201
- if (!prompt) {
22202
- throw new Error('Image prompt is required');
22203
- }
22204
- const { llmTools } = extra[0] || {};
22205
- if (!llmTools || !llmTools.callImageGenerationModel) {
22206
- throw new Error('Image generation is not supported by the current model provider');
22207
- }
22208
- const result = await llmTools.callImageGenerationModel({
22209
- content: prompt,
22210
- modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
22211
- });
22212
- return result.content;
22213
- },
22214
- };
22156
+ }, spaceTrim$1((block) => `
22157
+ Image generation:
22158
+ - You do not generate images directly and you do not call any image tool.
22159
+ - When the user asks for an image, include markdown notation in your message:
22160
+ \`![<alt text>](?image-prompt=<prompt>)\`
22161
+ - Keep \`<alt text>\` short and descriptive.
22162
+ - Keep \`<prompt>\` detailed so the generated image matches the request.
22163
+ - You can include normal explanatory text before and after the notation.
22164
+ ${block(extraInstructions)}
22165
+ `));
22215
22166
  }
22216
22167
  }
22217
22168
  /**
@@ -31971,7 +31922,6 @@ class RemoteAgent extends Agent {
31971
31922
  doneReading = !!done;
31972
31923
  if (value) {
31973
31924
  const textChunk = decoder.decode(value, { stream: true });
31974
- let sawToolCalls = false;
31975
31925
  let hasNonEmptyText = false;
31976
31926
  const textLines = [];
31977
31927
  const lines = textChunk.split(/\r?\n/);
@@ -31997,7 +31947,6 @@ class RemoteAgent extends Agent {
31997
31947
  rawResponse: {},
31998
31948
  toolCalls: getActiveToolCalls(),
31999
31949
  });
32000
- sawToolCalls = true;
32001
31950
  isToolCallLine = true;
32002
31951
  }
32003
31952
  }
@@ -32007,22 +31956,16 @@ class RemoteAgent extends Agent {
32007
31956
  }
32008
31957
  if (!isToolCallLine) {
32009
31958
  textLines.push(line);
32010
- if (line.length > 0) {
31959
+ if (trimmedLine.length > 0) {
32011
31960
  hasNonEmptyText = true;
32012
31961
  }
32013
31962
  }
32014
31963
  }
32015
- if (sawToolCalls) {
32016
- if (!hasNonEmptyText) {
32017
- continue;
32018
- }
32019
- const textChunkWithoutToolCalls = textLines.join('\n');
32020
- content += textChunkWithoutToolCalls;
32021
- }
32022
- else {
32023
- // console.debug('RemoteAgent chunk:', textChunk);
32024
- content += textChunk;
31964
+ if (!hasNonEmptyText) {
31965
+ continue;
32025
31966
  }
31967
+ const textChunkWithoutToolCalls = textLines.join('\n');
31968
+ content += textChunkWithoutToolCalls;
32026
31969
  if (!hasReceivedModelOutput && content.trim().length > 0) {
32027
31970
  hasReceivedModelOutput = true;
32028
31971
  preparationToolCalls.length = 0;