@promptbook/editable 0.100.0 → 0.100.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 +14 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +2 -2
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +2 -2
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +2 -2
- package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +2 -2
- package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +2 -2
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +3 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +4 -4
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -6
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +4 -4
- package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +3 -4
- package/esm/typings/src/utils/color/Color.d.ts +1 -2
- package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +2 -2
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +2 -2
- package/package.json +2 -2
- package/umd/index.umd.js +14 -7
- package/umd/index.umd.js.map +1 -1
@@ -1,13 +1,9 @@
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
2
2
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
3
3
|
import type { Prompt } from '../types/Prompt';
|
4
|
-
import type { string_markdown } from '../types/typeAliases';
|
5
|
-
import type { string_markdown_text } from '../types/typeAliases';
|
6
|
-
import type { string_title } from '../types/typeAliases';
|
4
|
+
import type { string_markdown, string_markdown_text, string_title } from '../types/typeAliases';
|
7
5
|
import type { AvailableModel } from './AvailableModel';
|
8
|
-
import type { ChatPromptResult } from './PromptResult';
|
9
|
-
import type { CompletionPromptResult } from './PromptResult';
|
10
|
-
import type { EmbeddingPromptResult } from './PromptResult';
|
6
|
+
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult } from './PromptResult';
|
11
7
|
/**
|
12
8
|
* Container for all the tools needed to execute prompts to large language models like GPT-4
|
13
9
|
* On its interface it exposes common methods for prompt execution.
|
@@ -60,6 +56,7 @@ export type LlmExecutionTools = {
|
|
60
56
|
callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
|
61
57
|
};
|
62
58
|
/**
|
59
|
+
* TODO: [🕛] Extend this from sth class
|
63
60
|
* TODO: [🍚] Implement destroyable pattern to free resources
|
64
61
|
* TODO: [🏳] Add `callTranslationModel`
|
65
62
|
* TODO: [🧠] Emulation of one type of model with another one - emuate chat with completion; emulate translation with chat
|
@@ -5,7 +5,7 @@ import type { string_postprocessing_function_name } from '../../types/typeAliase
|
|
5
5
|
/**
|
6
6
|
* Options for validating a prompt result
|
7
7
|
*/
|
8
|
-
export
|
8
|
+
export type ValidatePromptResultOptions = {
|
9
9
|
/**
|
10
10
|
* The result string to validate
|
11
11
|
*/
|
@@ -23,11 +23,11 @@ export interface ValidatePromptResultOptions {
|
|
23
23
|
* Note: This is for validation purposes only - postprocessing should be done before calling this function
|
24
24
|
*/
|
25
25
|
postprocessingFunctionNames?: ReadonlyArray<string_postprocessing_function_name>;
|
26
|
-
}
|
26
|
+
};
|
27
27
|
/**
|
28
28
|
* Result of prompt result validation
|
29
29
|
*/
|
30
|
-
export
|
30
|
+
export type ValidatePromptResultResult = {
|
31
31
|
/**
|
32
32
|
* Whether the result is valid (passes all expectations and format checks)
|
33
33
|
*/
|
@@ -40,7 +40,7 @@ export interface ValidatePromptResultResult {
|
|
40
40
|
* Error that occurred during validation, if any
|
41
41
|
*/
|
42
42
|
error?: ExpectError;
|
43
|
-
}
|
43
|
+
};
|
44
44
|
/**
|
45
45
|
* Validates a prompt result against expectations and format requirements.
|
46
46
|
* This function provides a common abstraction for result validation that can be used
|
@@ -76,6 +76,6 @@ export declare function getLlmProviderProfile(providerKey: keyof typeof LLM_PROV
|
|
76
76
|
export declare function createCustomLlmProfile(baseProfile: ChatParticipant, overrides: Partial<ChatParticipant>): ChatParticipant;
|
77
77
|
/**
|
78
78
|
* TODO: Refactor this - each profile must be alongside the provider definition
|
79
|
-
* TODO: Unite `AvatarProfileProps`
|
79
|
+
* TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
80
80
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
81
81
|
*/
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import { MODEL_ORDERS } from '../../../constants';
|
2
|
-
import {
|
3
|
-
import type { string_name } from '../../../types/typeAliases';
|
4
|
-
import type { string_title } from '../../../types/typeAliases';
|
1
|
+
import { MODEL_ORDERS, MODEL_TRUST_LEVELS } from '../../../constants';
|
2
|
+
import type { string_name, string_title } from '../../../types/typeAliases';
|
5
3
|
import type { Registered } from '../../../utils/$Register';
|
6
4
|
import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
7
5
|
import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
|
@@ -52,6 +50,7 @@ export type LlmToolsMetadata = Registered & {
|
|
52
50
|
createConfigurationFromEnv(env: Record<string_name, string>): LlmToolsConfiguration[number] | null;
|
53
51
|
};
|
54
52
|
/**
|
53
|
+
* TODO: [🕛] Extend this
|
55
54
|
* TODO: Add configuration schema and maybe some documentation link
|
56
55
|
* TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
|
57
56
|
* TODO: [®] DRY Register logic
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import type { string_color } from '../../types/typeAliases';
|
2
|
-
import type { string_url_image } from '../../types/typeAliases';
|
1
|
+
import type { string_color, string_url_image } from '../../types/typeAliases';
|
3
2
|
import type { WithTake } from '../take/interfaces/ITakeChain';
|
4
3
|
import { CSS_COLORS } from './css-colors';
|
5
4
|
/**
|
@@ -6,7 +6,7 @@ import type { Takeable } from './Takeable';
|
|
6
6
|
* @deprecated [🤡] Use some better functional library instead of `TakeChain`
|
7
7
|
*/
|
8
8
|
export type WithTake<TValue extends Takeable> = TValue & ITakeChain<TValue>;
|
9
|
-
export
|
9
|
+
export type ITakeChain<TValue extends Takeable> = {
|
10
10
|
readonly value: TValue;
|
11
11
|
then<TResultValue extends Takeable>(callback: (value: TValue) => TResultValue): WithTake<TResultValue>;
|
12
|
-
}
|
12
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { string_filename } from '../../../types/typeAliases';
|
2
2
|
import type { really_unknown } from '../../organization/really_unknown';
|
3
3
|
/**
|
4
|
-
* Tests if given string is valid
|
4
|
+
* Tests if given string is valid file path.
|
5
5
|
*
|
6
6
|
* Note: This does not check if the file exists only if the path is valid
|
7
7
|
* @public exported from `@promptbook/utils`
|
@@ -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.100.
|
18
|
+
* It follows semantic versioning (e.g., `0.100.1`).
|
19
19
|
*
|
20
20
|
* @generated
|
21
21
|
*/
|
@@ -9,12 +9,12 @@ import type { string_pipeline_url } from '../types/typeAliases';
|
|
9
9
|
/**
|
10
10
|
* Options for wizard methods
|
11
11
|
*/
|
12
|
-
|
12
|
+
type WizardOptions = {
|
13
13
|
/**
|
14
14
|
* Whether to enable verbose logging
|
15
15
|
*/
|
16
16
|
isVerbose?: boolean;
|
17
|
-
}
|
17
|
+
};
|
18
18
|
/**
|
19
19
|
* Wizard for simple usage of the Promptbook
|
20
20
|
* Look at `wizard` for more details
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@promptbook/editable",
|
3
|
-
"version": "0.100.
|
3
|
+
"version": "0.100.2",
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
5
5
|
"private": false,
|
6
6
|
"sideEffects": false,
|
@@ -95,7 +95,7 @@
|
|
95
95
|
"module": "./esm/index.es.js",
|
96
96
|
"typings": "./esm/typings/src/_packages/editable.index.d.ts",
|
97
97
|
"peerDependencies": {
|
98
|
-
"@promptbook/core": "0.100.
|
98
|
+
"@promptbook/core": "0.100.2"
|
99
99
|
},
|
100
100
|
"dependencies": {
|
101
101
|
"crypto-js": "4.2.0",
|
package/umd/index.umd.js
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
* @generated
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
25
25
|
*/
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.2';
|
27
27
|
/**
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -2477,7 +2477,7 @@
|
|
2477
2477
|
};
|
2478
2478
|
|
2479
2479
|
/**
|
2480
|
-
* Tests if given string is valid
|
2480
|
+
* Tests if given string is valid file path.
|
2481
2481
|
*
|
2482
2482
|
* Note: This does not check if the file exists only if the path is valid
|
2483
2483
|
* @public exported from `@promptbook/utils`
|
@@ -2489,18 +2489,25 @@
|
|
2489
2489
|
if (filename.split('\n').length > 1) {
|
2490
2490
|
return false;
|
2491
2491
|
}
|
2492
|
-
|
2493
|
-
|
2492
|
+
// Normalize slashes early so heuristics can detect path-like inputs
|
2493
|
+
const filenameSlashes = filename.replace(/\\/g, '/');
|
2494
|
+
// Reject strings that look like sentences (informational text)
|
2495
|
+
// Heuristic: contains multiple spaces and ends with a period, or contains typical sentence punctuation
|
2496
|
+
// But skip this heuristic if the string looks like a path (contains '/' or starts with a drive letter)
|
2497
|
+
if (filename.trim().length > 60 && // long enough to be a sentence
|
2498
|
+
/[.!?]/.test(filename) && // contains sentence punctuation
|
2499
|
+
filename.split(' ').length > 8 && // has many words
|
2500
|
+
!/\/|^[A-Z]:/i.test(filenameSlashes) // do NOT treat as sentence if looks like a path
|
2501
|
+
) {
|
2494
2502
|
return false;
|
2495
2503
|
}
|
2496
|
-
const filenameSlashes = filename.split('\\').join('/');
|
2497
2504
|
// Absolute Unix path: /hello.txt
|
2498
2505
|
if (/^(\/)/i.test(filenameSlashes)) {
|
2499
2506
|
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
2500
2507
|
return true;
|
2501
2508
|
}
|
2502
|
-
// Absolute Windows path:
|
2503
|
-
if (/^
|
2509
|
+
// Absolute Windows path: C:/ or C:\ (allow spaces and multiple dots in filename)
|
2510
|
+
if (/^[A-Z]:\/.+$/i.test(filenameSlashes)) {
|
2504
2511
|
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
2505
2512
|
return true;
|
2506
2513
|
}
|