@promptbook/legacy-documents 0.80.0-1 → 0.81.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/README.md +3 -0
- package/esm/index.es.js +150 -19
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +15 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -6
- package/esm/typings/src/_packages/editable.index.d.ts +10 -0
- package/esm/typings/src/_packages/templates.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +10 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
- package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
- package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +21 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +7 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +8 -0
- package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
- package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
- package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
- package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
- package/esm/typings/src/version.d.ts +7 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +2 -2
- package/umd/index.umd.js +150 -19
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
- /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
|
@@ -19,6 +19,7 @@ export declare const pdfScraperMetadata: import("type-fest/source/readonly-deep"
|
|
|
19
19
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
20
20
|
*
|
|
21
21
|
* @public exported from `@promptbook/core`
|
|
22
|
+
* @public exported from `@promptbook/wizzard`
|
|
22
23
|
* @public exported from `@promptbook/cli`
|
|
23
24
|
*/
|
|
24
25
|
export declare const _PdfScraperMetadataRegistration: Registration;
|
|
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
|
|
|
5
5
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6
6
|
*
|
|
7
7
|
* @public exported from `@promptbook/website-crawler`
|
|
8
|
+
* @public exported from `@promptbook/wizzard`
|
|
8
9
|
* @public exported from `@promptbook/cli`
|
|
9
10
|
*/
|
|
10
11
|
export declare const _WebsiteScraperRegistration: Registration;
|
|
@@ -19,6 +19,7 @@ export declare const websiteScraperMetadata: import("type-fest/source/readonly-d
|
|
|
19
19
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
20
20
|
*
|
|
21
21
|
* @public exported from `@promptbook/core`
|
|
22
|
+
* @public exported from `@promptbook/wizzard`
|
|
22
23
|
* @public exported from `@promptbook/cli`
|
|
23
24
|
*/
|
|
24
25
|
export declare const _WebsiteScraperMetadataRegistration: Registration;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TupleToUnion } from 'type-fest';
|
|
2
2
|
import { RESERVED_PARAMETER_NAMES } from '../constants';
|
|
3
|
+
import type { really_unknown } from '../utils/organization/really_unknown';
|
|
3
4
|
/**
|
|
4
5
|
* Semantic helper
|
|
5
6
|
*/
|
|
@@ -107,6 +108,13 @@ export type string_parameter_value = string;
|
|
|
107
108
|
* @see https://ptbk.io/parameters
|
|
108
109
|
*/
|
|
109
110
|
export type Parameters = Exclude<Record<string_parameter_name, string_parameter_value>, ReservedParameters>;
|
|
111
|
+
/**
|
|
112
|
+
* Parameters to pass to execution of the pipeline
|
|
113
|
+
*
|
|
114
|
+
* Note: [🚉] This should be fully serializable as JSON
|
|
115
|
+
* @see https://ptbk.io/parameters
|
|
116
|
+
*/
|
|
117
|
+
export type InputParameters = Exclude<Record<string_parameter_name, really_unknown>, ReservedParameters>;
|
|
110
118
|
/**
|
|
111
119
|
* Semantic helper
|
|
112
120
|
* Unique identifier of reserved parameter
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ErrorJson } from '../../../errors/utils/ErrorJson';
|
|
2
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { string_date_iso8601 } from '../../../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single pipeline in PromptbookStudio
|
|
6
|
+
*
|
|
7
|
+
* This is simple extension of PipelineJson with additional metadata
|
|
8
|
+
* Note: There are two similar entities:
|
|
9
|
+
* 1) Type (interface) `PipelineEditableSerialized` which represents just data in database
|
|
10
|
+
* 2) Class `PipelineEditable` which implements `PipelineEditableSerialized` and adds error handling and editing capabilities
|
|
11
|
+
*
|
|
12
|
+
* @public exported from `@promptbook/editable`
|
|
13
|
+
*/
|
|
14
|
+
export type PipelineEditableSerialized = PipelineJson & {
|
|
15
|
+
/**
|
|
16
|
+
* When was the pipeline created
|
|
17
|
+
*/
|
|
18
|
+
readonly createdAt: string_date_iso8601;
|
|
19
|
+
/**
|
|
20
|
+
* When was the pipeline last modified
|
|
21
|
+
*/
|
|
22
|
+
readonly updatedAt: string_date_iso8601 | null;
|
|
23
|
+
/**
|
|
24
|
+
* Known errors to transfer to new PipelineEditable
|
|
25
|
+
*/
|
|
26
|
+
readonly knownErrors: Array<ErrorJson>;
|
|
27
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandType } from '
|
|
2
|
-
import type { PipelineString } from '
|
|
1
|
+
import type { CommandType } from '../../../commands/_common/types/CommandType';
|
|
2
|
+
import type { PipelineString } from '../../../pipeline/PipelineString';
|
|
3
3
|
/**
|
|
4
4
|
* Options for `removePipelineCommand`
|
|
5
5
|
*/
|
|
@@ -16,7 +16,7 @@ type RemovePipelineCommandOptions = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
18
18
|
*
|
|
19
|
-
* @public exported from `@promptbook/
|
|
19
|
+
* @public exported from `@promptbook/editable`
|
|
20
20
|
*/
|
|
21
21
|
export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
|
|
22
22
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PipelineJson } from '
|
|
2
|
-
import type { string_name } from '
|
|
1
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { string_name } from '../../../types/typeAliases';
|
|
3
3
|
type RenameParameterOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* Pipeline to search and replace for parameters
|
|
@@ -20,7 +20,7 @@ type RenameParameterOptions = {
|
|
|
20
20
|
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
21
21
|
*
|
|
22
22
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
23
|
-
* @public exported from `@promptbook/
|
|
23
|
+
* @public exported from `@promptbook/editable`
|
|
24
24
|
*/
|
|
25
25
|
export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
|
|
26
26
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { string_json } from '
|
|
1
|
+
import type { string_json } from '../../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Stringify the PipelineJson with proper formatting
|
|
4
4
|
*
|
|
5
5
|
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
6
6
|
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
7
7
|
*
|
|
8
|
-
* @public exported from `@promptbook/
|
|
8
|
+
* @public exported from `@promptbook/editable`
|
|
9
9
|
*/
|
|
10
10
|
export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
|
|
11
11
|
/**
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
2
|
import type { string_template } from '../../types/typeAliases';
|
|
3
|
+
import type { really_unknown } from '../organization/really_unknown';
|
|
3
4
|
/**
|
|
4
5
|
* Replaces parameters in template with values from parameters object
|
|
5
6
|
*
|
|
7
|
+
* Note: This function is not places strings into string,
|
|
8
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
9
|
+
*
|
|
6
10
|
* @param template the template with parameters in {curly} braces
|
|
7
11
|
* @param parameters the object with parameters
|
|
8
12
|
* @returns the template with replaced parameters
|
|
9
13
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
10
14
|
* @public exported from `@promptbook/utils`
|
|
11
15
|
*/
|
|
12
|
-
export declare function
|
|
16
|
+
export declare function templateParameters(template: string_template, parameters: Record<string_parameter_name, really_unknown>): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { string_parameter_value } from '../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../organization/really_unknown';
|
|
3
|
+
/**
|
|
4
|
+
* Function `valueToString` will convert the given value to string
|
|
5
|
+
* This is useful and used in the `templateParameters` function
|
|
6
|
+
*
|
|
7
|
+
* Note: This function is not just calling `toString` method
|
|
8
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
9
|
+
* See `VALUE_STRINGS`
|
|
10
|
+
*
|
|
11
|
+
* Note: There are 2 similar functions
|
|
12
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
13
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
14
|
+
*
|
|
15
|
+
* @public exported from `@promptbook/utils`
|
|
16
|
+
*/
|
|
17
|
+
export declare function valueToString(value: really_unknown): string_parameter_value;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,10 @@ import type { really_any } from '../organization/really_any';
|
|
|
6
6
|
* For example:
|
|
7
7
|
* - `Date` objects will be converted to string
|
|
8
8
|
*
|
|
9
|
+
* Note: There are 2 similar functions
|
|
10
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
11
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
12
|
+
*
|
|
9
13
|
* @private Internal helper function
|
|
10
14
|
*/
|
|
11
15
|
export declare function asSerializable(value: really_any): really_any;
|
|
@@ -2,15 +2,22 @@ import type { string_semantic_version } from './types/typeAliases';
|
|
|
2
2
|
/**
|
|
3
3
|
* The version of the Book language
|
|
4
4
|
*
|
|
5
|
+
* @generated
|
|
5
6
|
* @see https://github.com/webgptorg/book
|
|
6
7
|
*/
|
|
7
8
|
export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
8
9
|
/**
|
|
9
10
|
* The version of the Promptbook engine
|
|
10
11
|
*
|
|
12
|
+
* @generated
|
|
11
13
|
* @see https://github.com/webgptorg/promptbook
|
|
12
14
|
*/
|
|
13
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
|
+
/**
|
|
17
|
+
* @@@
|
|
18
|
+
*
|
|
19
|
+
* @generated
|
|
20
|
+
*/
|
|
14
21
|
export type string_promptbook_version = string_semantic_version;
|
|
15
22
|
/**
|
|
16
23
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Promisable } from 'type-fest';
|
|
2
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
4
|
+
import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
|
|
5
|
+
import type { PipelineString } from '../pipeline/PipelineString';
|
|
6
|
+
import type { TaskProgress } from '../types/TaskProgress';
|
|
7
|
+
import type { InputParameters } from '../types/typeAliases';
|
|
8
|
+
import type { string_filename } from '../types/typeAliases';
|
|
9
|
+
import type { string_pipeline_url } from '../types/typeAliases';
|
|
10
|
+
/**
|
|
11
|
+
* Look at `wizzard` for more details
|
|
12
|
+
*
|
|
13
|
+
* @private just for single instance
|
|
14
|
+
*/
|
|
15
|
+
declare class Wizzard {
|
|
16
|
+
/**
|
|
17
|
+
* @@@!!!!!!
|
|
18
|
+
*/
|
|
19
|
+
execute(book: string_pipeline_url, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
|
|
20
|
+
private executionTools;
|
|
21
|
+
/**
|
|
22
|
+
* @@@!!!
|
|
23
|
+
*
|
|
24
|
+
* @param pipelineSource
|
|
25
|
+
*/
|
|
26
|
+
getExecutionTools(): Promise<ExecutionTools>;
|
|
27
|
+
/**
|
|
28
|
+
* TODO: Make standalone function from this exported from node and used here and in `ptbk run`
|
|
29
|
+
* @@@!!!
|
|
30
|
+
*
|
|
31
|
+
* Strategies:
|
|
32
|
+
* 1) @@@!!!
|
|
33
|
+
* 2) @@@!!!
|
|
34
|
+
*
|
|
35
|
+
* @param pipelineSource
|
|
36
|
+
*/
|
|
37
|
+
getPipeline(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 🧙♂️ @@@
|
|
41
|
+
*
|
|
42
|
+
* @singleton
|
|
43
|
+
* @public exported from `@promptbook/wizzard`
|
|
44
|
+
*/
|
|
45
|
+
export declare const wizzard: Wizzard;
|
|
46
|
+
export {};
|
|
47
|
+
/**
|
|
48
|
+
* TODO: !!!!!! Mark in jsdoc as non-pure
|
|
49
|
+
* TODO: !!!!!! Add to readmes - one markdown here imported in all packages
|
|
50
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
51
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/legacy-documents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0-11",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.
|
|
57
|
+
"@promptbook/core": "0.81.0-11"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -15,15 +15,17 @@
|
|
|
15
15
|
/**
|
|
16
16
|
* The version of the Book language
|
|
17
17
|
*
|
|
18
|
+
* @generated
|
|
18
19
|
* @see https://github.com/webgptorg/book
|
|
19
20
|
*/
|
|
20
21
|
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
21
22
|
/**
|
|
22
23
|
* The version of the Promptbook engine
|
|
23
24
|
*
|
|
25
|
+
* @generated
|
|
24
26
|
* @see https://github.com/webgptorg/promptbook
|
|
25
27
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-10';
|
|
27
29
|
/**
|
|
28
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -195,6 +197,26 @@
|
|
|
195
197
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
196
198
|
*/
|
|
197
199
|
var LOOP_LIMIT = 1000;
|
|
200
|
+
/**
|
|
201
|
+
* Strings to represent various values in the context of parameter values
|
|
202
|
+
*
|
|
203
|
+
* @public exported from `@promptbook/utils`
|
|
204
|
+
*/
|
|
205
|
+
var VALUE_STRINGS = {
|
|
206
|
+
empty: '(nothing; empty string)',
|
|
207
|
+
null: '(no value; null)',
|
|
208
|
+
undefined: '(unknown value; undefined)',
|
|
209
|
+
nan: '(not a number; NaN)',
|
|
210
|
+
infinity: '(infinity; ∞)',
|
|
211
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
212
|
+
unserializable: '(unserializable value)',
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Small number limit
|
|
216
|
+
*
|
|
217
|
+
* @public exported from `@promptbook/utils`
|
|
218
|
+
*/
|
|
219
|
+
var SMALL_NUMBER = 0.001;
|
|
198
220
|
/**
|
|
199
221
|
* Short time interval to prevent race conditions in milliseconds
|
|
200
222
|
*
|
|
@@ -1063,7 +1085,7 @@
|
|
|
1063
1085
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1064
1086
|
*/
|
|
1065
1087
|
|
|
1066
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1088
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n\\`\\`\\`json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1067
1089
|
|
|
1068
1090
|
/**
|
|
1069
1091
|
* Prettify the html code
|
|
@@ -1553,6 +1575,7 @@
|
|
|
1553
1575
|
* @public exported from `@promptbook/core`
|
|
1554
1576
|
*/
|
|
1555
1577
|
var ORDER_OF_PIPELINE_JSON = [
|
|
1578
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
1556
1579
|
'title',
|
|
1557
1580
|
'pipelineUrl',
|
|
1558
1581
|
'bookVersion',
|
|
@@ -1564,6 +1587,7 @@
|
|
|
1564
1587
|
'preparations',
|
|
1565
1588
|
'knowledgeSources',
|
|
1566
1589
|
'knowledgePieces',
|
|
1590
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
1567
1591
|
];
|
|
1568
1592
|
/**
|
|
1569
1593
|
* Nonce which is used for replacing things in strings
|
|
@@ -1751,9 +1775,6 @@
|
|
|
1751
1775
|
if (!url.startsWith('https://')) {
|
|
1752
1776
|
return false;
|
|
1753
1777
|
}
|
|
1754
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1755
|
-
return false;
|
|
1756
|
-
}
|
|
1757
1778
|
if (url.includes('#')) {
|
|
1758
1779
|
// TODO: [🐠]
|
|
1759
1780
|
return false;
|
|
@@ -2499,6 +2520,81 @@
|
|
|
2499
2520
|
* - [♨] Are tasks prepared
|
|
2500
2521
|
*/
|
|
2501
2522
|
|
|
2523
|
+
/**
|
|
2524
|
+
* Format either small or big number
|
|
2525
|
+
*
|
|
2526
|
+
* @public exported from `@promptbook/utils`
|
|
2527
|
+
*/
|
|
2528
|
+
function numberToString(value) {
|
|
2529
|
+
if (value === 0) {
|
|
2530
|
+
return '0';
|
|
2531
|
+
}
|
|
2532
|
+
else if (Number.isNaN(value)) {
|
|
2533
|
+
return VALUE_STRINGS.nan;
|
|
2534
|
+
}
|
|
2535
|
+
else if (value === Infinity) {
|
|
2536
|
+
return VALUE_STRINGS.infinity;
|
|
2537
|
+
}
|
|
2538
|
+
else if (value === -Infinity) {
|
|
2539
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2540
|
+
}
|
|
2541
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
2542
|
+
var factor = Math.pow(10, exponent);
|
|
2543
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
2544
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2545
|
+
return valueRounded.toFixed(exponent);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
return value.toString();
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* Function `valueToString` will convert the given value to string
|
|
2553
|
+
* This is useful and used in the `templateParameters` function
|
|
2554
|
+
*
|
|
2555
|
+
* Note: This function is not just calling `toString` method
|
|
2556
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2557
|
+
* See `VALUE_STRINGS`
|
|
2558
|
+
*
|
|
2559
|
+
* Note: There are 2 similar functions
|
|
2560
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2561
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2562
|
+
*
|
|
2563
|
+
* @public exported from `@promptbook/utils`
|
|
2564
|
+
*/
|
|
2565
|
+
function valueToString(value) {
|
|
2566
|
+
try {
|
|
2567
|
+
if (value === '') {
|
|
2568
|
+
return VALUE_STRINGS.empty;
|
|
2569
|
+
}
|
|
2570
|
+
else if (value === null) {
|
|
2571
|
+
return VALUE_STRINGS.null;
|
|
2572
|
+
}
|
|
2573
|
+
else if (value === undefined) {
|
|
2574
|
+
return VALUE_STRINGS.undefined;
|
|
2575
|
+
}
|
|
2576
|
+
else if (typeof value === 'string') {
|
|
2577
|
+
return value;
|
|
2578
|
+
}
|
|
2579
|
+
else if (typeof value === 'number') {
|
|
2580
|
+
return numberToString(value);
|
|
2581
|
+
}
|
|
2582
|
+
else if (value instanceof Date) {
|
|
2583
|
+
return value.toISOString();
|
|
2584
|
+
}
|
|
2585
|
+
else {
|
|
2586
|
+
return JSON.stringify(value);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
catch (error) {
|
|
2590
|
+
if (!(error instanceof Error)) {
|
|
2591
|
+
throw error;
|
|
2592
|
+
}
|
|
2593
|
+
console.error(error);
|
|
2594
|
+
return VALUE_STRINGS.unserializable;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2502
2598
|
/**
|
|
2503
2599
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
2504
2600
|
*
|
|
@@ -3499,6 +3595,30 @@
|
|
|
3499
3595
|
return mimeTypes.lookup(value) || 'application/octet-stream';
|
|
3500
3596
|
}
|
|
3501
3597
|
|
|
3598
|
+
/**
|
|
3599
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3600
|
+
*
|
|
3601
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
3602
|
+
*/
|
|
3603
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3604
|
+
var error_1;
|
|
3605
|
+
return __generator(this, function (_a) {
|
|
3606
|
+
switch (_a.label) {
|
|
3607
|
+
case 0:
|
|
3608
|
+
_a.trys.push([0, 2, , 3]);
|
|
3609
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
3610
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3611
|
+
case 2:
|
|
3612
|
+
error_1 = _a.sent();
|
|
3613
|
+
if (!(error_1 instanceof Error)) {
|
|
3614
|
+
throw error_1;
|
|
3615
|
+
}
|
|
3616
|
+
throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
3617
|
+
case 3: return [2 /*return*/];
|
|
3618
|
+
}
|
|
3619
|
+
});
|
|
3620
|
+
}); };
|
|
3621
|
+
|
|
3502
3622
|
/**
|
|
3503
3623
|
* @@@
|
|
3504
3624
|
*
|
|
@@ -3507,13 +3627,14 @@
|
|
|
3507
3627
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3508
3628
|
var _a;
|
|
3509
3629
|
return __awaiter(this, void 0, void 0, function () {
|
|
3510
|
-
var sourceContent, name,
|
|
3511
|
-
return __generator(this, function (
|
|
3512
|
-
switch (
|
|
3630
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3631
|
+
return __generator(this, function (_f) {
|
|
3632
|
+
switch (_f.label) {
|
|
3513
3633
|
case 0:
|
|
3634
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3514
3635
|
sourceContent = knowledgeSource.sourceContent;
|
|
3515
3636
|
name = knowledgeSource.name;
|
|
3516
|
-
|
|
3637
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3517
3638
|
if (!name) {
|
|
3518
3639
|
name = sourceContentToName(sourceContent);
|
|
3519
3640
|
}
|
|
@@ -3521,7 +3642,7 @@
|
|
|
3521
3642
|
url = sourceContent;
|
|
3522
3643
|
return [4 /*yield*/, fetch(url)];
|
|
3523
3644
|
case 1:
|
|
3524
|
-
response_1 =
|
|
3645
|
+
response_1 = _f.sent();
|
|
3525
3646
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3526
3647
|
return [2 /*return*/, {
|
|
3527
3648
|
source: name,
|
|
@@ -3578,7 +3699,7 @@
|
|
|
3578
3699
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3579
3700
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3580
3701
|
case 3:
|
|
3581
|
-
if (!(
|
|
3702
|
+
if (!(_f.sent())) {
|
|
3582
3703
|
throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3583
3704
|
}
|
|
3584
3705
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -4609,13 +4730,16 @@
|
|
|
4609
4730
|
/**
|
|
4610
4731
|
* Replaces parameters in template with values from parameters object
|
|
4611
4732
|
*
|
|
4733
|
+
* Note: This function is not places strings into string,
|
|
4734
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4735
|
+
*
|
|
4612
4736
|
* @param template the template with parameters in {curly} braces
|
|
4613
4737
|
* @param parameters the object with parameters
|
|
4614
4738
|
* @returns the template with replaced parameters
|
|
4615
4739
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
4616
4740
|
* @public exported from `@promptbook/utils`
|
|
4617
4741
|
*/
|
|
4618
|
-
function
|
|
4742
|
+
function templateParameters(template, parameters) {
|
|
4619
4743
|
var e_1, _a;
|
|
4620
4744
|
try {
|
|
4621
4745
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -4641,7 +4765,7 @@
|
|
|
4641
4765
|
var loopLimit = LOOP_LIMIT;
|
|
4642
4766
|
var _loop_1 = function () {
|
|
4643
4767
|
if (loopLimit-- < 0) {
|
|
4644
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
4768
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
4645
4769
|
}
|
|
4646
4770
|
var precol = match.groups.precol;
|
|
4647
4771
|
var parameterName = match.groups.parameterName;
|
|
@@ -4658,7 +4782,7 @@
|
|
|
4658
4782
|
if (parameterValue === undefined) {
|
|
4659
4783
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4660
4784
|
}
|
|
4661
|
-
parameterValue = parameterValue
|
|
4785
|
+
parameterValue = valueToString(parameterValue);
|
|
4662
4786
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4663
4787
|
parameterValue = parameterValue
|
|
4664
4788
|
.split('\n')
|
|
@@ -4893,7 +5017,7 @@
|
|
|
4893
5017
|
}
|
|
4894
5018
|
return [3 /*break*/, 24];
|
|
4895
5019
|
case 2:
|
|
4896
|
-
$ongoingTaskResult.$resultString =
|
|
5020
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4897
5021
|
return [3 /*break*/, 25];
|
|
4898
5022
|
case 3:
|
|
4899
5023
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -5016,8 +5140,8 @@
|
|
|
5016
5140
|
_j = $ongoingTaskResult;
|
|
5017
5141
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
5018
5142
|
promptTitle: task.title,
|
|
5019
|
-
promptMessage:
|
|
5020
|
-
defaultValue:
|
|
5143
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
5144
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
5021
5145
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
5022
5146
|
placeholder: undefined,
|
|
5023
5147
|
priority: priority,
|
|
@@ -5141,7 +5265,7 @@
|
|
|
5141
5265
|
if (!isJokerAttempt &&
|
|
5142
5266
|
task.taskType === 'PROMPT_TASK' &&
|
|
5143
5267
|
$ongoingTaskResult.$prompt
|
|
5144
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
5268
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
5145
5269
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
5146
5270
|
) {
|
|
5147
5271
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5718,7 +5842,10 @@
|
|
|
5718
5842
|
finally { if (e_2) throw e_2.error; }
|
|
5719
5843
|
return [7 /*endfinally*/];
|
|
5720
5844
|
case 19:
|
|
5721
|
-
parametersToPass = inputParameters
|
|
5845
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5846
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5847
|
+
return [key, valueToString(value)];
|
|
5848
|
+
}));
|
|
5722
5849
|
_g.label = 20;
|
|
5723
5850
|
case 20:
|
|
5724
5851
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5973,6 +6100,7 @@
|
|
|
5973
6100
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5974
6101
|
*
|
|
5975
6102
|
* @public exported from `@promptbook/core`
|
|
6103
|
+
* @public exported from `@promptbook/wizzard`
|
|
5976
6104
|
* @public exported from `@promptbook/cli`
|
|
5977
6105
|
*/
|
|
5978
6106
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
@@ -6170,6 +6298,7 @@
|
|
|
6170
6298
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6171
6299
|
*
|
|
6172
6300
|
* @public exported from `@promptbook/core`
|
|
6301
|
+
* @public exported from `@promptbook/wizzard`
|
|
6173
6302
|
* @public exported from `@promptbook/cli`
|
|
6174
6303
|
*/
|
|
6175
6304
|
$scrapersMetadataRegister.register(documentScraperMetadata);
|
|
@@ -6337,6 +6466,7 @@
|
|
|
6337
6466
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6338
6467
|
*
|
|
6339
6468
|
* @public exported from `@promptbook/core`
|
|
6469
|
+
* @public exported from `@promptbook/wizzard`
|
|
6340
6470
|
* @public exported from `@promptbook/cli`
|
|
6341
6471
|
*/
|
|
6342
6472
|
$scrapersMetadataRegister.register(legacyDocumentScraperMetadata);
|
|
@@ -6507,6 +6637,7 @@
|
|
|
6507
6637
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6508
6638
|
*
|
|
6509
6639
|
* @public exported from `@promptbook/legacy-documents`
|
|
6640
|
+
* @public exported from `@promptbook/wizzard`
|
|
6510
6641
|
* @public exported from `@promptbook/cli`
|
|
6511
6642
|
*/
|
|
6512
6643
|
var _LegacyDocumentScraperRegistration = $scrapersRegister.register(createLegacyDocumentScraper);
|