@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 +29 -86
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageMap.d.ts +17 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/citationHelpers.d.ts +38 -0
- package/esm/typings/src/book-components/Chat/utils/citationHelpers.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/utils/splitMessageContentIntoSegments.d.ts +41 -0
- package/esm/typings/src/book-components/Chat/utils/splitMessageContentIntoSegments.test.d.ts +1 -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 +2 -2
- package/umd/index.umd.js +29 -86
- package/umd/index.umd.js.map +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'leaflet/dist/leaflet.css';
|
|
2
|
+
import type { GeoJsonObject } from 'geojson';
|
|
3
|
+
/**
|
|
4
|
+
* Props for `<ChatMessageMap/>`.
|
|
5
|
+
*
|
|
6
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
7
|
+
*/
|
|
8
|
+
type ChatMessageMapProps = {
|
|
9
|
+
data: GeoJsonObject;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders a Leaflet map for GeoJSON data inside the chat bubble.
|
|
13
|
+
*
|
|
14
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
15
|
+
*/
|
|
16
|
+
export declare function ChatMessageMap({ data }: ChatMessageMapProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -17,6 +17,12 @@ export type ChatActionsOverlapConfig = {
|
|
|
17
17
|
* Selector used to locate message elements for overlap checks.
|
|
18
18
|
*/
|
|
19
19
|
messageSelector: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional selector for the actual message content region used for overlap checks.
|
|
22
|
+
*
|
|
23
|
+
* When not provided or when no matching element is found, the full message element is used.
|
|
24
|
+
*/
|
|
25
|
+
messageCollisionSelector?: string;
|
|
20
26
|
/**
|
|
21
27
|
* Messages used to trigger overlap recalculation.
|
|
22
28
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ChatParticipant } from '../types/ChatParticipant';
|
|
2
|
+
import type { ParsedCitation } from './parseCitationsFromContent';
|
|
3
|
+
/**
|
|
4
|
+
* Returns whether the provided value is a valid HTTP(S) URL.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Candidate string to inspect.
|
|
7
|
+
* @returns True when the value parses as an HTTP or HTTPS URL.
|
|
8
|
+
* @private utility of `<Chat/>` citation rendering
|
|
9
|
+
*/
|
|
10
|
+
export declare function isCitationUrl(value: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether a citation should be displayed as a text snippet instead of a file/URL.
|
|
13
|
+
*
|
|
14
|
+
* @param citation - Parsed citation metadata.
|
|
15
|
+
* @returns True when the citation looks like inline text instead of a document or URL.
|
|
16
|
+
* @private utility of `<Chat/>` citation rendering
|
|
17
|
+
*/
|
|
18
|
+
export declare function isPlainTextCitation(citation: ParsedCitation): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Builds a label that matches the desired chip/modal title for a citation.
|
|
21
|
+
*
|
|
22
|
+
* @param citation - Parsed citation metadata.
|
|
23
|
+
* @returns The friendly label shown on chips and modal headers.
|
|
24
|
+
* @private utility of `<Chat/>` citation rendering
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCitationLabel(citation: ParsedCitation): string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the preview URL used inside the citation modal iframe.
|
|
29
|
+
*
|
|
30
|
+
* @param citation - Parsed citation metadata.
|
|
31
|
+
* @param participants - Known chat participants for agent knowledge lookup.
|
|
32
|
+
* @returns URL string suitable for iframe preview or null when unavailable.
|
|
33
|
+
* @private utility of `<Chat/>` citation rendering
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveCitationPreviewUrl(citation: ParsedCitation, participants: ReadonlyArray<ChatParticipant>): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* TODO: [💞] Spread into multiple files
|
|
38
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { GeoJsonObject } from 'geojson';
|
|
2
|
+
import type { ImagePromptSegment } from './parseImagePrompts';
|
|
3
|
+
/**
|
|
4
|
+
* Segment that represents plain markdown text inside a chat message.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Segment that represents plain markdown text inside a chat message.
|
|
8
|
+
*
|
|
9
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
10
|
+
*/
|
|
11
|
+
export type ChatTextSegment = {
|
|
12
|
+
type: 'text';
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Segment that represents a Leaflet-ready map rendered from GeoJSON data.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Segment that represents a Leaflet-ready map rendered from GeoJSON data.
|
|
20
|
+
*
|
|
21
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
22
|
+
*/
|
|
23
|
+
export type ChatMapSegment = {
|
|
24
|
+
type: 'map';
|
|
25
|
+
data: GeoJsonObject;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Composite segment type that covers text, image prompts, and map features.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Composite segment type that covers text, image prompts, and map features.
|
|
32
|
+
*
|
|
33
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
34
|
+
*/
|
|
35
|
+
export type ChatMessageContentSegment = ImagePromptSegment | ChatTextSegment | ChatMapSegment;
|
|
36
|
+
/**
|
|
37
|
+
* Splits chat message content into markdown, image prompt, and map segments while preserving their order.
|
|
38
|
+
*
|
|
39
|
+
* @private internal helper of `<ChatMessageItem/>`
|
|
40
|
+
*/
|
|
41
|
+
export declare function splitMessageContentIntoSegments(content: string): ReadonlyArray<ChatMessageContentSegment>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { string_javascript_name } from '../../_packages/types.index';
|
|
2
1
|
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
3
|
-
import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
4
2
|
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
5
3
|
/**
|
|
6
4
|
* USE IMAGE GENERATOR commitment definition
|
|
7
5
|
*
|
|
8
|
-
* The `USE IMAGE GENERATOR` commitment indicates that the agent
|
|
9
|
-
*
|
|
6
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent can output
|
|
7
|
+
* markdown placeholders for UI-driven image generation.
|
|
10
8
|
*
|
|
11
9
|
* Example usage in agent source:
|
|
12
10
|
*
|
|
@@ -19,6 +17,7 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
|
19
17
|
*/
|
|
20
18
|
export declare class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition<'USE IMAGE GENERATOR' | 'USE IMAGE GENERATION' | 'IMAGE GENERATOR' | 'IMAGE GENERATION' | 'USE IMAGE'> {
|
|
21
19
|
constructor(type?: 'USE IMAGE GENERATOR' | 'USE IMAGE GENERATION' | 'IMAGE GENERATOR' | 'IMAGE GENERATION' | 'USE IMAGE');
|
|
20
|
+
get requiresContent(): boolean;
|
|
22
21
|
/**
|
|
23
22
|
* Short one-line description of USE IMAGE GENERATOR.
|
|
24
23
|
*/
|
|
@@ -32,14 +31,6 @@ export declare class UseImageGeneratorCommitmentDefinition extends BaseCommitmen
|
|
|
32
31
|
*/
|
|
33
32
|
get documentation(): string;
|
|
34
33
|
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
35
|
-
/**
|
|
36
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
37
|
-
*/
|
|
38
|
-
getToolTitles(): Record<string_javascript_name, string>;
|
|
39
|
-
/**
|
|
40
|
-
* Gets the `generate_image` tool function implementation.
|
|
41
|
-
*/
|
|
42
|
-
getToolFunctions(): Record<string_javascript_name, ToolFunction>;
|
|
43
34
|
}
|
|
44
35
|
/**
|
|
45
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplifies knowledge labels for UI chips by:
|
|
3
|
+
* - extracting filename from URL/path-like values,
|
|
4
|
+
* - removing extension,
|
|
5
|
+
* - removing trailing random ID segment when detected,
|
|
6
|
+
* - truncating to 20 characters with ellipsis.
|
|
7
|
+
*
|
|
8
|
+
* @param label - Raw knowledge label or source value.
|
|
9
|
+
* @returns Display-friendly chip label.
|
|
10
|
+
* @private utility of knowledge/source chip rendering
|
|
11
|
+
*/
|
|
12
|
+
export declare function simplifyKnowledgeLabel(label: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Heuristic that classifies a short text as human-readable, identifier-like, or unknown.
|
|
15
|
+
*
|
|
16
|
+
* @param text - Candidate value (typically a filename segment).
|
|
17
|
+
* @returns `'HUMAN'`, `'ID'`, or `'UNKNOWN'`.
|
|
18
|
+
* @private utility of knowledge/source chip rendering
|
|
19
|
+
*/
|
|
20
|
+
export declare function isHumanOrID(text: string): 'HUMAN' | 'ID' | 'UNKNOWN';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.
|
|
18
|
+
* It follows semantic versioning (e.g., `0.111.0-1`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/wizard",
|
|
3
|
-
"version": "0.111.0-
|
|
3
|
+
"version": "0.111.0-2",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"module": "./esm/index.es.js",
|
|
99
99
|
"typings": "./esm/typings/src/_packages/wizard.index.d.ts",
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@promptbook/core": "0.111.0-
|
|
101
|
+
"@promptbook/core": "0.111.0-2"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"@ai-sdk/deepseek": "0.1.17",
|
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
* @generated
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-
|
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-2';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22090,8 +22090,8 @@
|
|
|
22090
22090
|
/**
|
|
22091
22091
|
* USE IMAGE GENERATOR commitment definition
|
|
22092
22092
|
*
|
|
22093
|
-
* The `USE IMAGE GENERATOR` commitment indicates that the agent
|
|
22094
|
-
*
|
|
22093
|
+
* The `USE IMAGE GENERATOR` commitment indicates that the agent can output
|
|
22094
|
+
* markdown placeholders for UI-driven image generation.
|
|
22095
22095
|
*
|
|
22096
22096
|
* Example usage in agent source:
|
|
22097
22097
|
*
|
|
@@ -22106,11 +22106,14 @@
|
|
|
22106
22106
|
constructor(type = 'USE IMAGE GENERATOR') {
|
|
22107
22107
|
super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
|
|
22108
22108
|
}
|
|
22109
|
+
get requiresContent() {
|
|
22110
|
+
return false;
|
|
22111
|
+
}
|
|
22109
22112
|
/**
|
|
22110
22113
|
* Short one-line description of USE IMAGE GENERATOR.
|
|
22111
22114
|
*/
|
|
22112
22115
|
get description() {
|
|
22113
|
-
return 'Enable the agent to
|
|
22116
|
+
return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
|
|
22114
22117
|
}
|
|
22115
22118
|
/**
|
|
22116
22119
|
* Icon for this commitment.
|
|
@@ -22125,21 +22128,21 @@
|
|
|
22125
22128
|
return spaceTrim$1.spaceTrim(`
|
|
22126
22129
|
# USE IMAGE GENERATOR
|
|
22127
22130
|
|
|
22128
|
-
Enables the agent to
|
|
22131
|
+
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
22129
22132
|
|
|
22130
22133
|
## Key aspects
|
|
22131
22134
|
|
|
22132
22135
|
- The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
|
|
22133
|
-
- The
|
|
22134
|
-
-
|
|
22135
|
-
-
|
|
22136
|
+
- The agent does **not** call an image-generation tool directly.
|
|
22137
|
+
- The agent inserts markdown notation: \`\`.
|
|
22138
|
+
- The user interface detects the notation and generates the image asynchronously.
|
|
22136
22139
|
|
|
22137
22140
|
## Examples
|
|
22138
22141
|
|
|
22139
22142
|
\`\`\`book
|
|
22140
22143
|
Visual Artist
|
|
22141
22144
|
|
|
22142
|
-
PERSONA You are a creative visual artist
|
|
22145
|
+
PERSONA You are a creative visual artist.
|
|
22143
22146
|
USE IMAGE GENERATOR
|
|
22144
22147
|
RULE Always describe the generated image to the user.
|
|
22145
22148
|
\`\`\`
|
|
@@ -22149,80 +22152,28 @@
|
|
|
22149
22152
|
|
|
22150
22153
|
PERSONA You are an interior designer who helps users visualize their space.
|
|
22151
22154
|
USE IMAGE GENERATOR Professional interior design renders.
|
|
22152
|
-
ACTION
|
|
22155
|
+
ACTION Add one generated image placeholder whenever a user asks for a visual.
|
|
22153
22156
|
\`\`\`
|
|
22154
22157
|
`);
|
|
22155
22158
|
}
|
|
22156
22159
|
applyToAgentModelRequirements(requirements, content) {
|
|
22157
|
-
|
|
22158
|
-
const existingTools = requirements.tools || [];
|
|
22159
|
-
// Add 'generate_image' to tools if not already present
|
|
22160
|
-
const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
|
|
22161
|
-
? existingTools
|
|
22162
|
-
: [
|
|
22163
|
-
...existingTools,
|
|
22164
|
-
{
|
|
22165
|
-
name: 'generate_image',
|
|
22166
|
-
description: spaceTrim$1.spaceTrim(`
|
|
22167
|
-
Generate an image from a text prompt.
|
|
22168
|
-
Use this tool when the user asks to create, draw, or generate an image.
|
|
22169
|
-
${!content ? '' : `Style instructions / guidelines: ${content}`}
|
|
22170
|
-
`),
|
|
22171
|
-
parameters: {
|
|
22172
|
-
type: 'object',
|
|
22173
|
-
properties: {
|
|
22174
|
-
prompt: {
|
|
22175
|
-
type: 'string',
|
|
22176
|
-
description: 'The detailed description of the image to generate',
|
|
22177
|
-
},
|
|
22178
|
-
},
|
|
22179
|
-
required: ['prompt'],
|
|
22180
|
-
},
|
|
22181
|
-
},
|
|
22182
|
-
];
|
|
22183
|
-
// Return requirements with updated tools and metadata
|
|
22160
|
+
const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
|
|
22184
22161
|
return this.appendToSystemMessage({
|
|
22185
22162
|
...requirements,
|
|
22186
|
-
tools: updatedTools,
|
|
22187
22163
|
_metadata: {
|
|
22188
22164
|
...requirements._metadata,
|
|
22189
22165
|
useImageGenerator: content || true,
|
|
22190
22166
|
},
|
|
22191
|
-
}, spaceTrim$1.spaceTrim(`
|
|
22192
|
-
|
|
22193
|
-
|
|
22194
|
-
|
|
22195
|
-
|
|
22196
|
-
|
|
22197
|
-
|
|
22198
|
-
|
|
22199
|
-
|
|
22200
|
-
|
|
22201
|
-
generate_image: 'Generate image',
|
|
22202
|
-
};
|
|
22203
|
-
}
|
|
22204
|
-
/**
|
|
22205
|
-
* Gets the `generate_image` tool function implementation.
|
|
22206
|
-
*/
|
|
22207
|
-
getToolFunctions() {
|
|
22208
|
-
return {
|
|
22209
|
-
async generate_image(args, ...extra) {
|
|
22210
|
-
console.log('!!!! [Tool] generate_image called', { args });
|
|
22211
|
-
const { prompt } = args;
|
|
22212
|
-
if (!prompt) {
|
|
22213
|
-
throw new Error('Image prompt is required');
|
|
22214
|
-
}
|
|
22215
|
-
const { llmTools } = extra[0] || {};
|
|
22216
|
-
if (!llmTools || !llmTools.callImageGenerationModel) {
|
|
22217
|
-
throw new Error('Image generation is not supported by the current model provider');
|
|
22218
|
-
}
|
|
22219
|
-
const result = await llmTools.callImageGenerationModel({
|
|
22220
|
-
content: prompt,
|
|
22221
|
-
modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
|
|
22222
|
-
});
|
|
22223
|
-
return result.content;
|
|
22224
|
-
},
|
|
22225
|
-
};
|
|
22167
|
+
}, spaceTrim$1.spaceTrim((block) => `
|
|
22168
|
+
Image generation:
|
|
22169
|
+
- You do not generate images directly and you do not call any image tool.
|
|
22170
|
+
- When the user asks for an image, include markdown notation in your message:
|
|
22171
|
+
\`\`
|
|
22172
|
+
- Keep \`<alt text>\` short and descriptive.
|
|
22173
|
+
- Keep \`<prompt>\` detailed so the generated image matches the request.
|
|
22174
|
+
- You can include normal explanatory text before and after the notation.
|
|
22175
|
+
${block(extraInstructions)}
|
|
22176
|
+
`));
|
|
22226
22177
|
}
|
|
22227
22178
|
}
|
|
22228
22179
|
/**
|
|
@@ -31982,7 +31933,6 @@
|
|
|
31982
31933
|
doneReading = !!done;
|
|
31983
31934
|
if (value) {
|
|
31984
31935
|
const textChunk = decoder.decode(value, { stream: true });
|
|
31985
|
-
let sawToolCalls = false;
|
|
31986
31936
|
let hasNonEmptyText = false;
|
|
31987
31937
|
const textLines = [];
|
|
31988
31938
|
const lines = textChunk.split(/\r?\n/);
|
|
@@ -32008,7 +31958,6 @@
|
|
|
32008
31958
|
rawResponse: {},
|
|
32009
31959
|
toolCalls: getActiveToolCalls(),
|
|
32010
31960
|
});
|
|
32011
|
-
sawToolCalls = true;
|
|
32012
31961
|
isToolCallLine = true;
|
|
32013
31962
|
}
|
|
32014
31963
|
}
|
|
@@ -32018,22 +31967,16 @@
|
|
|
32018
31967
|
}
|
|
32019
31968
|
if (!isToolCallLine) {
|
|
32020
31969
|
textLines.push(line);
|
|
32021
|
-
if (
|
|
31970
|
+
if (trimmedLine.length > 0) {
|
|
32022
31971
|
hasNonEmptyText = true;
|
|
32023
31972
|
}
|
|
32024
31973
|
}
|
|
32025
31974
|
}
|
|
32026
|
-
if (
|
|
32027
|
-
|
|
32028
|
-
continue;
|
|
32029
|
-
}
|
|
32030
|
-
const textChunkWithoutToolCalls = textLines.join('\n');
|
|
32031
|
-
content += textChunkWithoutToolCalls;
|
|
32032
|
-
}
|
|
32033
|
-
else {
|
|
32034
|
-
// console.debug('RemoteAgent chunk:', textChunk);
|
|
32035
|
-
content += textChunk;
|
|
31975
|
+
if (!hasNonEmptyText) {
|
|
31976
|
+
continue;
|
|
32036
31977
|
}
|
|
31978
|
+
const textChunkWithoutToolCalls = textLines.join('\n');
|
|
31979
|
+
content += textChunkWithoutToolCalls;
|
|
32037
31980
|
if (!hasReceivedModelOutput && content.trim().length > 0) {
|
|
32038
31981
|
hasReceivedModelOutput = true;
|
|
32039
31982
|
preparationToolCalls.length = 0;
|