@promptbook/cli 0.46.0 → 0.47.0
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 +18 -8
- package/esm/index.es.js +64 -50
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/langtail.index.d.ts +2 -2
- package/esm/typings/_packages/mock.index.d.ts +3 -3
- package/esm/typings/_packages/openai.index.d.ts +2 -2
- package/esm/typings/_packages/remote-client.index.d.ts +4 -4
- package/esm/typings/_packages/remote-server.index.d.ts +2 -2
- package/esm/typings/_packages/types.index.d.ts +2 -2
- package/esm/typings/_packages/utils.index.d.ts +2 -0
- package/esm/typings/conversion/prettify/PrettifyOptions.d.ts +9 -3
- package/esm/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/esm/typings/conversion/prettify/renderPromptbookMermaid.d.ts +11 -0
- package/esm/typings/execution/ExecutionTools.d.ts +5 -2
- package/esm/typings/execution/{NaturalExecutionTools.d.ts → LlmExecutionTools.d.ts} +2 -2
- package/{umd/typings/execution/plugins/natural-execution-tools → esm/typings/execution/plugins/llm-execution-tools}/langtail/LangtailExecutionTools.d.ts +2 -2
- package/{umd/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts → esm/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts} +2 -2
- package/{umd/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts → esm/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts} +2 -2
- package/{umd/typings/execution/plugins/natural-execution-tools → esm/typings/execution/plugins/llm-execution-tools}/mocked/fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/OpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/execution/plugins/{natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts → llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts} +5 -5
- package/esm/typings/execution/plugins/{natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts → llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts} +3 -3
- package/{umd/typings/execution/plugins/natural-execution-tools → esm/typings/execution/plugins/llm-execution-tools}/remote/interfaces/RemoteServerOptions.d.ts +3 -3
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -2
- package/package.json +14 -4
- package/umd/index.umd.js +64 -50
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/langtail.index.d.ts +2 -2
- package/umd/typings/_packages/mock.index.d.ts +3 -3
- package/umd/typings/_packages/openai.index.d.ts +2 -2
- package/umd/typings/_packages/remote-client.index.d.ts +4 -4
- package/umd/typings/_packages/remote-server.index.d.ts +2 -2
- package/umd/typings/_packages/types.index.d.ts +2 -2
- package/umd/typings/_packages/utils.index.d.ts +2 -0
- package/umd/typings/conversion/prettify/PrettifyOptions.d.ts +9 -3
- package/umd/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/umd/typings/conversion/prettify/renderPromptbookMermaid.d.ts +11 -0
- package/umd/typings/execution/ExecutionTools.d.ts +5 -2
- package/umd/typings/execution/{NaturalExecutionTools.d.ts → LlmExecutionTools.d.ts} +2 -2
- package/{esm/typings/execution/plugins/natural-execution-tools → umd/typings/execution/plugins/llm-execution-tools}/langtail/LangtailExecutionTools.d.ts +2 -2
- package/{esm/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts → umd/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts} +2 -2
- package/{esm/typings/execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools.d.ts → umd/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts} +2 -2
- package/{esm/typings/execution/plugins/natural-execution-tools → umd/typings/execution/plugins/llm-execution-tools}/mocked/fakeTextToExpectations.d.ts +1 -1
- package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/OpenAiExecutionTools.d.ts +2 -2
- package/umd/typings/execution/plugins/{natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts → llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts} +5 -5
- package/umd/typings/execution/plugins/{natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts → llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts} +3 -3
- package/{esm/typings/execution/plugins/natural-execution-tools → umd/typings/execution/plugins/llm-execution-tools}/remote/interfaces/RemoteServerOptions.d.ts +3 -3
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -2
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/fakeTextToExpectations.test.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/faked-completion.test.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/joker.test.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/mocked-chat.test.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/mocked-completion.test.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/computeOpenaiUsage.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
- /package/esm/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/startRemoteServer.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/fakeTextToExpectations.test.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/faked-completion.test.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/joker.test.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/mocked-chat.test.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/mocked/mocked-completion.test.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/openai/computeOpenaiUsage.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
- /package/umd/typings/execution/plugins/{natural-execution-tools → llm-execution-tools}/remote/startRemoteServer.d.ts +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PromptbookJson } from '../../_packages/types.index';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Mermaid graph based on the promptbook
|
|
4
|
+
*
|
|
5
|
+
* Note: The result is not wrapped in a Markdown code block
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderPromptbookMermaid(promptbookJson: PromptbookJson): string;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: Maybe use some Mermaid library instead of string templating
|
|
10
|
+
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
11
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LlmExecutionTools } from './LlmExecutionTools';
|
|
2
2
|
import type { ScriptExecutionTools } from './ScriptExecutionTools';
|
|
3
3
|
import type { UserInterfaceTools } from './UserInterfaceTools';
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export type ExecutionTools = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Tools for executing prompts to large language models like GPT-4
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
llm: LlmExecutionTools;
|
|
14
14
|
/**
|
|
15
15
|
* Tools for executing scripts
|
|
16
16
|
*
|
|
@@ -23,3 +23,6 @@ export type ExecutionTools = {
|
|
|
23
23
|
*/
|
|
24
24
|
userInterface: UserInterfaceTools;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* TODO: !!!! Allow more
|
|
28
|
+
*/
|
|
@@ -5,9 +5,9 @@ import type { PromptChatResult, PromptCompletionResult } from './PromptResult';
|
|
|
5
5
|
* On its interface it exposes common methods for prompt execution.
|
|
6
6
|
* Inside (in constructor) it calls OpenAI, Azure, GPU, proxy, cache, logging,...
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/webgptorg/promptbook#
|
|
8
|
+
* @see https://github.com/webgptorg/promptbook#llm-execution-tools
|
|
9
9
|
*/
|
|
10
|
-
export type
|
|
10
|
+
export type LlmExecutionTools = {
|
|
11
11
|
/**
|
|
12
12
|
* Use a chat model
|
|
13
13
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LlmExecutionTools } from '../../../LlmExecutionTools';
|
|
2
2
|
import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
|
|
3
3
|
/**
|
|
4
4
|
* Execution Tools for calling OpenAI API.
|
|
5
5
|
*/
|
|
6
|
-
export declare class LangtailExecutionTools extends OpenAiExecutionTools implements
|
|
6
|
+
export declare class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* TODO: !!! Make lib which exports this
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Prompt } from '../../../../types/Prompt';
|
|
2
2
|
import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
|
|
3
|
-
import {
|
|
3
|
+
import { LlmExecutionTools } from '../../../LlmExecutionTools';
|
|
4
4
|
import { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
|
|
5
5
|
/**
|
|
6
6
|
* Mocked execution Tools for just echoing the requests for testing purposes.
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class MockedEchoLlmExecutionTools implements LlmExecutionTools {
|
|
9
9
|
private readonly options;
|
|
10
10
|
constructor(options: CommonExecutionToolsOptions);
|
|
11
11
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Prompt } from '../../../../types/Prompt';
|
|
2
2
|
import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
|
|
3
|
-
import {
|
|
3
|
+
import { LlmExecutionTools } from '../../../LlmExecutionTools';
|
|
4
4
|
import { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
|
|
5
5
|
/**
|
|
6
6
|
* Mocked execution Tools for just faking expected responses for testing purposes
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class MockedFackedLlmExecutionTools implements LlmExecutionTools {
|
|
9
9
|
private readonly options;
|
|
10
10
|
constructor(options: CommonExecutionToolsOptions);
|
|
11
11
|
/**
|
|
@@ -6,7 +6,7 @@ import { PostprocessingFunction } from '../../script-execution-tools/javascript/
|
|
|
6
6
|
* Note: You can provide postprocessing functions to modify the text before checking the expectations
|
|
7
7
|
* The result will be the text BEFORE the postprocessing
|
|
8
8
|
*
|
|
9
|
-
* @private internal util for
|
|
9
|
+
* @private internal util for MockedFackedLlmExecutionTools
|
|
10
10
|
*/
|
|
11
11
|
export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
|
|
12
12
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Prompt } from '../../../../types/Prompt';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LlmExecutionTools } from '../../../LlmExecutionTools';
|
|
3
3
|
import type { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
|
|
4
4
|
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
5
5
|
/**
|
|
6
6
|
* Execution Tools for calling OpenAI API.
|
|
7
7
|
*/
|
|
8
|
-
export declare class OpenAiExecutionTools implements
|
|
8
|
+
export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
9
9
|
private readonly options;
|
|
10
10
|
/**
|
|
11
11
|
* OpenAI API client.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Prompt } from '../../../../types/Prompt';
|
|
2
|
-
import {
|
|
2
|
+
import { LlmExecutionTools } from '../../../LlmExecutionTools';
|
|
3
3
|
import { PromptChatResult, PromptCompletionResult } from '../../../PromptResult';
|
|
4
|
-
import {
|
|
4
|
+
import { RemoteLlmExecutionToolsOptions } from './RemoteLlmExecutionToolsOptions';
|
|
5
5
|
/**
|
|
6
6
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
7
7
|
*
|
|
@@ -10,9 +10,9 @@ import { RemoteNaturalExecutionToolsOptions } from './RemoteNaturalExecutionTool
|
|
|
10
10
|
*
|
|
11
11
|
* @see https://github.com/webgptorg/promptbook#remote-server
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
|
|
14
14
|
private readonly options;
|
|
15
|
-
constructor(options:
|
|
15
|
+
constructor(options: RemoteLlmExecutionToolsOptions);
|
|
16
16
|
/**
|
|
17
17
|
* Creates a connection to the remote proxy server.
|
|
18
18
|
*/
|
|
@@ -31,5 +31,5 @@ export declare class RemoteNaturalExecutionTools implements NaturalExecutionTool
|
|
|
31
31
|
private gptCommon;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* TODO: [🤹♂️]
|
|
34
|
+
* TODO: [🤹♂️] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
|
|
35
35
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { client_id, string_uri } from '
|
|
1
|
+
import type { client_id, string_uri } from '../../../../types/typeAliases';
|
|
2
2
|
import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
|
|
3
3
|
/**
|
|
4
|
-
* Options for
|
|
4
|
+
* Options for RemoteLlmExecutionTools
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
7
7
|
/**
|
|
8
8
|
* URL of the remote PROMPTBOOK server
|
|
9
9
|
* On this server will be connected to the socket.io server
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PromptbookLibrary } from '../../../../../library/PromptbookLibrary';
|
|
2
2
|
import type { client_id, string_uri } from '../../../../../types/typeAliases';
|
|
3
3
|
import type { CommonExecutionToolsOptions } from '../../../../CommonExecutionToolsOptions';
|
|
4
|
-
import type {
|
|
4
|
+
import type { LlmExecutionTools } from '../../../../LlmExecutionTools';
|
|
5
5
|
export type RemoteServerOptions = CommonExecutionToolsOptions & {
|
|
6
6
|
/**
|
|
7
7
|
* Port on which the server will listen
|
|
@@ -21,7 +21,7 @@ export type RemoteServerOptions = CommonExecutionToolsOptions & {
|
|
|
21
21
|
*/
|
|
22
22
|
readonly library: PromptbookLibrary;
|
|
23
23
|
/**
|
|
24
|
-
* Creates
|
|
24
|
+
* Creates llm execution tools for each client
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
createLlmExecutionTools(clientId: client_id): LlmExecutionTools;
|
|
27
27
|
};
|
|
@@ -6,11 +6,11 @@ import type { number_integer, number_positive_or_zero, string_javascript, string
|
|
|
6
6
|
/**
|
|
7
7
|
* Describes one prompt template in the promptbook
|
|
8
8
|
*/
|
|
9
|
-
export type PromptTemplateJson =
|
|
9
|
+
export type PromptTemplateJson = LlmTemplateJson | SimpleTemplateJson | ScriptTemplateJson | PromptDialogJson;
|
|
10
10
|
/**
|
|
11
11
|
* Template for prompt to LLM
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
13
|
+
export type LlmTemplateJson = PromptTemplateJsonCommon & {
|
|
14
14
|
readonly executionType: 'PROMPT_TEMPLATE';
|
|
15
15
|
/**
|
|
16
16
|
* Requirements for the model
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,11 +38,21 @@
|
|
|
38
38
|
"commander": "12.0.0",
|
|
39
39
|
"glob-promise": "6.0.5",
|
|
40
40
|
"prettier": "2.8.1",
|
|
41
|
-
"spacetrim": "0.11.
|
|
42
|
-
"waitasecond": "1.11.
|
|
41
|
+
"spacetrim": "0.11.23",
|
|
42
|
+
"waitasecond": "1.11.67"
|
|
43
43
|
},
|
|
44
|
+
"funding": [
|
|
45
|
+
{
|
|
46
|
+
"type": "individual",
|
|
47
|
+
"url": "https://buymeacoffee.com/hejny"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"type": "github",
|
|
51
|
+
"url": "https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
44
54
|
"peerDependencies": {
|
|
45
|
-
"@promptbook/core": "0.
|
|
55
|
+
"@promptbook/core": "0.47.0"
|
|
46
56
|
},
|
|
47
57
|
"main": "./umd/index.umd.js",
|
|
48
58
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -146,7 +146,67 @@
|
|
|
146
146
|
/**
|
|
147
147
|
* The version of the Promptbook library
|
|
148
148
|
*/
|
|
149
|
-
var PROMPTBOOK_VERSION = '0.
|
|
149
|
+
var PROMPTBOOK_VERSION = '0.47.0-0';
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
153
|
+
*/
|
|
154
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
155
|
+
__extends(UnexpectedError, _super);
|
|
156
|
+
function UnexpectedError(message) {
|
|
157
|
+
var _this = _super.call(this, spacetrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the promptbook library\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
158
|
+
_this.name = 'UnexpectedError';
|
|
159
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
160
|
+
return _this;
|
|
161
|
+
}
|
|
162
|
+
return UnexpectedError;
|
|
163
|
+
}(Error));
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a Mermaid graph based on the promptbook
|
|
167
|
+
*
|
|
168
|
+
* Note: The result is not wrapped in a Markdown code block
|
|
169
|
+
*/
|
|
170
|
+
function renderPromptbookMermaid(promptbookJson) {
|
|
171
|
+
var parameterNameToTemplateName = function (parameterName) {
|
|
172
|
+
var parameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
173
|
+
if (!parameter) {
|
|
174
|
+
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
175
|
+
}
|
|
176
|
+
if (parameter.isInput) {
|
|
177
|
+
return 'input';
|
|
178
|
+
}
|
|
179
|
+
var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
180
|
+
if (!template) {
|
|
181
|
+
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
182
|
+
}
|
|
183
|
+
return 'template' + normalizeTo_PascalCase(template.title);
|
|
184
|
+
};
|
|
185
|
+
var promptbookMermaid = spacetrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson.promptTemplates
|
|
186
|
+
.flatMap(function (_a) {
|
|
187
|
+
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
188
|
+
return __spreadArray([
|
|
189
|
+
"".concat(parameterNameToTemplateName(resultingParameterName), "(\"").concat(title, "\")")
|
|
190
|
+
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
191
|
+
return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
|
|
192
|
+
})), false);
|
|
193
|
+
})
|
|
194
|
+
.join('\n')), "\n\n ").concat(block(promptbookJson.parameters
|
|
195
|
+
.filter(function (_a) {
|
|
196
|
+
var isOutput = _a.isOutput;
|
|
197
|
+
return isOutput;
|
|
198
|
+
})
|
|
199
|
+
.map(function (_a) {
|
|
200
|
+
var name = _a.name;
|
|
201
|
+
return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
|
|
202
|
+
})
|
|
203
|
+
.join('\n')), "\n output((Output)):::output\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
204
|
+
return promptbookMermaid;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* TODO: Maybe use some Mermaid library instead of string templating
|
|
208
|
+
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
209
|
+
*/
|
|
150
210
|
|
|
151
211
|
/**
|
|
152
212
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -524,20 +584,6 @@
|
|
|
524
584
|
return TemplateError;
|
|
525
585
|
})(Error));
|
|
526
586
|
|
|
527
|
-
/**
|
|
528
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
529
|
-
*/
|
|
530
|
-
var UnexpectedError = /** @class */ (function (_super) {
|
|
531
|
-
__extends(UnexpectedError, _super);
|
|
532
|
-
function UnexpectedError(message) {
|
|
533
|
-
var _this = _super.call(this, spacetrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the promptbook library\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
534
|
-
_this.name = 'UnexpectedError';
|
|
535
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
536
|
-
return _this;
|
|
537
|
-
}
|
|
538
|
-
return UnexpectedError;
|
|
539
|
-
}(Error));
|
|
540
|
-
|
|
541
587
|
/**
|
|
542
588
|
* Prettify the html code
|
|
543
589
|
*
|
|
@@ -1606,45 +1652,13 @@
|
|
|
1606
1652
|
}
|
|
1607
1653
|
|
|
1608
1654
|
/**
|
|
1609
|
-
*
|
|
1655
|
+
* Prettyfies Promptbook string and adds Mermaid graph
|
|
1610
1656
|
*/
|
|
1611
1657
|
function prettifyPromptbookString(promptbookString, options) {
|
|
1612
1658
|
var isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
|
|
1613
1659
|
if (isGraphAdded) {
|
|
1614
|
-
var
|
|
1615
|
-
var
|
|
1616
|
-
var parameter = promptbookJson_1.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1617
|
-
if (!parameter) {
|
|
1618
|
-
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
1619
|
-
}
|
|
1620
|
-
if (parameter.isInput) {
|
|
1621
|
-
return 'input';
|
|
1622
|
-
}
|
|
1623
|
-
var template = promptbookJson_1.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
1624
|
-
if (!template) {
|
|
1625
|
-
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
1626
|
-
}
|
|
1627
|
-
return 'template' + normalizeTo_PascalCase(template.title);
|
|
1628
|
-
};
|
|
1629
|
-
var promptbookMermaid_1 = spacetrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson_1.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson_1.promptTemplates
|
|
1630
|
-
.flatMap(function (_a) {
|
|
1631
|
-
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
1632
|
-
return __spreadArray([
|
|
1633
|
-
"".concat(parameterNameToTemplateName_1(resultingParameterName), "(\"").concat(title, "\")")
|
|
1634
|
-
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
1635
|
-
return "".concat(parameterNameToTemplateName_1(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName_1(resultingParameterName));
|
|
1636
|
-
})), false);
|
|
1637
|
-
})
|
|
1638
|
-
.join('\n')), "\n\n ").concat(block(promptbookJson_1.parameters
|
|
1639
|
-
.filter(function (_a) {
|
|
1640
|
-
var isOutput = _a.isOutput;
|
|
1641
|
-
return isOutput;
|
|
1642
|
-
})
|
|
1643
|
-
.map(function (_a) {
|
|
1644
|
-
var name = _a.name;
|
|
1645
|
-
return "".concat(parameterNameToTemplateName_1(name), "--\"{").concat(name, "}\"-->output");
|
|
1646
|
-
})
|
|
1647
|
-
.join('\n')), "\n output((Output)):::output\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n\n\n "); });
|
|
1660
|
+
var promptbookJson = promptbookStringToJson(promptbookString);
|
|
1661
|
+
var promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson);
|
|
1648
1662
|
var promptbookMermaidBlock = spacetrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
|
|
1649
1663
|
promptbookString = addAutoGeneratedSection(promptbookString, {
|
|
1650
1664
|
sectionName: 'Graph',
|