@promptbook/core 0.59.0-21 → 0.59.0-24
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 +42 -66
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -4
- package/esm/typings/src/_packages/core.index.d.ts +6 -6
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -1
- package/esm/typings/src/cli/actions/hello.d.ts +7 -0
- package/esm/typings/src/cli/actions/make.d.ts +7 -0
- package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
- package/esm/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
- package/esm/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
- package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → esm/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
- package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
- package/{umd/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → esm/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
- package/{umd/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → esm/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
- package/esm/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
- package/esm/typings/src/library/libraryToJson.d.ts +8 -0
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +46 -70
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/cli.index.d.ts +4 -4
- package/umd/typings/src/_packages/core.index.d.ts +6 -6
- package/umd/typings/src/_packages/node.index.d.ts +2 -2
- package/umd/typings/src/_packages/types.index.d.ts +2 -1
- package/umd/typings/src/cli/actions/hello.d.ts +7 -0
- package/umd/typings/src/cli/actions/make.d.ts +7 -0
- package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
- package/umd/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
- package/umd/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
- package/{esm/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → umd/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
- package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
- package/{esm/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → umd/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
- package/umd/typings/src/library/constructors/createLibraryFromPromise.test.d.ts +1 -0
- package/{esm/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → umd/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
- package/umd/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
- package/umd/typings/src/library/libraryToJson.d.ts +8 -0
- package/umd/typings/src/library/libraryToJson.test.d.ts +1 -0
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
- package/umd/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
- /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromDirectory.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromPromise.test.d.ts} +0 -0
- /package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → esm/typings/src/library/libraryToJson.test.d.ts} +0 -0
- /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
- /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runs CLI
|
|
2
|
+
* Runs CLI utilities of Promptbook package
|
|
3
3
|
*/
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function promptbookCli(): Promise<void>;
|
|
5
5
|
/**
|
|
6
6
|
* TODO: [🥠] Do not export to utils directly, its just for CLI script
|
|
7
7
|
* TODO: [🕌] When more functionalities, rename
|
|
@@ -6,6 +6,7 @@ import type { PromptbookLibrary } from './PromptbookLibrary';
|
|
|
6
6
|
* Library of promptbooks that groups together promptbooks for an application.
|
|
7
7
|
* This implementation is a very thin wrapper around the Array / Map of promptbooks.
|
|
8
8
|
*
|
|
9
|
+
* @private use `createLibraryFromJson` instead
|
|
9
10
|
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
10
11
|
*/
|
|
11
12
|
export declare class SimplePromptbookLibrary implements PromptbookLibrary {
|
|
@@ -15,8 +16,9 @@ export declare class SimplePromptbookLibrary implements PromptbookLibrary {
|
|
|
15
16
|
*
|
|
16
17
|
* @param promptbooks !!!
|
|
17
18
|
*
|
|
19
|
+
* @private Use instead `createLibraryFromJson`
|
|
18
20
|
* Note: During the construction logic of all promptbooks are validated
|
|
19
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
21
|
+
* Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
|
|
20
22
|
*/
|
|
21
23
|
constructor(...promptbooks: Array<PromptbookJson>);
|
|
22
24
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { string_folder_path } from '../../types/typeAliases';
|
|
2
2
|
import type { PromptbookLibrary } from '../PromptbookLibrary';
|
|
3
3
|
/**
|
|
4
|
-
* Options for `
|
|
4
|
+
* Options for `createLibraryFromDirectory` function
|
|
5
5
|
*/
|
|
6
6
|
type CreatePromptbookLibraryFromDirectoryOptions = {
|
|
7
7
|
/**
|
|
@@ -39,7 +39,7 @@ type CreatePromptbookLibraryFromDirectoryOptions = {
|
|
|
39
39
|
* @param options - Misc options for the library
|
|
40
40
|
* @returns PromptbookLibrary
|
|
41
41
|
*/
|
|
42
|
-
export declare function
|
|
42
|
+
export declare function createLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
|
|
43
43
|
export {};
|
|
44
44
|
/**
|
|
45
45
|
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
2
|
+
import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
|
|
3
|
+
/**
|
|
4
|
+
* Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
|
|
5
|
+
*
|
|
6
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
7
|
+
* Note: During the construction syntax and logic of all sources are validated
|
|
8
|
+
*
|
|
9
|
+
* @param promptbookSources
|
|
10
|
+
* @returns PromptbookLibrary
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLibraryFromJson(...promptbooks: Array<PromptbookJson>): Promise<SimplePromptbookLibrary>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
|
|
2
|
-
import type { PromptbookString } from '../../types/PromptbookString';
|
|
3
2
|
import type { PromptbookLibrary } from '../PromptbookLibrary';
|
|
4
3
|
/**
|
|
5
4
|
* Constructs Promptbook from async sources
|
|
@@ -8,19 +7,16 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
|
|
|
8
7
|
* - Factory function that returns Promise of array of PromptbookJson or PromptbookString
|
|
9
8
|
*
|
|
10
9
|
* Note: This is useful as internal tool for other constructor functions like
|
|
11
|
-
* `
|
|
10
|
+
* `createLibraryFromUrl` or `createLibraryFromDirectory`
|
|
12
11
|
* Consider using those functions instead of this one
|
|
13
12
|
*
|
|
14
13
|
* Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
|
|
15
14
|
* when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
|
|
16
15
|
*
|
|
17
|
-
* Note: Consider using `
|
|
16
|
+
* Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
|
|
18
17
|
*
|
|
19
18
|
* @param promptbookSourcesPromiseOrFactory
|
|
20
19
|
* @returns PromptbookLibrary
|
|
21
20
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
22
21
|
*/
|
|
23
|
-
export declare function
|
|
24
|
-
/**
|
|
25
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
26
|
-
*/
|
|
22
|
+
export declare function createLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson>> | (() => Promise<Array<PromptbookJson>>)): PromptbookLibrary;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { string_url } from '../../types/typeAliases';
|
|
2
2
|
import type { PromptbookLibrary } from '../PromptbookLibrary';
|
|
3
3
|
/**
|
|
4
|
-
* Options for `
|
|
4
|
+
* Options for `createLibraryFromDirectory` function
|
|
5
5
|
*/
|
|
6
6
|
type CreatePromptbookLibraryFromUrlyOptions = {
|
|
7
7
|
/**
|
|
@@ -22,7 +22,7 @@ type CreatePromptbookLibraryFromUrlyOptions = {
|
|
|
22
22
|
|
|
23
23
|
* @returns PromptbookLibrary
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function createLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
|
|
26
26
|
export {};
|
|
27
27
|
/**
|
|
28
28
|
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
@@ -9,4 +9,4 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
|
|
|
9
9
|
* @param promptbookSources
|
|
10
10
|
* @returns PromptbookLibrary
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function createSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
|
|
2
|
+
import type { PromptbookLibrary } from './PromptbookLibrary';
|
|
3
|
+
/**
|
|
4
|
+
* Converts PromptbookLibrary to serialized JSON
|
|
5
|
+
*
|
|
6
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
7
|
+
*/
|
|
8
|
+
export declare function libraryToJson(library: PromptbookLibrary): Promise<Array<PromptbookJson>>;
|
|
@@ -10,7 +10,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function startRemoteServer(options: RemoteServerOptions): IDestroyable;
|
|
12
12
|
/**
|
|
13
|
-
* TODO: [⚖] Expose the library to be able to connect to same library via
|
|
13
|
+
* TODO: [⚖] Expose the library to be able to connect to same library via createLibraryFromUrl
|
|
14
14
|
* TODO: Handle progress - support streaming
|
|
15
15
|
* TODO: [🤹♂️] Do not hang up immediately but wait until client closes OR timeout
|
|
16
16
|
* TODO: [🤹♂️] Timeout on chat to free up resources
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
return PromptbookSyntaxError;
|
|
207
207
|
}(Error));
|
|
208
208
|
|
|
209
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
209
|
+
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-23",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
/**
|
|
532
532
|
* The version of the Promptbook library
|
|
533
533
|
*/
|
|
534
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
534
|
+
var PROMPTBOOK_VERSION = '0.59.0-23';
|
|
535
535
|
|
|
536
536
|
/**
|
|
537
537
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1853,6 +1853,7 @@
|
|
|
1853
1853
|
* Library of promptbooks that groups together promptbooks for an application.
|
|
1854
1854
|
* This implementation is a very thin wrapper around the Array / Map of promptbooks.
|
|
1855
1855
|
*
|
|
1856
|
+
* @private use `createLibraryFromJson` instead
|
|
1856
1857
|
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
1857
1858
|
*/
|
|
1858
1859
|
var SimplePromptbookLibrary = /** @class */ (function () {
|
|
@@ -1861,8 +1862,9 @@
|
|
|
1861
1862
|
*
|
|
1862
1863
|
* @param promptbooks !!!
|
|
1863
1864
|
*
|
|
1865
|
+
* @private Use instead `createLibraryFromJson`
|
|
1864
1866
|
* Note: During the construction logic of all promptbooks are validated
|
|
1865
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
1867
|
+
* Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
|
|
1866
1868
|
*/
|
|
1867
1869
|
function SimplePromptbookLibrary() {
|
|
1868
1870
|
var e_1, _a;
|
|
@@ -1931,68 +1933,23 @@
|
|
|
1931
1933
|
/**
|
|
1932
1934
|
* Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
|
|
1933
1935
|
*
|
|
1934
|
-
* Note:
|
|
1936
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
1935
1937
|
* Note: During the construction syntax and logic of all sources are validated
|
|
1936
1938
|
*
|
|
1937
1939
|
* @param promptbookSources
|
|
1938
1940
|
* @returns PromptbookLibrary
|
|
1939
1941
|
*/
|
|
1940
|
-
function
|
|
1941
|
-
var
|
|
1942
|
+
function createLibraryFromJson() {
|
|
1943
|
+
var promptbooks = [];
|
|
1942
1944
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1943
|
-
|
|
1945
|
+
promptbooks[_i] = arguments[_i];
|
|
1944
1946
|
}
|
|
1945
1947
|
return __awaiter(this, void 0, void 0, function () {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
return __generator(this, function (_b) {
|
|
1949
|
-
switch (_b.label) {
|
|
1950
|
-
case 0:
|
|
1951
|
-
promptbooks = new Array();
|
|
1952
|
-
_b.label = 1;
|
|
1953
|
-
case 1:
|
|
1954
|
-
_b.trys.push([1, 8, 9, 10]);
|
|
1955
|
-
promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
|
|
1956
|
-
_b.label = 2;
|
|
1957
|
-
case 2:
|
|
1958
|
-
if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
|
|
1959
|
-
source = promptbookSources_1_1.value;
|
|
1960
|
-
promptbook = void 0;
|
|
1961
|
-
if (!(typeof source === 'string')) return [3 /*break*/, 4];
|
|
1962
|
-
return [4 /*yield*/, promptbookStringToJson(source)];
|
|
1963
|
-
case 3:
|
|
1964
|
-
// Note: When directly creating from string, no need to validate the source
|
|
1965
|
-
// The validation is performed always before execution
|
|
1966
|
-
promptbook = _b.sent();
|
|
1967
|
-
return [3 /*break*/, 5];
|
|
1968
|
-
case 4:
|
|
1969
|
-
promptbook = source;
|
|
1970
|
-
_b.label = 5;
|
|
1971
|
-
case 5:
|
|
1972
|
-
promptbooks.push(promptbook);
|
|
1973
|
-
_b.label = 6;
|
|
1974
|
-
case 6:
|
|
1975
|
-
promptbookSources_1_1 = promptbookSources_1.next();
|
|
1976
|
-
return [3 /*break*/, 2];
|
|
1977
|
-
case 7: return [3 /*break*/, 10];
|
|
1978
|
-
case 8:
|
|
1979
|
-
e_1_1 = _b.sent();
|
|
1980
|
-
e_1 = { error: e_1_1 };
|
|
1981
|
-
return [3 /*break*/, 10];
|
|
1982
|
-
case 9:
|
|
1983
|
-
try {
|
|
1984
|
-
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
1985
|
-
}
|
|
1986
|
-
finally { if (e_1) throw e_1.error; }
|
|
1987
|
-
return [7 /*endfinally*/];
|
|
1988
|
-
case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1989
|
-
}
|
|
1948
|
+
return __generator(this, function (_a) {
|
|
1949
|
+
return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1990
1950
|
});
|
|
1991
1951
|
});
|
|
1992
1952
|
}
|
|
1993
|
-
/**
|
|
1994
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1995
|
-
*/
|
|
1996
1953
|
|
|
1997
1954
|
/* tslint:disable */
|
|
1998
1955
|
function normalizeToKebabCase(sentence) {
|
|
@@ -2057,7 +2014,7 @@
|
|
|
2057
2014
|
switch (_b.label) {
|
|
2058
2015
|
case 0:
|
|
2059
2016
|
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2060
|
-
return [4 /*yield*/,
|
|
2017
|
+
return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false))];
|
|
2061
2018
|
case 1:
|
|
2062
2019
|
library = _b.sent();
|
|
2063
2020
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
@@ -3492,19 +3449,19 @@
|
|
|
3492
3449
|
* - Factory function that returns Promise of array of PromptbookJson or PromptbookString
|
|
3493
3450
|
*
|
|
3494
3451
|
* Note: This is useful as internal tool for other constructor functions like
|
|
3495
|
-
* `
|
|
3452
|
+
* `createLibraryFromUrl` or `createLibraryFromDirectory`
|
|
3496
3453
|
* Consider using those functions instead of this one
|
|
3497
3454
|
*
|
|
3498
3455
|
* Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
|
|
3499
3456
|
* when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
|
|
3500
3457
|
*
|
|
3501
|
-
* Note: Consider using `
|
|
3458
|
+
* Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
|
|
3502
3459
|
*
|
|
3503
3460
|
* @param promptbookSourcesPromiseOrFactory
|
|
3504
3461
|
* @returns PromptbookLibrary
|
|
3505
3462
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
3506
3463
|
*/
|
|
3507
|
-
function
|
|
3464
|
+
function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
3508
3465
|
var library;
|
|
3509
3466
|
function forSources() {
|
|
3510
3467
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3519,7 +3476,7 @@
|
|
|
3519
3476
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3520
3477
|
case 1:
|
|
3521
3478
|
promptbookSources = _a.sent();
|
|
3522
|
-
return [4 /*yield*/,
|
|
3479
|
+
return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
|
|
3523
3480
|
case 2:
|
|
3524
3481
|
library = _a.sent();
|
|
3525
3482
|
return [2 /*return*/];
|
|
@@ -3569,16 +3526,13 @@
|
|
|
3569
3526
|
isResponsibleForPrompt: isResponsibleForPrompt,
|
|
3570
3527
|
};
|
|
3571
3528
|
}
|
|
3572
|
-
/**
|
|
3573
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
3574
|
-
*/
|
|
3575
3529
|
|
|
3576
3530
|
/**
|
|
3577
3531
|
* Constructs Promptbook from remote Promptbase URL
|
|
3578
3532
|
|
|
3579
3533
|
* @returns PromptbookLibrary
|
|
3580
3534
|
*/
|
|
3581
|
-
function
|
|
3535
|
+
function createLibraryFromUrl(url, options) {
|
|
3582
3536
|
return __awaiter(this, void 0, void 0, function () {
|
|
3583
3537
|
var _a, _b, isVerbose, _c, isLazyLoaded, library;
|
|
3584
3538
|
var _this = this;
|
|
@@ -3586,7 +3540,7 @@
|
|
|
3586
3540
|
switch (_d.label) {
|
|
3587
3541
|
case 0:
|
|
3588
3542
|
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
|
|
3589
|
-
library =
|
|
3543
|
+
library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3590
3544
|
return __generator(this, function (_a) {
|
|
3591
3545
|
if (isVerbose) {
|
|
3592
3546
|
console.info("Creating promptbook library from url ".concat(url.toString()));
|
|
@@ -3617,7 +3571,7 @@
|
|
|
3617
3571
|
* @param promptbookSources
|
|
3618
3572
|
* @returns PromptbookLibrary
|
|
3619
3573
|
*/
|
|
3620
|
-
function
|
|
3574
|
+
function createSublibrary(library, predicate) {
|
|
3621
3575
|
function listPromptbooks() {
|
|
3622
3576
|
return __awaiter(this, void 0, void 0, function () {
|
|
3623
3577
|
var promptbooks;
|
|
@@ -3687,6 +3641,28 @@
|
|
|
3687
3641
|
};
|
|
3688
3642
|
}
|
|
3689
3643
|
|
|
3644
|
+
/**
|
|
3645
|
+
* Converts PromptbookLibrary to serialized JSON
|
|
3646
|
+
*
|
|
3647
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
3648
|
+
*/
|
|
3649
|
+
function libraryToJson(library) {
|
|
3650
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3651
|
+
var promptbookUrls, promptbooks;
|
|
3652
|
+
return __generator(this, function (_a) {
|
|
3653
|
+
switch (_a.label) {
|
|
3654
|
+
case 0: return [4 /*yield*/, library.listPromptbooks()];
|
|
3655
|
+
case 1:
|
|
3656
|
+
promptbookUrls = _a.sent();
|
|
3657
|
+
return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPromptbookByUrl(url); }))];
|
|
3658
|
+
case 2:
|
|
3659
|
+
promptbooks = _a.sent();
|
|
3660
|
+
return [2 /*return*/, promptbooks];
|
|
3661
|
+
}
|
|
3662
|
+
});
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3690
3666
|
/**
|
|
3691
3667
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3692
3668
|
*
|
|
@@ -4134,19 +4110,19 @@
|
|
|
4134
4110
|
exports.PromptbookReferenceError = PromptbookReferenceError;
|
|
4135
4111
|
exports.PromptbookSyntaxError = PromptbookSyntaxError;
|
|
4136
4112
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
4137
|
-
exports.SimplePromptbookLibrary = SimplePromptbookLibrary;
|
|
4138
4113
|
exports.TemplateError = TemplateError;
|
|
4139
4114
|
exports.UnexpectedError = UnexpectedError;
|
|
4140
4115
|
exports.addUsage = addUsage;
|
|
4141
4116
|
exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
|
|
4142
4117
|
exports.checkExpectations = checkExpectations;
|
|
4118
|
+
exports.createLibraryFromJson = createLibraryFromJson;
|
|
4119
|
+
exports.createLibraryFromPromise = createLibraryFromPromise;
|
|
4120
|
+
exports.createLibraryFromUrl = createLibraryFromUrl;
|
|
4143
4121
|
exports.createPromptbookExecutor = createPromptbookExecutor;
|
|
4144
|
-
exports.
|
|
4145
|
-
exports.createPromptbookLibraryFromSources = createPromptbookLibraryFromSources;
|
|
4146
|
-
exports.createPromptbookLibraryFromUrl = createPromptbookLibraryFromUrl;
|
|
4147
|
-
exports.createPromptbookSublibrary = createPromptbookSublibrary;
|
|
4122
|
+
exports.createSublibrary = createSublibrary;
|
|
4148
4123
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
4149
4124
|
exports.isPassingExpectations = isPassingExpectations;
|
|
4125
|
+
exports.libraryToJson = libraryToJson;
|
|
4150
4126
|
exports.prepareKnowledgeFromMarkdown = prepareKnowledgeFromMarkdown;
|
|
4151
4127
|
exports.prettifyPromptbookString = prettifyPromptbookString;
|
|
4152
4128
|
exports.promptbookJsonToString = promptbookJsonToString;
|