@promptbook/editable 0.89.0-9 → 0.92.0-3
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 +9 -7
- package/esm/index.es.js +106 -12
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +40 -0
- package/esm/typings/src/_packages/core.index.d.ts +10 -4
- package/esm/typings/src/_packages/types.index.d.ts +18 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +16 -3
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
- package/esm/typings/src/config.d.ts +10 -19
- package/esm/typings/src/errors/0-index.d.ts +7 -4
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
- package/esm/typings/src/errors/WrappedError.d.ts +10 -0
- package/esm/typings/src/errors/assertsError.d.ts +11 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
- package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +3 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
- package/esm/typings/src/llm-providers/_common/register/{$provideEnvFilepath.d.ts → $provideEnvFilename.d.ts} +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +11 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/typings/src/remote-server/openapi-types.d.ts +284 -0
- package/esm/typings/src/remote-server/openapi.d.ts +187 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +7 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -9
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
- package/esm/typings/src/types/typeAliases.d.ts +26 -0
- package/package.json +6 -2
- package/umd/index.umd.js +106 -12
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
package/README.md
CHANGED
|
@@ -246,6 +246,10 @@ But unlike programming languages, it is designed to be understandable by non-pro
|
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
|
|
249
|
+
## 🔒 Security
|
|
250
|
+
|
|
251
|
+
For information on reporting security vulnerabilities, see our [Security Policy](./SECURITY.md).
|
|
252
|
+
|
|
249
253
|
## 📦 Packages _(for developers)_
|
|
250
254
|
|
|
251
255
|
This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -302,7 +306,7 @@ The following glossary is used to clarify certain concepts:
|
|
|
302
306
|
### General LLM / AI terms
|
|
303
307
|
|
|
304
308
|
- **Prompt drift** is a phenomenon where the AI model starts to generate outputs that are not aligned with the original prompt. This can happen due to the model's training data, the prompt's wording, or the model's architecture.
|
|
305
|
-
- **Pipeline, workflow or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.
|
|
309
|
+
- [**Pipeline, workflow scenario or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.](https://github.com/webgptorg/promptbook/discussions/88)
|
|
306
310
|
- **Fine-tuning** is a process where a pre-trained AI model is further trained on a specific dataset to improve its performance on a specific task.
|
|
307
311
|
- **Zero-shot learning** is a machine learning paradigm where a model is trained to perform a task without any labeled examples. Instead, the model is provided with a description of the task and is expected to generate the correct output.
|
|
308
312
|
- **Few-shot learning** is a machine learning paradigm where a model is trained to perform a task with only a few labeled examples. This is in contrast to traditional machine learning, where models are trained on large datasets.
|
|
@@ -310,10 +314,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
310
314
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
311
315
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
312
316
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
317
|
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
318
318
|
|
|
319
319
|
|
|
@@ -427,6 +427,8 @@ See [TODO.md](./TODO.md)
|
|
|
427
427
|
|
|
428
428
|
## 🖋️ Contributing
|
|
429
429
|
|
|
430
|
-
We are open to pull requests, feedback, and suggestions.
|
|
430
|
+
You can also ⭐ star the project, [follow us on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).We are open to [pull requests, feedback, and suggestions](./CONTRIBUTING.md).
|
|
431
|
+
|
|
432
|
+
## 📞 Support
|
|
431
433
|
|
|
432
|
-
|
|
434
|
+
If you need help or have questions, please check our [Support Resources](./SUPPORT.md).
|
package/esm/index.es.js
CHANGED
|
@@ -17,7 +17,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
17
17
|
* @generated
|
|
18
18
|
* @see https://github.com/webgptorg/promptbook
|
|
19
19
|
*/
|
|
20
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
20
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-3';
|
|
21
21
|
/**
|
|
22
22
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
23
23
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -63,6 +63,7 @@ const ADMIN_EMAIL = 'pavol@ptbk.io';
|
|
|
63
63
|
* @public exported from `@promptbook/core`
|
|
64
64
|
*/
|
|
65
65
|
const ADMIN_GITHUB_NAME = 'hejny';
|
|
66
|
+
// <- TODO: [🐊] Pick the best claim
|
|
66
67
|
/**
|
|
67
68
|
* When the title is not provided, the default title is used
|
|
68
69
|
*
|
|
@@ -417,6 +418,54 @@ const bookVersionCommandParser = {
|
|
|
417
418
|
},
|
|
418
419
|
};
|
|
419
420
|
|
|
421
|
+
/**
|
|
422
|
+
* This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
|
|
423
|
+
*
|
|
424
|
+
* @public exported from `@promptbook/core`
|
|
425
|
+
*/
|
|
426
|
+
class WrappedError extends Error {
|
|
427
|
+
constructor(whatWasThrown) {
|
|
428
|
+
const tag = `[🤮]`;
|
|
429
|
+
console.error(tag, whatWasThrown);
|
|
430
|
+
super(spaceTrim$1(`
|
|
431
|
+
Non-Error object was thrown
|
|
432
|
+
|
|
433
|
+
Note: Look for ${tag} in the console for more details
|
|
434
|
+
Please report issue on ${ADMIN_EMAIL}
|
|
435
|
+
`));
|
|
436
|
+
this.name = 'WrappedError';
|
|
437
|
+
Object.setPrototypeOf(this, WrappedError.prototype);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Helper used in catch blocks to assert that the error is an instance of `Error`
|
|
443
|
+
*
|
|
444
|
+
* @param whatWasThrown Any object that was thrown
|
|
445
|
+
* @returns Nothing if the error is an instance of `Error`
|
|
446
|
+
* @throws `WrappedError` or `UnexpectedError` if the error is not standard
|
|
447
|
+
*
|
|
448
|
+
* @private within the repository
|
|
449
|
+
*/
|
|
450
|
+
function assertsError(whatWasThrown) {
|
|
451
|
+
// Case 1: Handle error which was rethrown as `WrappedError`
|
|
452
|
+
if (whatWasThrown instanceof WrappedError) {
|
|
453
|
+
const wrappedError = whatWasThrown;
|
|
454
|
+
throw wrappedError;
|
|
455
|
+
}
|
|
456
|
+
// Case 2: Handle unexpected errors
|
|
457
|
+
if (whatWasThrown instanceof UnexpectedError) {
|
|
458
|
+
const unexpectedError = whatWasThrown;
|
|
459
|
+
throw unexpectedError;
|
|
460
|
+
}
|
|
461
|
+
// Case 3: Handle standard errors - keep them up to consumer
|
|
462
|
+
if (whatWasThrown instanceof Error) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
// Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
|
|
466
|
+
throw new WrappedError(whatWasThrown);
|
|
467
|
+
}
|
|
468
|
+
|
|
420
469
|
/**
|
|
421
470
|
* Units of text measurement
|
|
422
471
|
*
|
|
@@ -497,6 +546,8 @@ function parseNumber(value) {
|
|
|
497
546
|
*/
|
|
498
547
|
|
|
499
548
|
/**
|
|
549
|
+
import { WrappedError } from '../../errors/WrappedError';
|
|
550
|
+
import { assertsError } from '../../errors/assertsError';
|
|
500
551
|
* Parses the expect command
|
|
501
552
|
*
|
|
502
553
|
* @see `documentationUrl` for more details
|
|
@@ -588,9 +639,7 @@ const expectCommandParser = {
|
|
|
588
639
|
};
|
|
589
640
|
}
|
|
590
641
|
catch (error) {
|
|
591
|
-
|
|
592
|
-
throw error;
|
|
593
|
-
}
|
|
642
|
+
assertsError(error);
|
|
594
643
|
throw new ParseError(spaceTrim((block) => `
|
|
595
644
|
Invalid FORMAT command
|
|
596
645
|
${block(error.message)}:
|
|
@@ -678,6 +727,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
678
727
|
// encoding: 'utf-8',
|
|
679
728
|
});
|
|
680
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Function to check if a string is valid CSV
|
|
732
|
+
*
|
|
733
|
+
* @param value The string to check
|
|
734
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
735
|
+
*
|
|
736
|
+
* @public exported from `@promptbook/utils`
|
|
737
|
+
*/
|
|
738
|
+
function isValidCsvString(value) {
|
|
739
|
+
try {
|
|
740
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
741
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
catch (error) {
|
|
747
|
+
assertsError(error);
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
681
752
|
/**
|
|
682
753
|
* Definition for CSV spreadsheet
|
|
683
754
|
*
|
|
@@ -688,7 +759,7 @@ const CsvFormatDefinition = {
|
|
|
688
759
|
formatName: 'CSV',
|
|
689
760
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
690
761
|
isValid(value, settings, schema) {
|
|
691
|
-
return
|
|
762
|
+
return isValidCsvString(value);
|
|
692
763
|
},
|
|
693
764
|
canBeValid(partialValue, settings, schema) {
|
|
694
765
|
return true;
|
|
@@ -769,6 +840,9 @@ const CsvFormatDefinition = {
|
|
|
769
840
|
/**
|
|
770
841
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
771
842
|
*
|
|
843
|
+
* @param value The string to check
|
|
844
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
845
|
+
*
|
|
772
846
|
* @public exported from `@promptbook/utils`
|
|
773
847
|
*/
|
|
774
848
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -777,9 +851,7 @@ function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
|
777
851
|
return true;
|
|
778
852
|
}
|
|
779
853
|
catch (error) {
|
|
780
|
-
|
|
781
|
-
throw error;
|
|
782
|
-
}
|
|
854
|
+
assertsError(error);
|
|
783
855
|
if (error.message.includes('Unexpected token')) {
|
|
784
856
|
return false;
|
|
785
857
|
}
|
|
@@ -863,6 +935,30 @@ const TextFormatDefinition = {
|
|
|
863
935
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
864
936
|
*/
|
|
865
937
|
|
|
938
|
+
/**
|
|
939
|
+
* Function to check if a string is valid XML
|
|
940
|
+
*
|
|
941
|
+
* @param value
|
|
942
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
943
|
+
*
|
|
944
|
+
* @public exported from `@promptbook/utils`
|
|
945
|
+
*/
|
|
946
|
+
function isValidXmlString(value) {
|
|
947
|
+
try {
|
|
948
|
+
const parser = new DOMParser();
|
|
949
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
950
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
951
|
+
if (parserError.length > 0) {
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
catch (error) {
|
|
957
|
+
assertsError(error);
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
866
962
|
/**
|
|
867
963
|
* Definition for XML format
|
|
868
964
|
*
|
|
@@ -872,7 +968,7 @@ const XmlFormatDefinition = {
|
|
|
872
968
|
formatName: 'XML',
|
|
873
969
|
mimeType: 'application/xml',
|
|
874
970
|
isValid(value, settings, schema) {
|
|
875
|
-
return
|
|
971
|
+
return isValidXmlString(value);
|
|
876
972
|
},
|
|
877
973
|
canBeValid(partialValue, settings, schema) {
|
|
878
974
|
return true;
|
|
@@ -1097,9 +1193,7 @@ function checkSerializableAsJson(options) {
|
|
|
1097
1193
|
JSON.stringify(value); // <- TODO: [0]
|
|
1098
1194
|
}
|
|
1099
1195
|
catch (error) {
|
|
1100
|
-
|
|
1101
|
-
throw error;
|
|
1102
|
-
}
|
|
1196
|
+
assertsError(error);
|
|
1103
1197
|
throw new UnexpectedError(spaceTrim((block) => `
|
|
1104
1198
|
\`${name}\` is not serializable
|
|
1105
1199
|
|