@promptbook/core 0.101.0-7 → 0.101.0-8
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 +64 -2
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +31 -0
- package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +64 -1
- package/umd/index.umd.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
2
|
import { createAgentModelRequirements } from '../book-2.0/agent-source/createAgentModelRequirements';
|
|
3
3
|
import { parseAgentSource } from '../book-2.0/agent-source/parseAgentSource';
|
|
4
|
+
import { parseParameters } from '../book-2.0/agent-source/parseParameters';
|
|
4
5
|
import { isValidBook } from '../book-2.0/agent-source/string_book';
|
|
5
6
|
import { validateBook } from '../book-2.0/agent-source/string_book';
|
|
6
7
|
import { DEFAULT_BOOK } from '../book-2.0/agent-source/string_book';
|
|
@@ -166,6 +167,7 @@ import { REMOTE_SERVER_URLS } from '../../servers';
|
|
|
166
167
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
167
168
|
export { createAgentModelRequirements };
|
|
168
169
|
export { parseAgentSource };
|
|
170
|
+
export { parseParameters };
|
|
169
171
|
export { isValidBook };
|
|
170
172
|
export { validateBook };
|
|
171
173
|
export { DEFAULT_BOOK };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BookParameter } from '../book-2.0/agent-source/AgentBasicInformation';
|
|
1
2
|
import type { AgentBasicInformation } from '../book-2.0/agent-source/AgentBasicInformation';
|
|
2
3
|
import type { AgentModelRequirements } from '../book-2.0/agent-source/AgentModelRequirements';
|
|
3
4
|
import type { string_book } from '../book-2.0/agent-source/string_book';
|
|
@@ -322,6 +323,7 @@ import type { CheckSerializableAsJsonOptions } from '../utils/serialization/chec
|
|
|
322
323
|
import type { ExportJsonOptions } from '../utils/serialization/exportJson';
|
|
323
324
|
import type { ITakeChain } from '../utils/take/interfaces/ITakeChain';
|
|
324
325
|
import type { string_promptbook_version } from '../version';
|
|
326
|
+
export type { BookParameter };
|
|
325
327
|
export type { AgentBasicInformation };
|
|
326
328
|
export type { AgentModelRequirements };
|
|
327
329
|
export type { string_book };
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import type { string_agent_name, string_url_image } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Unified parameter representation that supports two different notations:
|
|
4
|
+
* 1. @Parameter - single word parameter starting with @
|
|
5
|
+
* 2. {parameterName} or {parameter with multiple words} or {parameterName: description text}
|
|
6
|
+
* Both notations represent the same syntax feature - parameters
|
|
7
|
+
*/
|
|
8
|
+
export type BookParameter = {
|
|
9
|
+
/**
|
|
10
|
+
* The raw text of the parameter as it appears in the source
|
|
11
|
+
*/
|
|
12
|
+
text: string;
|
|
13
|
+
/**
|
|
14
|
+
* The notation used for this parameter
|
|
15
|
+
*/
|
|
16
|
+
notation: 'at' | 'brace';
|
|
17
|
+
/**
|
|
18
|
+
* The parameter name (without @ or {})
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional description for {parameterName: description} notation
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
};
|
|
2
26
|
export type AgentBasicInformation = {
|
|
3
27
|
/**
|
|
4
28
|
* Name of the agent
|
|
@@ -15,6 +39,13 @@ export type AgentBasicInformation = {
|
|
|
15
39
|
* This is the line starting with "META IMAGE"
|
|
16
40
|
*/
|
|
17
41
|
profileImageUrl: string_url_image;
|
|
42
|
+
/**
|
|
43
|
+
* Parameters found in the agent source
|
|
44
|
+
* Supports two different notations for the same syntax feature:
|
|
45
|
+
* - @Parameter (single word parameter starting with @)
|
|
46
|
+
* - {parameterName} or {parameter with multiple words} or {parameterName: description text}
|
|
47
|
+
*/
|
|
48
|
+
parameters: BookParameter[];
|
|
18
49
|
};
|
|
19
50
|
/**
|
|
20
51
|
* TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BookParameter } from './AgentBasicInformation';
|
|
2
|
+
/**
|
|
3
|
+
* Parses parameters from text using both supported notations:
|
|
4
|
+
* 1. @Parameter - single word parameter starting with @
|
|
5
|
+
* 2. {parameterName} or {parameter with multiple words} or {parameterName: description text}
|
|
6
|
+
*
|
|
7
|
+
* Both notations represent the same syntax feature - parameters
|
|
8
|
+
*
|
|
9
|
+
* @param text - Text to extract parameters from
|
|
10
|
+
* @returns Array of parsed parameters with unified representation
|
|
11
|
+
* @public exported from `@promptbook/core`
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseParameters(text: string): BookParameter[];
|
|
@@ -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.101.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.101.0-7`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-8';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2232,6 +2232,64 @@
|
|
|
2232
2232
|
return generateGravatarUrl(agentName);
|
|
2233
2233
|
}
|
|
2234
2234
|
|
|
2235
|
+
/**
|
|
2236
|
+
* Parses parameters from text using both supported notations:
|
|
2237
|
+
* 1. @Parameter - single word parameter starting with @
|
|
2238
|
+
* 2. {parameterName} or {parameter with multiple words} or {parameterName: description text}
|
|
2239
|
+
*
|
|
2240
|
+
* Both notations represent the same syntax feature - parameters
|
|
2241
|
+
*
|
|
2242
|
+
* @param text - Text to extract parameters from
|
|
2243
|
+
* @returns Array of parsed parameters with unified representation
|
|
2244
|
+
* @public exported from `@promptbook/core`
|
|
2245
|
+
*/
|
|
2246
|
+
function parseParameters(text) {
|
|
2247
|
+
const parameters = [];
|
|
2248
|
+
// [🧠] Parameter syntax parsing - unified approach for two different notations of the same syntax feature
|
|
2249
|
+
// The Book language supports parameters in two different notations but they represent the same concept
|
|
2250
|
+
// Extract @Parameter notation (single word parameters starting with @)
|
|
2251
|
+
const atParameterRegex = /@[\w\u00C0-\u017F\u0100-\u024F\u1E00-\u1EFF]+/gim;
|
|
2252
|
+
text.replace(atParameterRegex, (match) => {
|
|
2253
|
+
const parameterName = match.slice(1); // Remove the @ symbol
|
|
2254
|
+
parameters.push({
|
|
2255
|
+
text: match,
|
|
2256
|
+
notation: 'at',
|
|
2257
|
+
name: parameterName,
|
|
2258
|
+
});
|
|
2259
|
+
return match;
|
|
2260
|
+
});
|
|
2261
|
+
// Extract {parameter} notation (parameters in braces)
|
|
2262
|
+
const braceParameterRegex = /\{([^}]+)\}/gim;
|
|
2263
|
+
text.replace(braceParameterRegex, (match, content) => {
|
|
2264
|
+
// Check if the parameter has a description (parameterName: description)
|
|
2265
|
+
const colonIndex = content.indexOf(':');
|
|
2266
|
+
if (colonIndex !== -1) {
|
|
2267
|
+
const name = content.substring(0, colonIndex).trim();
|
|
2268
|
+
const description = content.substring(colonIndex + 1).trim();
|
|
2269
|
+
parameters.push({
|
|
2270
|
+
text: match,
|
|
2271
|
+
notation: 'brace',
|
|
2272
|
+
name,
|
|
2273
|
+
description,
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
else {
|
|
2277
|
+
// Simple parameter without description
|
|
2278
|
+
parameters.push({
|
|
2279
|
+
text: match,
|
|
2280
|
+
notation: 'brace',
|
|
2281
|
+
name: content.trim(),
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
return match;
|
|
2285
|
+
});
|
|
2286
|
+
// Remove duplicates based on name (keep the first occurrence)
|
|
2287
|
+
const uniqueParameters = parameters.filter((param, index, array) => {
|
|
2288
|
+
return array.findIndex(p => p.name === param.name) === index;
|
|
2289
|
+
});
|
|
2290
|
+
return uniqueParameters;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2235
2293
|
/**
|
|
2236
2294
|
* Parses basic information from agent source
|
|
2237
2295
|
*
|
|
@@ -2258,10 +2316,14 @@
|
|
|
2258
2316
|
if (!profileImageUrl) {
|
|
2259
2317
|
profileImageUrl = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
|
|
2260
2318
|
}
|
|
2319
|
+
// Parse parameters using unified approach - both @Parameter and {parameter} notations
|
|
2320
|
+
// are treated as the same syntax feature with unified representation
|
|
2321
|
+
const parameters = parseParameters(agentSource);
|
|
2261
2322
|
return {
|
|
2262
2323
|
agentName: parseResult.agentName,
|
|
2263
2324
|
personaDescription,
|
|
2264
2325
|
profileImageUrl,
|
|
2326
|
+
parameters,
|
|
2265
2327
|
};
|
|
2266
2328
|
}
|
|
2267
2329
|
/**
|
|
@@ -14724,6 +14786,7 @@
|
|
|
14724
14786
|
exports.makeKnowledgeSourceHandler = makeKnowledgeSourceHandler;
|
|
14725
14787
|
exports.migratePipeline = migratePipeline;
|
|
14726
14788
|
exports.parseAgentSource = parseAgentSource;
|
|
14789
|
+
exports.parseParameters = parseParameters;
|
|
14727
14790
|
exports.parsePipeline = parsePipeline;
|
|
14728
14791
|
exports.pipelineJsonToString = pipelineJsonToString;
|
|
14729
14792
|
exports.prepareKnowledgePieces = prepareKnowledgePieces;
|