@promptbook/core 0.74.0-0 → 0.74.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 +143 -29
- package/esm/index.es.js +388 -373
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
- package/esm/typings/src/_packages/azure-openai.index.d.ts +2 -2
- package/esm/typings/src/_packages/browser.index.d.ts +2 -2
- package/esm/typings/src/_packages/cli.index.d.ts +2 -2
- package/esm/typings/src/_packages/core.index.d.ts +7 -3
- package/esm/typings/src/_packages/documents.index.d.ts +2 -2
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +2 -2
- package/esm/typings/src/_packages/fake-llm.index.d.ts +2 -2
- package/esm/typings/src/_packages/langtail.index.d.ts +2 -2
- package/esm/typings/src/_packages/legacy-documents.index.d.ts +2 -2
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/openai.index.d.ts +2 -2
- package/esm/typings/src/_packages/pdf.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-client.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/_packages/website-crawler.index.d.ts +2 -2
- package/esm/typings/src/cli/cli-commands/make.d.ts +0 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +14 -0
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
- package/esm/typings/src/cli/test/ptbk.d.ts +5 -2
- package/esm/typings/src/commands/{PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts → BOOK_VERSION/BookVersionCommand.d.ts} +4 -4
- package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
- package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/version.d.ts +13 -2
- package/package.json +1 -1
- package/umd/index.umd.js +391 -373
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
- /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.d.ts} +0 -0
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -12,10 +12,20 @@ import moment from 'moment';
|
|
|
12
12
|
|
|
13
13
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
14
14
|
/**
|
|
15
|
-
* The version of the
|
|
15
|
+
* The version of the Book language
|
|
16
|
+
*
|
|
17
|
+
* @see https://github.com/webgptorg/book
|
|
18
|
+
*/
|
|
19
|
+
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
20
|
+
/**
|
|
21
|
+
* The version of the Promptbook engine
|
|
22
|
+
*
|
|
23
|
+
* @see https://github.com/webgptorg/promptbook
|
|
24
|
+
*/
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-10';
|
|
26
|
+
/**
|
|
27
|
+
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
16
28
|
*/
|
|
17
|
-
var PROMPTBOOK_VERSION = '0.73.0';
|
|
18
|
-
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
19
29
|
|
|
20
30
|
/*! *****************************************************************************
|
|
21
31
|
Copyright (c) Microsoft Corporation.
|
|
@@ -636,6 +646,13 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
|
|
|
636
646
|
* @public exported from `@promptbook/core`
|
|
637
647
|
*/
|
|
638
648
|
var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
|
|
649
|
+
// <- TODO: [🐊] Pick the best claim
|
|
650
|
+
/**
|
|
651
|
+
* When the title is not provided, the default title is used
|
|
652
|
+
*
|
|
653
|
+
* @public exported from `@promptbook/core`
|
|
654
|
+
*/
|
|
655
|
+
var DEFAULT_TITLE = "Untitled";
|
|
639
656
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
640
657
|
/**
|
|
641
658
|
* The maximum number of iterations for a loops
|
|
@@ -875,7 +892,7 @@ function isValidPromptbookVersion(version) {
|
|
|
875
892
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
876
893
|
return false;
|
|
877
894
|
}
|
|
878
|
-
// <- TODO: [main] !!! Check isValidPromptbookVersion against
|
|
895
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
|
|
879
896
|
return true;
|
|
880
897
|
}
|
|
881
898
|
|
|
@@ -975,7 +992,7 @@ function isValidPipelineUrl(url) {
|
|
|
975
992
|
if (!url.startsWith('https://')) {
|
|
976
993
|
return false;
|
|
977
994
|
}
|
|
978
|
-
if (!url.endsWith('.ptbk.md')) {
|
|
995
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
|
|
979
996
|
return false;
|
|
980
997
|
}
|
|
981
998
|
if (url.includes('#')) {
|
|
@@ -1803,6 +1820,188 @@ var UNCERTAIN_USAGE = $deepFreeze({
|
|
|
1803
1820
|
},
|
|
1804
1821
|
});
|
|
1805
1822
|
|
|
1823
|
+
/**
|
|
1824
|
+
* @@@
|
|
1825
|
+
*
|
|
1826
|
+
* @public exported from `@promptbook/utils`
|
|
1827
|
+
*/
|
|
1828
|
+
function deepClone(objectValue) {
|
|
1829
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
1830
|
+
/*
|
|
1831
|
+
TODO: [🧠] Is there a better implementation?
|
|
1832
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1833
|
+
> for (const propertyName of propertyNames) {
|
|
1834
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
1835
|
+
> if (value && typeof value === 'object') {
|
|
1836
|
+
> deepClone(value);
|
|
1837
|
+
> }
|
|
1838
|
+
> }
|
|
1839
|
+
> return Object.assign({}, objectValue);
|
|
1840
|
+
*/
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1844
|
+
*/
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Function `addUsage` will add multiple usages into one
|
|
1848
|
+
*
|
|
1849
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1850
|
+
*
|
|
1851
|
+
* @public exported from `@promptbook/core`
|
|
1852
|
+
*/
|
|
1853
|
+
function addUsage() {
|
|
1854
|
+
var usageItems = [];
|
|
1855
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1856
|
+
usageItems[_i] = arguments[_i];
|
|
1857
|
+
}
|
|
1858
|
+
return usageItems.reduce(function (acc, item) {
|
|
1859
|
+
var e_1, _a, e_2, _b;
|
|
1860
|
+
var _c;
|
|
1861
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1862
|
+
try {
|
|
1863
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1864
|
+
var key = _e.value;
|
|
1865
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1866
|
+
//@ts-ignore
|
|
1867
|
+
if (item.input[key]) {
|
|
1868
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1869
|
+
//@ts-ignore
|
|
1870
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
1871
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1872
|
+
//@ts-ignore
|
|
1873
|
+
if (item.input[key].isUncertain) {
|
|
1874
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1875
|
+
//@ts-ignore
|
|
1876
|
+
acc.input[key].isUncertain = true;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1882
|
+
finally {
|
|
1883
|
+
try {
|
|
1884
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1885
|
+
}
|
|
1886
|
+
finally { if (e_1) throw e_1.error; }
|
|
1887
|
+
}
|
|
1888
|
+
try {
|
|
1889
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1890
|
+
var key = _g.value;
|
|
1891
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1892
|
+
//@ts-ignore
|
|
1893
|
+
if (item.output[key]) {
|
|
1894
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1895
|
+
//@ts-ignore
|
|
1896
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
1897
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1898
|
+
//@ts-ignore
|
|
1899
|
+
if (item.output[key].isUncertain) {
|
|
1900
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1901
|
+
//@ts-ignore
|
|
1902
|
+
acc.output[key].isUncertain = true;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1908
|
+
finally {
|
|
1909
|
+
try {
|
|
1910
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1911
|
+
}
|
|
1912
|
+
finally { if (e_2) throw e_2.error; }
|
|
1913
|
+
}
|
|
1914
|
+
return acc;
|
|
1915
|
+
}, deepClone(ZERO_USAGE));
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
1920
|
+
*
|
|
1921
|
+
* @param llmTools LLM tools to be intercepted with usage counting
|
|
1922
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
1923
|
+
* @public exported from `@promptbook/core`
|
|
1924
|
+
*/
|
|
1925
|
+
function countTotalUsage(llmTools) {
|
|
1926
|
+
var _this = this;
|
|
1927
|
+
var totalUsage = ZERO_USAGE;
|
|
1928
|
+
var proxyTools = {
|
|
1929
|
+
get title() {
|
|
1930
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
1931
|
+
return llmTools.title;
|
|
1932
|
+
},
|
|
1933
|
+
get description() {
|
|
1934
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
1935
|
+
return llmTools.description;
|
|
1936
|
+
},
|
|
1937
|
+
checkConfiguration: function () {
|
|
1938
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1939
|
+
return __generator(this, function (_a) {
|
|
1940
|
+
return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
|
|
1941
|
+
});
|
|
1942
|
+
});
|
|
1943
|
+
},
|
|
1944
|
+
listModels: function () {
|
|
1945
|
+
return /* not await */ llmTools.listModels();
|
|
1946
|
+
},
|
|
1947
|
+
getTotalUsage: function () {
|
|
1948
|
+
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
1949
|
+
return totalUsage;
|
|
1950
|
+
},
|
|
1951
|
+
};
|
|
1952
|
+
if (llmTools.callChatModel !== undefined) {
|
|
1953
|
+
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1954
|
+
var promptResult;
|
|
1955
|
+
return __generator(this, function (_a) {
|
|
1956
|
+
switch (_a.label) {
|
|
1957
|
+
case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
1958
|
+
case 1:
|
|
1959
|
+
promptResult = _a.sent();
|
|
1960
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1961
|
+
return [2 /*return*/, promptResult];
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
}); };
|
|
1965
|
+
}
|
|
1966
|
+
if (llmTools.callCompletionModel !== undefined) {
|
|
1967
|
+
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1968
|
+
var promptResult;
|
|
1969
|
+
return __generator(this, function (_a) {
|
|
1970
|
+
switch (_a.label) {
|
|
1971
|
+
case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
1972
|
+
case 1:
|
|
1973
|
+
promptResult = _a.sent();
|
|
1974
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1975
|
+
return [2 /*return*/, promptResult];
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
}); };
|
|
1979
|
+
}
|
|
1980
|
+
if (llmTools.callEmbeddingModel !== undefined) {
|
|
1981
|
+
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
1982
|
+
var promptResult;
|
|
1983
|
+
return __generator(this, function (_a) {
|
|
1984
|
+
switch (_a.label) {
|
|
1985
|
+
case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
1986
|
+
case 1:
|
|
1987
|
+
promptResult = _a.sent();
|
|
1988
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
1989
|
+
return [2 /*return*/, promptResult];
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
}); };
|
|
1993
|
+
}
|
|
1994
|
+
// <- Note: [🤖]
|
|
1995
|
+
return proxyTools;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
1999
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
2000
|
+
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
2001
|
+
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
2002
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2003
|
+
*/
|
|
2004
|
+
|
|
1806
2005
|
/**
|
|
1807
2006
|
* This error indicates errors during the execution of the pipeline
|
|
1808
2007
|
*
|
|
@@ -2111,188 +2310,6 @@ function joinLlmExecutionTools() {
|
|
|
2111
2310
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2112
2311
|
*/
|
|
2113
2312
|
|
|
2114
|
-
/**
|
|
2115
|
-
* @@@
|
|
2116
|
-
*
|
|
2117
|
-
* @public exported from `@promptbook/utils`
|
|
2118
|
-
*/
|
|
2119
|
-
function deepClone(objectValue) {
|
|
2120
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
2121
|
-
/*
|
|
2122
|
-
TODO: [🧠] Is there a better implementation?
|
|
2123
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2124
|
-
> for (const propertyName of propertyNames) {
|
|
2125
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
2126
|
-
> if (value && typeof value === 'object') {
|
|
2127
|
-
> deepClone(value);
|
|
2128
|
-
> }
|
|
2129
|
-
> }
|
|
2130
|
-
> return Object.assign({}, objectValue);
|
|
2131
|
-
*/
|
|
2132
|
-
}
|
|
2133
|
-
/**
|
|
2134
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
2135
|
-
*/
|
|
2136
|
-
|
|
2137
|
-
/**
|
|
2138
|
-
* Function `addUsage` will add multiple usages into one
|
|
2139
|
-
*
|
|
2140
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
2141
|
-
*
|
|
2142
|
-
* @public exported from `@promptbook/core`
|
|
2143
|
-
*/
|
|
2144
|
-
function addUsage() {
|
|
2145
|
-
var usageItems = [];
|
|
2146
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2147
|
-
usageItems[_i] = arguments[_i];
|
|
2148
|
-
}
|
|
2149
|
-
return usageItems.reduce(function (acc, item) {
|
|
2150
|
-
var e_1, _a, e_2, _b;
|
|
2151
|
-
var _c;
|
|
2152
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
2153
|
-
try {
|
|
2154
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2155
|
-
var key = _e.value;
|
|
2156
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2157
|
-
//@ts-ignore
|
|
2158
|
-
if (item.input[key]) {
|
|
2159
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2160
|
-
//@ts-ignore
|
|
2161
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
2162
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2163
|
-
//@ts-ignore
|
|
2164
|
-
if (item.input[key].isUncertain) {
|
|
2165
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2166
|
-
//@ts-ignore
|
|
2167
|
-
acc.input[key].isUncertain = true;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2173
|
-
finally {
|
|
2174
|
-
try {
|
|
2175
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2176
|
-
}
|
|
2177
|
-
finally { if (e_1) throw e_1.error; }
|
|
2178
|
-
}
|
|
2179
|
-
try {
|
|
2180
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2181
|
-
var key = _g.value;
|
|
2182
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2183
|
-
//@ts-ignore
|
|
2184
|
-
if (item.output[key]) {
|
|
2185
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2186
|
-
//@ts-ignore
|
|
2187
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
2188
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2189
|
-
//@ts-ignore
|
|
2190
|
-
if (item.output[key].isUncertain) {
|
|
2191
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2192
|
-
//@ts-ignore
|
|
2193
|
-
acc.output[key].isUncertain = true;
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2199
|
-
finally {
|
|
2200
|
-
try {
|
|
2201
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
2202
|
-
}
|
|
2203
|
-
finally { if (e_2) throw e_2.error; }
|
|
2204
|
-
}
|
|
2205
|
-
return acc;
|
|
2206
|
-
}, deepClone(ZERO_USAGE));
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
/**
|
|
2210
|
-
* Intercepts LLM tools and counts total usage of the tools
|
|
2211
|
-
*
|
|
2212
|
-
* @param llmTools LLM tools to be intercepted with usage counting
|
|
2213
|
-
* @returns LLM tools with same functionality with added total cost counting
|
|
2214
|
-
* @public exported from `@promptbook/core`
|
|
2215
|
-
*/
|
|
2216
|
-
function countTotalUsage(llmTools) {
|
|
2217
|
-
var _this = this;
|
|
2218
|
-
var totalUsage = ZERO_USAGE;
|
|
2219
|
-
var proxyTools = {
|
|
2220
|
-
get title() {
|
|
2221
|
-
// TODO: [🧠] Maybe put here some suffix
|
|
2222
|
-
return llmTools.title;
|
|
2223
|
-
},
|
|
2224
|
-
get description() {
|
|
2225
|
-
// TODO: [🧠] Maybe put here some suffix
|
|
2226
|
-
return llmTools.description;
|
|
2227
|
-
},
|
|
2228
|
-
checkConfiguration: function () {
|
|
2229
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2230
|
-
return __generator(this, function (_a) {
|
|
2231
|
-
return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
|
|
2232
|
-
});
|
|
2233
|
-
});
|
|
2234
|
-
},
|
|
2235
|
-
listModels: function () {
|
|
2236
|
-
return /* not await */ llmTools.listModels();
|
|
2237
|
-
},
|
|
2238
|
-
getTotalUsage: function () {
|
|
2239
|
-
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
2240
|
-
return totalUsage;
|
|
2241
|
-
},
|
|
2242
|
-
};
|
|
2243
|
-
if (llmTools.callChatModel !== undefined) {
|
|
2244
|
-
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
2245
|
-
var promptResult;
|
|
2246
|
-
return __generator(this, function (_a) {
|
|
2247
|
-
switch (_a.label) {
|
|
2248
|
-
case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
2249
|
-
case 1:
|
|
2250
|
-
promptResult = _a.sent();
|
|
2251
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2252
|
-
return [2 /*return*/, promptResult];
|
|
2253
|
-
}
|
|
2254
|
-
});
|
|
2255
|
-
}); };
|
|
2256
|
-
}
|
|
2257
|
-
if (llmTools.callCompletionModel !== undefined) {
|
|
2258
|
-
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
2259
|
-
var promptResult;
|
|
2260
|
-
return __generator(this, function (_a) {
|
|
2261
|
-
switch (_a.label) {
|
|
2262
|
-
case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
2263
|
-
case 1:
|
|
2264
|
-
promptResult = _a.sent();
|
|
2265
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2266
|
-
return [2 /*return*/, promptResult];
|
|
2267
|
-
}
|
|
2268
|
-
});
|
|
2269
|
-
}); };
|
|
2270
|
-
}
|
|
2271
|
-
if (llmTools.callEmbeddingModel !== undefined) {
|
|
2272
|
-
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
2273
|
-
var promptResult;
|
|
2274
|
-
return __generator(this, function (_a) {
|
|
2275
|
-
switch (_a.label) {
|
|
2276
|
-
case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
2277
|
-
case 1:
|
|
2278
|
-
promptResult = _a.sent();
|
|
2279
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2280
|
-
return [2 /*return*/, promptResult];
|
|
2281
|
-
}
|
|
2282
|
-
});
|
|
2283
|
-
}); };
|
|
2284
|
-
}
|
|
2285
|
-
// <- Note: [🤖]
|
|
2286
|
-
return proxyTools;
|
|
2287
|
-
}
|
|
2288
|
-
/**
|
|
2289
|
-
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
2290
|
-
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
2291
|
-
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
2292
|
-
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
2293
|
-
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2294
|
-
*/
|
|
2295
|
-
|
|
2296
2313
|
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
2297
2314
|
|
|
2298
2315
|
/**
|
|
@@ -2697,23 +2714,6 @@ function union() {
|
|
|
2697
2714
|
return union;
|
|
2698
2715
|
}
|
|
2699
2716
|
|
|
2700
|
-
/**
|
|
2701
|
-
* Just marks a place of place where should be something implemented
|
|
2702
|
-
* No side effects.
|
|
2703
|
-
*
|
|
2704
|
-
* Note: It can be usefull suppressing eslint errors of unused variables
|
|
2705
|
-
*
|
|
2706
|
-
* @param value any values
|
|
2707
|
-
* @returns void
|
|
2708
|
-
* @private within the repository
|
|
2709
|
-
*/
|
|
2710
|
-
function TODO_USE() {
|
|
2711
|
-
var value = [];
|
|
2712
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2713
|
-
value[_i] = arguments[_i];
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
|
|
2717
2717
|
/**
|
|
2718
2718
|
* This error indicates problems parsing the format value
|
|
2719
2719
|
*
|
|
@@ -2770,22 +2770,12 @@ var CsvFormatDefinition = {
|
|
|
2770
2770
|
formatName: 'CSV',
|
|
2771
2771
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2772
2772
|
isValid: function (value, settings, schema) {
|
|
2773
|
-
// TODO: Implement CSV validation
|
|
2774
|
-
TODO_USE(value /* <- TODO: Use value here */);
|
|
2775
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2776
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2777
2773
|
return true;
|
|
2778
2774
|
},
|
|
2779
2775
|
canBeValid: function (partialValue, settings, schema) {
|
|
2780
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2781
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2782
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2783
2776
|
return true;
|
|
2784
2777
|
},
|
|
2785
2778
|
heal: function (value, settings, schema) {
|
|
2786
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2787
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2788
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2789
2779
|
throw new Error('Not implemented');
|
|
2790
2780
|
},
|
|
2791
2781
|
subvalueDefinitions: [
|
|
@@ -2904,20 +2894,12 @@ var JsonFormatDefinition = {
|
|
|
2904
2894
|
formatName: 'JSON',
|
|
2905
2895
|
mimeType: 'application/json',
|
|
2906
2896
|
isValid: function (value, settings, schema) {
|
|
2907
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2908
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2909
2897
|
return isValidJsonString(value);
|
|
2910
2898
|
},
|
|
2911
2899
|
canBeValid: function (partialValue, settings, schema) {
|
|
2912
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2913
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2914
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2915
2900
|
return true;
|
|
2916
2901
|
},
|
|
2917
2902
|
heal: function (value, settings, schema) {
|
|
2918
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2919
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2920
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2921
2903
|
throw new Error('Not implemented');
|
|
2922
2904
|
},
|
|
2923
2905
|
subvalueDefinitions: [],
|
|
@@ -2999,21 +2981,12 @@ var XmlFormatDefinition = {
|
|
|
2999
2981
|
formatName: 'XML',
|
|
3000
2982
|
mimeType: 'application/xml',
|
|
3001
2983
|
isValid: function (value, settings, schema) {
|
|
3002
|
-
TODO_USE(value /* <- TODO: Use value here */);
|
|
3003
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
3004
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
3005
2984
|
return true;
|
|
3006
2985
|
},
|
|
3007
2986
|
canBeValid: function (partialValue, settings, schema) {
|
|
3008
|
-
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
3009
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
3010
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
3011
2987
|
return true;
|
|
3012
2988
|
},
|
|
3013
2989
|
heal: function (value, settings, schema) {
|
|
3014
|
-
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
3015
|
-
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
3016
|
-
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
3017
2990
|
throw new Error('Not implemented');
|
|
3018
2991
|
},
|
|
3019
2992
|
subvalueDefinitions: [],
|
|
@@ -3246,27 +3219,6 @@ function arrayableToArray(input) {
|
|
|
3246
3219
|
return [input];
|
|
3247
3220
|
}
|
|
3248
3221
|
|
|
3249
|
-
/**
|
|
3250
|
-
* Just says that the variable is not used but should be kept
|
|
3251
|
-
* No side effects.
|
|
3252
|
-
*
|
|
3253
|
-
* Note: It can be usefull for:
|
|
3254
|
-
*
|
|
3255
|
-
* 1) Suppressing eager optimization of unused imports
|
|
3256
|
-
* 2) Suppressing eslint errors of unused variables in the tests
|
|
3257
|
-
* 3) Keeping the type of the variable for type testing
|
|
3258
|
-
*
|
|
3259
|
-
* @param value any values
|
|
3260
|
-
* @returns void
|
|
3261
|
-
* @private within the repository
|
|
3262
|
-
*/
|
|
3263
|
-
function keepUnused() {
|
|
3264
|
-
var valuesToKeep = [];
|
|
3265
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3266
|
-
valuesToKeep[_i] = arguments[_i];
|
|
3267
|
-
}
|
|
3268
|
-
}
|
|
3269
|
-
|
|
3270
3222
|
/**
|
|
3271
3223
|
* Replaces parameters in template with values from parameters object
|
|
3272
3224
|
*
|
|
@@ -3379,10 +3331,12 @@ function countLines(text) {
|
|
|
3379
3331
|
* @public exported from `@promptbook/utils`
|
|
3380
3332
|
*/
|
|
3381
3333
|
function countPages(text) {
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3334
|
+
if (text === '') {
|
|
3335
|
+
return 0;
|
|
3336
|
+
}
|
|
3337
|
+
var pagesByLinesCount = Math.ceil(countLines(text) / 44);
|
|
3338
|
+
var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
|
|
3339
|
+
return Math.max(pagesByLinesCount, pagesByCharactersCount);
|
|
3386
3340
|
}
|
|
3387
3341
|
|
|
3388
3342
|
/**
|
|
@@ -4043,7 +3997,6 @@ function executeAttempts(options) {
|
|
|
4043
3997
|
$ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
|
|
4044
3998
|
}
|
|
4045
3999
|
catch (error) {
|
|
4046
|
-
keepUnused(error);
|
|
4047
4000
|
throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
4048
4001
|
/*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
|
|
4049
4002
|
}
|
|
@@ -4221,7 +4174,6 @@ function executeFormatSubvalues(options) {
|
|
|
4221
4174
|
function getContextForTemplate(template) {
|
|
4222
4175
|
return __awaiter(this, void 0, void 0, function () {
|
|
4223
4176
|
return __generator(this, function (_a) {
|
|
4224
|
-
TODO_USE(template);
|
|
4225
4177
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
|
|
4226
4178
|
});
|
|
4227
4179
|
});
|
|
@@ -4234,11 +4186,9 @@ function getContextForTemplate(template) {
|
|
|
4234
4186
|
*/
|
|
4235
4187
|
function getKnowledgeForTemplate(options) {
|
|
4236
4188
|
return __awaiter(this, void 0, void 0, function () {
|
|
4237
|
-
var preparedPipeline
|
|
4189
|
+
var preparedPipeline;
|
|
4238
4190
|
return __generator(this, function (_a) {
|
|
4239
|
-
preparedPipeline = options.preparedPipeline,
|
|
4240
|
-
// TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
|
|
4241
|
-
TODO_USE(template);
|
|
4191
|
+
preparedPipeline = options.preparedPipeline, options.template;
|
|
4242
4192
|
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4243
4193
|
var content = _a.content;
|
|
4244
4194
|
return "- ".concat(content);
|
|
@@ -4255,8 +4205,6 @@ function getKnowledgeForTemplate(options) {
|
|
|
4255
4205
|
function getExamplesForTemplate(template) {
|
|
4256
4206
|
return __awaiter(this, void 0, void 0, function () {
|
|
4257
4207
|
return __generator(this, function (_a) {
|
|
4258
|
-
// TODO: [♨] Implement Better - use real index and keyword search
|
|
4259
|
-
TODO_USE(template);
|
|
4260
4208
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
|
|
4261
4209
|
});
|
|
4262
4210
|
});
|
|
@@ -4275,13 +4223,13 @@ function getReservedParametersForTemplate(options) {
|
|
|
4275
4223
|
switch (_b.label) {
|
|
4276
4224
|
case 0:
|
|
4277
4225
|
preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
|
|
4278
|
-
return [4 /*yield*/, getContextForTemplate(
|
|
4226
|
+
return [4 /*yield*/, getContextForTemplate()];
|
|
4279
4227
|
case 1:
|
|
4280
4228
|
context = _b.sent();
|
|
4281
4229
|
return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
|
|
4282
4230
|
case 2:
|
|
4283
4231
|
knowledge = _b.sent();
|
|
4284
|
-
return [4 /*yield*/, getExamplesForTemplate(
|
|
4232
|
+
return [4 /*yield*/, getExamplesForTemplate()];
|
|
4285
4233
|
case 3:
|
|
4286
4234
|
examples = _b.sent();
|
|
4287
4235
|
currentDate = new Date().toISOString();
|
|
@@ -4516,7 +4464,7 @@ function executePipeline(options) {
|
|
|
4516
4464
|
executionReport = {
|
|
4517
4465
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
4518
4466
|
title: preparedPipeline.title,
|
|
4519
|
-
promptbookUsedVersion:
|
|
4467
|
+
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
4520
4468
|
promptbookRequestedVersion: preparedPipeline.promptbookVersion,
|
|
4521
4469
|
description: preparedPipeline.description,
|
|
4522
4470
|
promptExecutions: [],
|
|
@@ -5363,16 +5311,13 @@ function isValidFilePath(filename) {
|
|
|
5363
5311
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5364
5312
|
var _a;
|
|
5365
5313
|
return __awaiter(this, void 0, void 0, function () {
|
|
5366
|
-
var sourceContent, name, _b, _c, rootDirname,
|
|
5367
|
-
// <- TODO: process.cwd() if running in Node.js
|
|
5368
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5314
|
+
var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5369
5315
|
return __generator(this, function (_e) {
|
|
5370
5316
|
switch (_e.label) {
|
|
5371
5317
|
case 0:
|
|
5372
5318
|
sourceContent = knowledgeSource.sourceContent;
|
|
5373
5319
|
name = knowledgeSource.name;
|
|
5374
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c,
|
|
5375
|
-
TODO_USE(isVerbose);
|
|
5320
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
|
|
5376
5321
|
if (!name) {
|
|
5377
5322
|
name = sourceContentToName(sourceContent);
|
|
5378
5323
|
}
|
|
@@ -5652,15 +5597,13 @@ function clonePipeline(pipeline) {
|
|
|
5652
5597
|
*/
|
|
5653
5598
|
function prepareTemplates(pipeline, tools, options) {
|
|
5654
5599
|
return __awaiter(this, void 0, void 0, function () {
|
|
5655
|
-
var _a, maxParallelCount, templates,
|
|
5600
|
+
var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
|
|
5656
5601
|
var _this = this;
|
|
5657
5602
|
return __generator(this, function (_b) {
|
|
5658
5603
|
switch (_b.label) {
|
|
5659
5604
|
case 0:
|
|
5660
5605
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5661
|
-
templates = pipeline.templates,
|
|
5662
|
-
// TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
|
|
5663
|
-
TODO_USE(parameters);
|
|
5606
|
+
templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5664
5607
|
templatesPrepared = new Array(templates.length);
|
|
5665
5608
|
return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5666
5609
|
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
@@ -5730,7 +5673,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
5730
5673
|
currentPreparation = {
|
|
5731
5674
|
id: 1,
|
|
5732
5675
|
// TODO: [🍥]> date: $currentDate(),
|
|
5733
|
-
promptbookVersion:
|
|
5676
|
+
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
5734
5677
|
usage: ZERO_USAGE,
|
|
5735
5678
|
};
|
|
5736
5679
|
preparations = [
|
|
@@ -5870,7 +5813,6 @@ var knowledgeCommandParser = {
|
|
|
5870
5813
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5871
5814
|
*/
|
|
5872
5815
|
stringify: function (command) {
|
|
5873
|
-
keepUnused(command);
|
|
5874
5816
|
return "---"; // <- TODO: [🛋] Implement
|
|
5875
5817
|
},
|
|
5876
5818
|
/**
|
|
@@ -5879,7 +5821,6 @@ var knowledgeCommandParser = {
|
|
|
5879
5821
|
* Note: This is used in `pipelineJsonToString` utility
|
|
5880
5822
|
*/
|
|
5881
5823
|
takeFromPipelineJson: function (pipelineJson) {
|
|
5882
|
-
keepUnused(pipelineJson);
|
|
5883
5824
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5884
5825
|
},
|
|
5885
5826
|
};
|
|
@@ -6044,7 +5985,6 @@ var templateCommandParser = {
|
|
|
6044
5985
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6045
5986
|
*/
|
|
6046
5987
|
stringify: function (command) {
|
|
6047
|
-
keepUnused(command);
|
|
6048
5988
|
return "---"; // <- TODO: [🛋] Implement
|
|
6049
5989
|
},
|
|
6050
5990
|
/**
|
|
@@ -6053,7 +5993,6 @@ var templateCommandParser = {
|
|
|
6053
5993
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6054
5994
|
*/
|
|
6055
5995
|
takeFromTemplateJson: function ($templateJson) {
|
|
6056
|
-
keepUnused($templateJson);
|
|
6057
5996
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6058
5997
|
},
|
|
6059
5998
|
};
|
|
@@ -6285,7 +6224,6 @@ var expectCommandParser = {
|
|
|
6285
6224
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6286
6225
|
*/
|
|
6287
6226
|
stringify: function (command) {
|
|
6288
|
-
keepUnused(command);
|
|
6289
6227
|
return "---"; // <- TODO: [🛋] Implement
|
|
6290
6228
|
},
|
|
6291
6229
|
/**
|
|
@@ -6294,7 +6232,6 @@ var expectCommandParser = {
|
|
|
6294
6232
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6295
6233
|
*/
|
|
6296
6234
|
takeFromTemplateJson: function ($templateJson) {
|
|
6297
|
-
keepUnused($templateJson);
|
|
6298
6235
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6299
6236
|
},
|
|
6300
6237
|
};
|
|
@@ -6613,7 +6550,6 @@ var foreachCommandParser = {
|
|
|
6613
6550
|
inputSubparameterNames: inputSubparameterNames,
|
|
6614
6551
|
outputSubparameterName: outputSubparameterName,
|
|
6615
6552
|
};
|
|
6616
|
-
keepUnused($pipelineJson); // <- TODO: [🧠] Maybe register subparameter from foreach into parameters of the pipeline
|
|
6617
6553
|
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
6618
6554
|
},
|
|
6619
6555
|
/**
|
|
@@ -6622,7 +6558,6 @@ var foreachCommandParser = {
|
|
|
6622
6558
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6623
6559
|
*/
|
|
6624
6560
|
stringify: function (command) {
|
|
6625
|
-
keepUnused(command);
|
|
6626
6561
|
return "---"; // <- TODO: [🛋] Implement
|
|
6627
6562
|
},
|
|
6628
6563
|
/**
|
|
@@ -6631,7 +6566,6 @@ var foreachCommandParser = {
|
|
|
6631
6566
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6632
6567
|
*/
|
|
6633
6568
|
takeFromTemplateJson: function ($templateJson) {
|
|
6634
|
-
keepUnused($templateJson);
|
|
6635
6569
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6636
6570
|
},
|
|
6637
6571
|
};
|
|
@@ -6699,7 +6633,6 @@ var formatCommandParser = {
|
|
|
6699
6633
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6700
6634
|
*/
|
|
6701
6635
|
stringify: function (command) {
|
|
6702
|
-
keepUnused(command);
|
|
6703
6636
|
return "---"; // <- TODO: [🛋] Implement
|
|
6704
6637
|
},
|
|
6705
6638
|
/**
|
|
@@ -6708,7 +6641,6 @@ var formatCommandParser = {
|
|
|
6708
6641
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6709
6642
|
*/
|
|
6710
6643
|
takeFromTemplateJson: function ($templateJson) {
|
|
6711
|
-
keepUnused($templateJson);
|
|
6712
6644
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6713
6645
|
},
|
|
6714
6646
|
};
|
|
@@ -6771,7 +6703,6 @@ var jokerCommandParser = {
|
|
|
6771
6703
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6772
6704
|
*/
|
|
6773
6705
|
stringify: function (command) {
|
|
6774
|
-
keepUnused(command);
|
|
6775
6706
|
return "---"; // <- TODO: [🛋] Implement
|
|
6776
6707
|
},
|
|
6777
6708
|
/**
|
|
@@ -6780,7 +6711,6 @@ var jokerCommandParser = {
|
|
|
6780
6711
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6781
6712
|
*/
|
|
6782
6713
|
takeFromTemplateJson: function ($templateJson) {
|
|
6783
|
-
keepUnused($templateJson);
|
|
6784
6714
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6785
6715
|
},
|
|
6786
6716
|
};
|
|
@@ -6916,7 +6846,6 @@ var modelCommandParser = {
|
|
|
6916
6846
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6917
6847
|
*/
|
|
6918
6848
|
stringify: function (command) {
|
|
6919
|
-
keepUnused(command);
|
|
6920
6849
|
return "---"; // <- TODO: [🛋] Implement
|
|
6921
6850
|
},
|
|
6922
6851
|
/**
|
|
@@ -6925,7 +6854,6 @@ var modelCommandParser = {
|
|
|
6925
6854
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6926
6855
|
*/
|
|
6927
6856
|
takeFromPipelineJson: function (pipelineJson) {
|
|
6928
|
-
keepUnused(pipelineJson);
|
|
6929
6857
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6930
6858
|
},
|
|
6931
6859
|
/**
|
|
@@ -6934,7 +6862,6 @@ var modelCommandParser = {
|
|
|
6934
6862
|
* Note: This is used in `pipelineJsonToString` utility
|
|
6935
6863
|
*/
|
|
6936
6864
|
takeFromTemplateJson: function ($templateJson) {
|
|
6937
|
-
keepUnused($templateJson);
|
|
6938
6865
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
6939
6866
|
},
|
|
6940
6867
|
};
|
|
@@ -7008,7 +6935,6 @@ var parameterCommandParser = {
|
|
|
7008
6935
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7009
6936
|
*/
|
|
7010
6937
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7011
|
-
keepUnused(command, $pipelineJson);
|
|
7012
6938
|
// Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
|
|
7013
6939
|
},
|
|
7014
6940
|
/**
|
|
@@ -7017,7 +6943,6 @@ var parameterCommandParser = {
|
|
|
7017
6943
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7018
6944
|
*/
|
|
7019
6945
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7020
|
-
keepUnused(command, $templateJson, $pipelineJson);
|
|
7021
6946
|
// Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
|
|
7022
6947
|
},
|
|
7023
6948
|
/**
|
|
@@ -7026,7 +6951,6 @@ var parameterCommandParser = {
|
|
|
7026
6951
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7027
6952
|
*/
|
|
7028
6953
|
stringify: function (command) {
|
|
7029
|
-
keepUnused(command);
|
|
7030
6954
|
return "---"; // <- TODO: [🛋] Implement
|
|
7031
6955
|
},
|
|
7032
6956
|
/**
|
|
@@ -7035,7 +6959,6 @@ var parameterCommandParser = {
|
|
|
7035
6959
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7036
6960
|
*/
|
|
7037
6961
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7038
|
-
keepUnused(pipelineJson);
|
|
7039
6962
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7040
6963
|
},
|
|
7041
6964
|
/**
|
|
@@ -7044,7 +6967,6 @@ var parameterCommandParser = {
|
|
|
7044
6967
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7045
6968
|
*/
|
|
7046
6969
|
takeFromTemplateJson: function ($templateJson) {
|
|
7047
|
-
keepUnused($templateJson);
|
|
7048
6970
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7049
6971
|
},
|
|
7050
6972
|
};
|
|
@@ -7116,7 +7038,6 @@ var personaCommandParser = {
|
|
|
7116
7038
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7117
7039
|
*/
|
|
7118
7040
|
stringify: function (command) {
|
|
7119
|
-
keepUnused(command);
|
|
7120
7041
|
return "---"; // <- TODO: [🛋] Implement
|
|
7121
7042
|
},
|
|
7122
7043
|
/**
|
|
@@ -7125,7 +7046,6 @@ var personaCommandParser = {
|
|
|
7125
7046
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7126
7047
|
*/
|
|
7127
7048
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7128
|
-
keepUnused(pipelineJson);
|
|
7129
7049
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7130
7050
|
},
|
|
7131
7051
|
/**
|
|
@@ -7134,7 +7054,6 @@ var personaCommandParser = {
|
|
|
7134
7054
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7135
7055
|
*/
|
|
7136
7056
|
takeFromTemplateJson: function ($templateJson) {
|
|
7137
|
-
keepUnused($templateJson);
|
|
7138
7057
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7139
7058
|
},
|
|
7140
7059
|
};
|
|
@@ -7253,7 +7172,6 @@ var postprocessCommandParser = {
|
|
|
7253
7172
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7254
7173
|
*/
|
|
7255
7174
|
stringify: function (command) {
|
|
7256
|
-
keepUnused(command);
|
|
7257
7175
|
return "---"; // <- TODO: [🛋] Implement
|
|
7258
7176
|
},
|
|
7259
7177
|
/**
|
|
@@ -7262,42 +7180,41 @@ var postprocessCommandParser = {
|
|
|
7262
7180
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7263
7181
|
*/
|
|
7264
7182
|
takeFromTemplateJson: function ($templateJson) {
|
|
7265
|
-
keepUnused($templateJson);
|
|
7266
7183
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7267
7184
|
},
|
|
7268
7185
|
};
|
|
7269
7186
|
|
|
7270
7187
|
/**
|
|
7271
|
-
* Parses the
|
|
7188
|
+
* Parses the BOOK_VERSION command
|
|
7272
7189
|
*
|
|
7273
7190
|
* @see `documentationUrl` for more details
|
|
7274
7191
|
* @private within the commands folder
|
|
7275
7192
|
*/
|
|
7276
|
-
var
|
|
7193
|
+
var bookVersionCommandParser = {
|
|
7277
7194
|
/**
|
|
7278
7195
|
* Name of the command
|
|
7279
7196
|
*/
|
|
7280
|
-
name: '
|
|
7281
|
-
aliasNames: ['PTBK_VERSION', '
|
|
7197
|
+
name: 'BOOK_VERSION',
|
|
7198
|
+
aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
|
|
7282
7199
|
/**
|
|
7283
7200
|
* BOILERPLATE command can be used in:
|
|
7284
7201
|
*/
|
|
7285
7202
|
isUsedInPipelineHead: true,
|
|
7286
7203
|
isUsedInPipelineTemplate: false,
|
|
7287
7204
|
/**
|
|
7288
|
-
* Description of the
|
|
7205
|
+
* Description of the BOOK_VERSION command
|
|
7289
7206
|
*/
|
|
7290
|
-
description: "Which version of the
|
|
7207
|
+
description: "Which version of the Book language is the .ptbk.md using",
|
|
7291
7208
|
/**
|
|
7292
7209
|
* Link to documentation
|
|
7293
7210
|
*/
|
|
7294
7211
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
|
|
7295
7212
|
/**
|
|
7296
|
-
* Example usages of the
|
|
7213
|
+
* Example usages of the BOOK_VERSION command
|
|
7297
7214
|
*/
|
|
7298
|
-
examples: ["
|
|
7215
|
+
examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
|
|
7299
7216
|
/**
|
|
7300
|
-
* Parses the
|
|
7217
|
+
* Parses the BOOK_VERSION command
|
|
7301
7218
|
*/
|
|
7302
7219
|
parse: function (input) {
|
|
7303
7220
|
var args = input.args;
|
|
@@ -7308,16 +7225,16 @@ var promptbookVersionCommandParser = {
|
|
|
7308
7225
|
if (!isValidPromptbookVersion(promptbookVersion)) {
|
|
7309
7226
|
throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
|
|
7310
7227
|
}
|
|
7311
|
-
if (args.length > 0) {
|
|
7228
|
+
if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
|
|
7312
7229
|
throw new ParseError("Can not have more than one Promptbook version");
|
|
7313
7230
|
}
|
|
7314
7231
|
return {
|
|
7315
|
-
type: '
|
|
7232
|
+
type: 'BOOK_VERSION',
|
|
7316
7233
|
promptbookVersion: promptbookVersion,
|
|
7317
7234
|
};
|
|
7318
7235
|
},
|
|
7319
7236
|
/**
|
|
7320
|
-
* Apply the
|
|
7237
|
+
* Apply the BOOK_VERSION command to the `pipelineJson`
|
|
7321
7238
|
*
|
|
7322
7239
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7323
7240
|
*/
|
|
@@ -7326,21 +7243,19 @@ var promptbookVersionCommandParser = {
|
|
|
7326
7243
|
$pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
7327
7244
|
},
|
|
7328
7245
|
/**
|
|
7329
|
-
* Converts the
|
|
7246
|
+
* Converts the BOOK_VERSION command back to string
|
|
7330
7247
|
*
|
|
7331
7248
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7332
7249
|
*/
|
|
7333
7250
|
stringify: function (command) {
|
|
7334
|
-
keepUnused(command);
|
|
7335
7251
|
return "---"; // <- TODO: [🛋] Implement
|
|
7336
7252
|
},
|
|
7337
7253
|
/**
|
|
7338
|
-
* Reads the
|
|
7254
|
+
* Reads the BOOK_VERSION command from the `PipelineJson`
|
|
7339
7255
|
*
|
|
7340
7256
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7341
7257
|
*/
|
|
7342
7258
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7343
|
-
keepUnused(pipelineJson);
|
|
7344
7259
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7345
7260
|
},
|
|
7346
7261
|
};
|
|
@@ -7434,7 +7349,6 @@ var urlCommandParser = {
|
|
|
7434
7349
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7435
7350
|
*/
|
|
7436
7351
|
stringify: function (command) {
|
|
7437
|
-
keepUnused(command);
|
|
7438
7352
|
return "---"; // <- TODO: [🛋] Implement
|
|
7439
7353
|
},
|
|
7440
7354
|
/**
|
|
@@ -7443,7 +7357,6 @@ var urlCommandParser = {
|
|
|
7443
7357
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7444
7358
|
*/
|
|
7445
7359
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7446
|
-
keepUnused(pipelineJson);
|
|
7447
7360
|
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
7448
7361
|
},
|
|
7449
7362
|
};
|
|
@@ -7480,8 +7393,7 @@ var actionCommandParser = {
|
|
|
7480
7393
|
* Parses the ACTION command
|
|
7481
7394
|
*/
|
|
7482
7395
|
parse: function (input) {
|
|
7483
|
-
|
|
7484
|
-
TODO_USE(args);
|
|
7396
|
+
input.args;
|
|
7485
7397
|
return {
|
|
7486
7398
|
type: 'ACTION',
|
|
7487
7399
|
};
|
|
@@ -7492,7 +7404,6 @@ var actionCommandParser = {
|
|
|
7492
7404
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7493
7405
|
*/
|
|
7494
7406
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7495
|
-
keepUnused(command, $pipelineJson);
|
|
7496
7407
|
console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
|
|
7497
7408
|
},
|
|
7498
7409
|
/**
|
|
@@ -7501,7 +7412,6 @@ var actionCommandParser = {
|
|
|
7501
7412
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7502
7413
|
*/
|
|
7503
7414
|
stringify: function (command) {
|
|
7504
|
-
keepUnused(command);
|
|
7505
7415
|
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
7506
7416
|
},
|
|
7507
7417
|
/**
|
|
@@ -7510,7 +7420,6 @@ var actionCommandParser = {
|
|
|
7510
7420
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7511
7421
|
*/
|
|
7512
7422
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7513
|
-
keepUnused(pipelineJson);
|
|
7514
7423
|
throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
|
|
7515
7424
|
},
|
|
7516
7425
|
};
|
|
@@ -7550,9 +7459,7 @@ var instrumentCommandParser = {
|
|
|
7550
7459
|
* Parses the INSTRUMENT command
|
|
7551
7460
|
*/
|
|
7552
7461
|
parse: function (input) {
|
|
7553
|
-
|
|
7554
|
-
// TODO: [🛠] Implement
|
|
7555
|
-
TODO_USE(args);
|
|
7462
|
+
input.args;
|
|
7556
7463
|
return {
|
|
7557
7464
|
type: 'INSTRUMENT',
|
|
7558
7465
|
};
|
|
@@ -7563,7 +7470,6 @@ var instrumentCommandParser = {
|
|
|
7563
7470
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7564
7471
|
*/
|
|
7565
7472
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7566
|
-
keepUnused(command, $pipelineJson);
|
|
7567
7473
|
console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
|
|
7568
7474
|
},
|
|
7569
7475
|
/**
|
|
@@ -7572,7 +7478,6 @@ var instrumentCommandParser = {
|
|
|
7572
7478
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7573
7479
|
*/
|
|
7574
7480
|
stringify: function (command) {
|
|
7575
|
-
keepUnused(command);
|
|
7576
7481
|
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
7577
7482
|
},
|
|
7578
7483
|
/**
|
|
@@ -7581,7 +7486,6 @@ var instrumentCommandParser = {
|
|
|
7581
7486
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7582
7487
|
*/
|
|
7583
7488
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7584
|
-
keepUnused(pipelineJson);
|
|
7585
7489
|
throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
|
|
7586
7490
|
},
|
|
7587
7491
|
};
|
|
@@ -7646,7 +7550,6 @@ var boilerplateCommandParser = {
|
|
|
7646
7550
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7647
7551
|
*/
|
|
7648
7552
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7649
|
-
keepUnused(command, $pipelineJson);
|
|
7650
7553
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7651
7554
|
},
|
|
7652
7555
|
/**
|
|
@@ -7655,7 +7558,6 @@ var boilerplateCommandParser = {
|
|
|
7655
7558
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
7656
7559
|
*/
|
|
7657
7560
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
7658
|
-
keepUnused(command, $templateJson, $pipelineJson);
|
|
7659
7561
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7660
7562
|
},
|
|
7661
7563
|
/**
|
|
@@ -7664,7 +7566,6 @@ var boilerplateCommandParser = {
|
|
|
7664
7566
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7665
7567
|
*/
|
|
7666
7568
|
stringify: function (command) {
|
|
7667
|
-
keepUnused(command);
|
|
7668
7569
|
return "---"; // <- TODO: [🛋] Implement
|
|
7669
7570
|
},
|
|
7670
7571
|
/**
|
|
@@ -7673,7 +7574,6 @@ var boilerplateCommandParser = {
|
|
|
7673
7574
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7674
7575
|
*/
|
|
7675
7576
|
takeFromPipelineJson: function (pipelineJson) {
|
|
7676
|
-
keepUnused(pipelineJson);
|
|
7677
7577
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7678
7578
|
},
|
|
7679
7579
|
/**
|
|
@@ -7682,7 +7582,6 @@ var boilerplateCommandParser = {
|
|
|
7682
7582
|
* Note: This is used in `pipelineJsonToString` utility
|
|
7683
7583
|
*/
|
|
7684
7584
|
takeFromTemplateJson: function ($templateJson) {
|
|
7685
|
-
keepUnused($templateJson);
|
|
7686
7585
|
throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
|
|
7687
7586
|
},
|
|
7688
7587
|
};
|
|
@@ -7700,7 +7599,7 @@ var COMMANDS = [
|
|
|
7700
7599
|
modelCommandParser,
|
|
7701
7600
|
parameterCommandParser,
|
|
7702
7601
|
postprocessCommandParser,
|
|
7703
|
-
|
|
7602
|
+
bookVersionCommandParser,
|
|
7704
7603
|
urlCommandParser,
|
|
7705
7604
|
knowledgeCommandParser,
|
|
7706
7605
|
actionCommandParser,
|
|
@@ -7852,9 +7751,7 @@ function parseCommandVariant(input) {
|
|
|
7852
7751
|
var _loop_1 = function (commandParser) {
|
|
7853
7752
|
// <- Note: [🦦] Its strange that this type assertion is needed
|
|
7854
7753
|
var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
|
|
7855
|
-
if (just(false))
|
|
7856
|
-
keepUnused( /* for better indentation */);
|
|
7857
|
-
}
|
|
7754
|
+
if (just(false)) ;
|
|
7858
7755
|
else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
|
|
7859
7756
|
return "continue";
|
|
7860
7757
|
}
|
|
@@ -8014,7 +7911,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
8014
7911
|
return;
|
|
8015
7912
|
}
|
|
8016
7913
|
if (!section.startsWith('#')) {
|
|
8017
|
-
section = "#
|
|
7914
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
8018
7915
|
}
|
|
8019
7916
|
sections.push(section);
|
|
8020
7917
|
buffer = [];
|
|
@@ -8078,7 +7975,7 @@ function flattenMarkdown(markdown) {
|
|
|
8078
7975
|
var e_1, _a;
|
|
8079
7976
|
var sections = splitMarkdownIntoSections(markdown);
|
|
8080
7977
|
if (sections.length === 0) {
|
|
8081
|
-
return
|
|
7978
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
8082
7979
|
}
|
|
8083
7980
|
var flattenedMarkdown = '';
|
|
8084
7981
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -8089,7 +7986,7 @@ function flattenMarkdown(markdown) {
|
|
|
8089
7986
|
}
|
|
8090
7987
|
else {
|
|
8091
7988
|
parsedSections.unshift(firstSection);
|
|
8092
|
-
flattenedMarkdown += "#
|
|
7989
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
8093
7990
|
}
|
|
8094
7991
|
try {
|
|
8095
7992
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|
|
@@ -8167,7 +8064,7 @@ function titleToName(value) {
|
|
|
8167
8064
|
* @public exported from `@promptbook/core`
|
|
8168
8065
|
*/
|
|
8169
8066
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8170
|
-
var e_1, _a, e_2, _b;
|
|
8067
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
8171
8068
|
var $pipelineJson = {
|
|
8172
8069
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
8173
8070
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
@@ -8194,11 +8091,18 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8194
8091
|
}
|
|
8195
8092
|
// =============================================================
|
|
8196
8093
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8094
|
+
if (pipelineString.startsWith('#!')) {
|
|
8095
|
+
var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
|
|
8096
|
+
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8097
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
8098
|
+
}
|
|
8099
|
+
pipelineString = restLines.join('\n');
|
|
8100
|
+
}
|
|
8197
8101
|
pipelineString = removeContentComments(pipelineString);
|
|
8198
8102
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8199
8103
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8200
8104
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8201
|
-
var
|
|
8105
|
+
var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
|
|
8202
8106
|
if (pipelineHead === undefined) {
|
|
8203
8107
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
8204
8108
|
}
|
|
@@ -8226,6 +8130,8 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8226
8130
|
if (parameterDescription) {
|
|
8227
8131
|
existingParameter.description = parameterDescription;
|
|
8228
8132
|
}
|
|
8133
|
+
existingParameter.isInput = existingParameter.isInput || isInput;
|
|
8134
|
+
existingParameter.isOutput = existingParameter.isOutput || isOutput;
|
|
8229
8135
|
}
|
|
8230
8136
|
else {
|
|
8231
8137
|
$pipelineJson.parameters.push({
|
|
@@ -8288,10 +8194,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8288
8194
|
finally { if (e_1) throw e_1.error; }
|
|
8289
8195
|
}
|
|
8290
8196
|
var _loop_2 = function (section) {
|
|
8291
|
-
var
|
|
8197
|
+
var e_5, _l, e_6, _m;
|
|
8292
8198
|
// TODO: Parse template description (the content out of the codeblock and lists)
|
|
8293
8199
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8294
|
-
var
|
|
8200
|
+
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8295
8201
|
// TODO: [🎾][1] DRY description
|
|
8296
8202
|
var description_1 = section.content;
|
|
8297
8203
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8332,7 +8238,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8332
8238
|
}) === false) {
|
|
8333
8239
|
templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
|
|
8334
8240
|
}
|
|
8335
|
-
var
|
|
8241
|
+
var _loop_4 = function (listItem, command) {
|
|
8336
8242
|
var commandParser = getParserForCommand(command);
|
|
8337
8243
|
if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
|
|
8338
8244
|
throw new ParseError(spaceTrim$1(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
@@ -8355,17 +8261,17 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8355
8261
|
};
|
|
8356
8262
|
try {
|
|
8357
8263
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8358
|
-
for (var commands_1 = (
|
|
8359
|
-
var
|
|
8360
|
-
|
|
8264
|
+
for (var commands_1 = (e_5 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
8265
|
+
var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
|
|
8266
|
+
_loop_4(listItem, command);
|
|
8361
8267
|
}
|
|
8362
8268
|
}
|
|
8363
|
-
catch (
|
|
8269
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8364
8270
|
finally {
|
|
8365
8271
|
try {
|
|
8366
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8272
|
+
if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
|
|
8367
8273
|
}
|
|
8368
|
-
finally { if (
|
|
8274
|
+
finally { if (e_5) throw e_5.error; }
|
|
8369
8275
|
}
|
|
8370
8276
|
// TODO: [🍧] Should be done in TEMPLATE command
|
|
8371
8277
|
if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
|
|
@@ -8379,6 +8285,26 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8379
8285
|
language;
|
|
8380
8286
|
}
|
|
8381
8287
|
$templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
|
|
8288
|
+
try {
|
|
8289
|
+
for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8290
|
+
var parameterName = _r.value;
|
|
8291
|
+
// TODO: [🧠] This definition should be made first in the template
|
|
8292
|
+
defineParam({
|
|
8293
|
+
parameterName: parameterName,
|
|
8294
|
+
parameterDescription: null,
|
|
8295
|
+
isInput: false,
|
|
8296
|
+
isOutput: false,
|
|
8297
|
+
// <- Note: In this case null+false+false means that we do not know yet if it is input or output and we will set it later
|
|
8298
|
+
});
|
|
8299
|
+
}
|
|
8300
|
+
}
|
|
8301
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8302
|
+
finally {
|
|
8303
|
+
try {
|
|
8304
|
+
if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
|
|
8305
|
+
}
|
|
8306
|
+
finally { if (e_6) throw e_6.error; }
|
|
8307
|
+
}
|
|
8382
8308
|
/*
|
|
8383
8309
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
8384
8310
|
if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
|
|
@@ -8420,9 +8346,51 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8420
8346
|
finally { if (e_2) throw e_2.error; }
|
|
8421
8347
|
}
|
|
8422
8348
|
// =============================================================
|
|
8423
|
-
// Note: 5️⃣
|
|
8349
|
+
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8350
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8351
|
+
var _loop_3 = function (parameter) {
|
|
8352
|
+
var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
|
|
8353
|
+
if (!isThisParameterResulting) {
|
|
8354
|
+
parameter.isInput = true;
|
|
8355
|
+
}
|
|
8356
|
+
};
|
|
8357
|
+
try {
|
|
8358
|
+
for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
8359
|
+
var parameter = _h.value;
|
|
8360
|
+
_loop_3(parameter);
|
|
8361
|
+
}
|
|
8362
|
+
}
|
|
8363
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8364
|
+
finally {
|
|
8365
|
+
try {
|
|
8366
|
+
if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
|
|
8367
|
+
}
|
|
8368
|
+
finally { if (e_3) throw e_3.error; }
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
// =============================================================
|
|
8372
|
+
// Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8373
|
+
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8374
|
+
try {
|
|
8375
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
8376
|
+
var parameter = _k.value;
|
|
8377
|
+
if (!parameter.isInput) {
|
|
8378
|
+
parameter.isOutput = true;
|
|
8379
|
+
}
|
|
8380
|
+
}
|
|
8381
|
+
}
|
|
8382
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8383
|
+
finally {
|
|
8384
|
+
try {
|
|
8385
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
8386
|
+
}
|
|
8387
|
+
finally { if (e_4) throw e_4.error; }
|
|
8388
|
+
}
|
|
8389
|
+
}
|
|
8390
|
+
// =============================================================
|
|
8391
|
+
// Note: 7️⃣ Cleanup of undefined values
|
|
8424
8392
|
$pipelineJson.templates.forEach(function (templates) {
|
|
8425
|
-
var
|
|
8393
|
+
var e_7, _a;
|
|
8426
8394
|
try {
|
|
8427
8395
|
for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8428
8396
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8431,16 +8399,16 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8431
8399
|
}
|
|
8432
8400
|
}
|
|
8433
8401
|
}
|
|
8434
|
-
catch (
|
|
8402
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8435
8403
|
finally {
|
|
8436
8404
|
try {
|
|
8437
8405
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8438
8406
|
}
|
|
8439
|
-
finally { if (
|
|
8407
|
+
finally { if (e_7) throw e_7.error; }
|
|
8440
8408
|
}
|
|
8441
8409
|
});
|
|
8442
8410
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8443
|
-
var
|
|
8411
|
+
var e_8, _a;
|
|
8444
8412
|
try {
|
|
8445
8413
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8446
8414
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8449,12 +8417,12 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8449
8417
|
}
|
|
8450
8418
|
}
|
|
8451
8419
|
}
|
|
8452
|
-
catch (
|
|
8420
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8453
8421
|
finally {
|
|
8454
8422
|
try {
|
|
8455
8423
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8456
8424
|
}
|
|
8457
|
-
finally { if (
|
|
8425
|
+
finally { if (e_8) throw e_8.error; }
|
|
8458
8426
|
}
|
|
8459
8427
|
});
|
|
8460
8428
|
// =============================================================
|
|
@@ -8976,7 +8944,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
8976
8944
|
*/
|
|
8977
8945
|
|
|
8978
8946
|
/**
|
|
8979
|
-
* Stores
|
|
8947
|
+
* Stores data in memory (HEAP)
|
|
8980
8948
|
*
|
|
8981
8949
|
* @public exported from `@promptbook/core`
|
|
8982
8950
|
*/
|
|
@@ -9106,13 +9074,18 @@ function cacheLlmTools(llmTools, options) {
|
|
|
9106
9074
|
promptResult = _c.sent();
|
|
9107
9075
|
return [3 /*break*/, 11];
|
|
9108
9076
|
case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
|
|
9109
|
-
case 11:
|
|
9077
|
+
case 11:
|
|
9078
|
+
// TODO: [🧠] !!!!!! How to do timing in mixed cache / non-cache situation
|
|
9079
|
+
// promptResult.timing: FromtoItems
|
|
9080
|
+
return [4 /*yield*/, storage.setItem(key, {
|
|
9110
9081
|
date: $currentDate(),
|
|
9111
|
-
promptbookVersion:
|
|
9082
|
+
promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
9112
9083
|
prompt: prompt,
|
|
9113
9084
|
promptResult: promptResult,
|
|
9114
9085
|
})];
|
|
9115
9086
|
case 12:
|
|
9087
|
+
// TODO: [🧠] !!!!!! How to do timing in mixed cache / non-cache situation
|
|
9088
|
+
// promptResult.timing: FromtoItems
|
|
9116
9089
|
_c.sent();
|
|
9117
9090
|
return [2 /*return*/, promptResult];
|
|
9118
9091
|
}
|
|
@@ -9158,8 +9131,7 @@ function cacheLlmTools(llmTools, options) {
|
|
|
9158
9131
|
function limitTotalUsage(llmTools, options) {
|
|
9159
9132
|
var _this = this;
|
|
9160
9133
|
if (options === void 0) { options = {}; }
|
|
9161
|
-
var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage
|
|
9162
|
-
TODO_USE(storage);
|
|
9134
|
+
var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage; _b === void 0 ? new MemoryStorage() : _b;
|
|
9163
9135
|
var proxyTools = countTotalUsage(llmTools);
|
|
9164
9136
|
if (maxTotalUsage.price.value !== 0) {
|
|
9165
9137
|
throw new NotYetImplementedError('`limitTotalUsage` is not yet implemented for non-zero price');
|
|
@@ -9168,7 +9140,6 @@ function limitTotalUsage(llmTools, options) {
|
|
|
9168
9140
|
if (proxyTools.callChatModel !== undefined) {
|
|
9169
9141
|
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
9170
9142
|
return __generator(this, function (_a) {
|
|
9171
|
-
TODO_USE(prompt);
|
|
9172
9143
|
throw new LimitReachedError('Cannot call `callChatModel` because you are not allowed to spend any cost');
|
|
9173
9144
|
});
|
|
9174
9145
|
}); };
|
|
@@ -9176,7 +9147,6 @@ function limitTotalUsage(llmTools, options) {
|
|
|
9176
9147
|
if (proxyTools.callCompletionModel !== undefined) {
|
|
9177
9148
|
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
9178
9149
|
return __generator(this, function (_a) {
|
|
9179
|
-
TODO_USE(prompt);
|
|
9180
9150
|
throw new LimitReachedError('Cannot call `callCompletionModel` because you are not allowed to spend any cost');
|
|
9181
9151
|
});
|
|
9182
9152
|
}); };
|
|
@@ -9184,7 +9154,6 @@ function limitTotalUsage(llmTools, options) {
|
|
|
9184
9154
|
if (proxyTools.callEmbeddingModel !== undefined) {
|
|
9185
9155
|
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
9186
9156
|
return __generator(this, function (_a) {
|
|
9187
|
-
TODO_USE(prompt);
|
|
9188
9157
|
throw new LimitReachedError('Cannot call `callEmbeddingModel` because you are not allowed to spend any cost');
|
|
9189
9158
|
});
|
|
9190
9159
|
}); };
|
|
@@ -9349,8 +9318,6 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
9349
9318
|
};
|
|
9350
9319
|
},
|
|
9351
9320
|
createConfigurationFromEnv: function (env) {
|
|
9352
|
-
// TODO: Maybe auto-configure (multiple) assistants from env variables
|
|
9353
|
-
keepUnused(env);
|
|
9354
9321
|
return null;
|
|
9355
9322
|
/*
|
|
9356
9323
|
if (typeof env.OPENAI_API_KEY === 'string' || typeof env.OPENAI_XXX === 'string') {
|
|
@@ -9494,6 +9461,54 @@ var websiteScraperMetadata = $deepFreeze({
|
|
|
9494
9461
|
*/
|
|
9495
9462
|
var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
|
|
9496
9463
|
|
|
9464
|
+
/**
|
|
9465
|
+
* Behaves like a storage but forgets everything you put in it
|
|
9466
|
+
*
|
|
9467
|
+
* @public exported from `@promptbook/core`
|
|
9468
|
+
*/
|
|
9469
|
+
var BlackholeStorage = /** @class */ (function () {
|
|
9470
|
+
function BlackholeStorage() {
|
|
9471
|
+
}
|
|
9472
|
+
Object.defineProperty(BlackholeStorage.prototype, "length", {
|
|
9473
|
+
/**
|
|
9474
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
9475
|
+
*/
|
|
9476
|
+
get: function () {
|
|
9477
|
+
return 0;
|
|
9478
|
+
},
|
|
9479
|
+
enumerable: false,
|
|
9480
|
+
configurable: true
|
|
9481
|
+
});
|
|
9482
|
+
/**
|
|
9483
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
9484
|
+
*/
|
|
9485
|
+
BlackholeStorage.prototype.clear = function () { };
|
|
9486
|
+
/**
|
|
9487
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
9488
|
+
* @param key
|
|
9489
|
+
*/
|
|
9490
|
+
BlackholeStorage.prototype.getItem = function (key) {
|
|
9491
|
+
return null;
|
|
9492
|
+
};
|
|
9493
|
+
/**
|
|
9494
|
+
* Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
|
|
9495
|
+
*/
|
|
9496
|
+
BlackholeStorage.prototype.key = function (index) {
|
|
9497
|
+
return null;
|
|
9498
|
+
};
|
|
9499
|
+
/**
|
|
9500
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
9501
|
+
*/
|
|
9502
|
+
BlackholeStorage.prototype.setItem = function (key, value) {
|
|
9503
|
+
};
|
|
9504
|
+
/**
|
|
9505
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
9506
|
+
*/
|
|
9507
|
+
BlackholeStorage.prototype.removeItem = function (key) {
|
|
9508
|
+
};
|
|
9509
|
+
return BlackholeStorage;
|
|
9510
|
+
}());
|
|
9511
|
+
|
|
9497
9512
|
/**
|
|
9498
9513
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
9499
9514
|
*
|
|
@@ -9844,5 +9859,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9844
9859
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
9845
9860
|
*/
|
|
9846
9861
|
|
|
9847
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError,
|
|
9862
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_ENGINE_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9848
9863
|
//# sourceMappingURL=index.es.js.map
|