@promptbook/core 0.59.0-20 → 0.59.0-23
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 +52 -73
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +2 -2
- 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/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +16 -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 +56 -77
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/cli.index.d.ts +2 -2
- 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/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +16 -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
|
package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
2
2
|
import type { KnowledgeJson } from '../../../types/PromptbookJson/KnowledgeJson';
|
|
3
3
|
import type { string_markdown } from '../../../types/typeAliases';
|
|
4
|
-
|
|
4
|
+
type PrepareKnowledgeFromMarkdownOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The source of the knowledge in markdown format
|
|
7
|
+
*/
|
|
5
8
|
content: string_markdown;
|
|
9
|
+
/**
|
|
10
|
+
* The LLM tools to use for the conversion and extraction of knowledge
|
|
11
|
+
*/
|
|
6
12
|
llmTools: LlmExecutionTools;
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* If true, the preaparation of knowledge logs additional information
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
isVerbose?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function prepareKnowledgeFromMarkdown(options: PrepareKnowledgeFromMarkdownOptions): Promise<KnowledgeJson>;
|
|
21
|
+
export {};
|
|
@@ -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-21",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-21';
|
|
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) {
|
|
@@ -2051,15 +2008,15 @@
|
|
|
2051
2008
|
|
|
2052
2009
|
function prepareKnowledgeFromMarkdown(options) {
|
|
2053
2010
|
return __awaiter(this, void 0, void 0, function () {
|
|
2054
|
-
var content, llmTools, library, promptbook, executor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2011
|
+
var content, llmTools, _a, isVerbose, library, promptbook, executor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2055
2012
|
var _this = this;
|
|
2056
|
-
return __generator(this, function (
|
|
2057
|
-
switch (
|
|
2013
|
+
return __generator(this, function (_b) {
|
|
2014
|
+
switch (_b.label) {
|
|
2058
2015
|
case 0:
|
|
2059
|
-
content = options.content, llmTools = options.llmTools;
|
|
2060
|
-
return [4 /*yield*/,
|
|
2016
|
+
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2017
|
+
return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false))];
|
|
2061
2018
|
case 1:
|
|
2062
|
-
library =
|
|
2019
|
+
library = _b.sent();
|
|
2063
2020
|
promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
|
|
2064
2021
|
executor = createPromptbookExecutor({
|
|
2065
2022
|
promptbook: promptbook,
|
|
@@ -2072,11 +2029,14 @@
|
|
|
2072
2029
|
});
|
|
2073
2030
|
return [4 /*yield*/, executor({ content: content })];
|
|
2074
2031
|
case 2:
|
|
2075
|
-
result =
|
|
2032
|
+
result = _b.sent();
|
|
2076
2033
|
assertsExecutionSuccessful(result);
|
|
2077
2034
|
outputParameters = result.outputParameters;
|
|
2078
2035
|
knowledgeRaw = outputParameters.knowledge;
|
|
2079
2036
|
knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
|
|
2037
|
+
if (isVerbose) {
|
|
2038
|
+
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
2039
|
+
}
|
|
2080
2040
|
return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
2081
2041
|
var name, title, content, keywords, index, sources;
|
|
2082
2042
|
return __generator(this, function (_a) {
|
|
@@ -2108,7 +2068,7 @@
|
|
|
2108
2068
|
});
|
|
2109
2069
|
}); }))];
|
|
2110
2070
|
case 3:
|
|
2111
|
-
knowledge =
|
|
2071
|
+
knowledge = _b.sent();
|
|
2112
2072
|
return [2 /*return*/, knowledge];
|
|
2113
2073
|
}
|
|
2114
2074
|
});
|
|
@@ -3489,19 +3449,19 @@
|
|
|
3489
3449
|
* - Factory function that returns Promise of array of PromptbookJson or PromptbookString
|
|
3490
3450
|
*
|
|
3491
3451
|
* Note: This is useful as internal tool for other constructor functions like
|
|
3492
|
-
* `
|
|
3452
|
+
* `createLibraryFromUrl` or `createLibraryFromDirectory`
|
|
3493
3453
|
* Consider using those functions instead of this one
|
|
3494
3454
|
*
|
|
3495
3455
|
* Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
|
|
3496
3456
|
* when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
|
|
3497
3457
|
*
|
|
3498
|
-
* Note: Consider using `
|
|
3458
|
+
* Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
|
|
3499
3459
|
*
|
|
3500
3460
|
* @param promptbookSourcesPromiseOrFactory
|
|
3501
3461
|
* @returns PromptbookLibrary
|
|
3502
3462
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
3503
3463
|
*/
|
|
3504
|
-
function
|
|
3464
|
+
function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
3505
3465
|
var library;
|
|
3506
3466
|
function forSources() {
|
|
3507
3467
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3516,7 +3476,7 @@
|
|
|
3516
3476
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3517
3477
|
case 1:
|
|
3518
3478
|
promptbookSources = _a.sent();
|
|
3519
|
-
return [4 /*yield*/,
|
|
3479
|
+
return [4 /*yield*/, createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
|
|
3520
3480
|
case 2:
|
|
3521
3481
|
library = _a.sent();
|
|
3522
3482
|
return [2 /*return*/];
|
|
@@ -3566,16 +3526,13 @@
|
|
|
3566
3526
|
isResponsibleForPrompt: isResponsibleForPrompt,
|
|
3567
3527
|
};
|
|
3568
3528
|
}
|
|
3569
|
-
/**
|
|
3570
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
3571
|
-
*/
|
|
3572
3529
|
|
|
3573
3530
|
/**
|
|
3574
3531
|
* Constructs Promptbook from remote Promptbase URL
|
|
3575
3532
|
|
|
3576
3533
|
* @returns PromptbookLibrary
|
|
3577
3534
|
*/
|
|
3578
|
-
function
|
|
3535
|
+
function createLibraryFromUrl(url, options) {
|
|
3579
3536
|
return __awaiter(this, void 0, void 0, function () {
|
|
3580
3537
|
var _a, _b, isVerbose, _c, isLazyLoaded, library;
|
|
3581
3538
|
var _this = this;
|
|
@@ -3583,7 +3540,7 @@
|
|
|
3583
3540
|
switch (_d.label) {
|
|
3584
3541
|
case 0:
|
|
3585
3542
|
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
|
|
3586
|
-
library =
|
|
3543
|
+
library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3587
3544
|
return __generator(this, function (_a) {
|
|
3588
3545
|
if (isVerbose) {
|
|
3589
3546
|
console.info("Creating promptbook library from url ".concat(url.toString()));
|
|
@@ -3614,7 +3571,7 @@
|
|
|
3614
3571
|
* @param promptbookSources
|
|
3615
3572
|
* @returns PromptbookLibrary
|
|
3616
3573
|
*/
|
|
3617
|
-
function
|
|
3574
|
+
function createSublibrary(library, predicate) {
|
|
3618
3575
|
function listPromptbooks() {
|
|
3619
3576
|
return __awaiter(this, void 0, void 0, function () {
|
|
3620
3577
|
var promptbooks;
|
|
@@ -3684,6 +3641,28 @@
|
|
|
3684
3641
|
};
|
|
3685
3642
|
}
|
|
3686
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
|
+
|
|
3687
3666
|
/**
|
|
3688
3667
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3689
3668
|
*
|
|
@@ -4131,19 +4110,19 @@
|
|
|
4131
4110
|
exports.PromptbookReferenceError = PromptbookReferenceError;
|
|
4132
4111
|
exports.PromptbookSyntaxError = PromptbookSyntaxError;
|
|
4133
4112
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
4134
|
-
exports.SimplePromptbookLibrary = SimplePromptbookLibrary;
|
|
4135
4113
|
exports.TemplateError = TemplateError;
|
|
4136
4114
|
exports.UnexpectedError = UnexpectedError;
|
|
4137
4115
|
exports.addUsage = addUsage;
|
|
4138
4116
|
exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
|
|
4139
4117
|
exports.checkExpectations = checkExpectations;
|
|
4118
|
+
exports.createLibraryFromJson = createLibraryFromJson;
|
|
4119
|
+
exports.createLibraryFromPromise = createLibraryFromPromise;
|
|
4120
|
+
exports.createLibraryFromUrl = createLibraryFromUrl;
|
|
4140
4121
|
exports.createPromptbookExecutor = createPromptbookExecutor;
|
|
4141
|
-
exports.
|
|
4142
|
-
exports.createPromptbookLibraryFromSources = createPromptbookLibraryFromSources;
|
|
4143
|
-
exports.createPromptbookLibraryFromUrl = createPromptbookLibraryFromUrl;
|
|
4144
|
-
exports.createPromptbookSublibrary = createPromptbookSublibrary;
|
|
4122
|
+
exports.createSublibrary = createSublibrary;
|
|
4145
4123
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
4146
4124
|
exports.isPassingExpectations = isPassingExpectations;
|
|
4125
|
+
exports.libraryToJson = libraryToJson;
|
|
4147
4126
|
exports.prepareKnowledgeFromMarkdown = prepareKnowledgeFromMarkdown;
|
|
4148
4127
|
exports.prettifyPromptbookString = prettifyPromptbookString;
|
|
4149
4128
|
exports.promptbookJsonToString = promptbookJsonToString;
|