@promptbook/openai 0.37.0 → 0.39.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/esm/typings/_packages/core.index.d.ts +2 -2
- package/esm/typings/_packages/types.index.d.ts +2 -1
- package/esm/typings/execution/CommonExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/execution/ExecutionTools.d.ts +2 -2
- package/esm/typings/execution/NaturalExecutionTools.d.ts +2 -2
- package/esm/typings/execution/PromptResult.d.ts +3 -4
- package/esm/typings/execution/PromptbookExecutor.d.ts +2 -2
- package/esm/typings/execution/ScriptExecutionTools.d.ts +5 -5
- package/esm/typings/execution/UserInterfaceTools.d.ts +4 -4
- package/esm/typings/execution/createPromptbookExecutor.d.ts +2 -2
- package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
- package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
- package/{umd/typings/execution/translation/automatic-translate/automatic-translators/IAutomaticTranslator.d.ts → esm/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts} +2 -2
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +3 -3
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +2 -2
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +5 -5
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -0
- package/esm/typings/execution/translation/automatic-translate/translateMessages.d.ts +4 -4
- package/esm/typings/library/PromptbookLibrary.d.ts +24 -0
- package/esm/typings/library/SimplePromptbookLibrary.d.ts +41 -0
- package/esm/typings/types/Command.d.ts +18 -18
- package/esm/typings/types/ModelRequirements.d.ts +3 -3
- package/esm/typings/types/Prompt.d.ts +2 -2
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -2
- package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +2 -2
- package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +2 -2
- package/esm/typings/types/TaskProgress.d.ts +2 -2
- package/esm/typings/types/typeAliases.d.ts +0 -26
- package/esm/typings/utils/markdown-json/MarkdownStructure.d.ts +2 -2
- package/package.json +2 -2
- package/umd/typings/_packages/core.index.d.ts +2 -2
- package/umd/typings/_packages/types.index.d.ts +2 -1
- package/umd/typings/execution/CommonExecutionToolsOptions.d.ts +2 -2
- package/umd/typings/execution/ExecutionTools.d.ts +2 -2
- package/umd/typings/execution/NaturalExecutionTools.d.ts +2 -2
- package/umd/typings/execution/PromptResult.d.ts +3 -4
- package/umd/typings/execution/PromptbookExecutor.d.ts +2 -2
- package/umd/typings/execution/ScriptExecutionTools.d.ts +5 -5
- package/umd/typings/execution/UserInterfaceTools.d.ts +4 -4
- package/umd/typings/execution/createPromptbookExecutor.d.ts +2 -2
- package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +2 -2
- package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
- package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
- package/{esm/typings/execution/translation/automatic-translate/automatic-translators/IAutomaticTranslator.d.ts → umd/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts} +2 -2
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +3 -3
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +2 -2
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +5 -5
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -0
- package/umd/typings/execution/translation/automatic-translate/translateMessages.d.ts +4 -4
- package/umd/typings/library/PromptbookLibrary.d.ts +24 -0
- package/umd/typings/library/SimplePromptbookLibrary.d.ts +41 -0
- package/umd/typings/types/Command.d.ts +18 -18
- package/umd/typings/types/ModelRequirements.d.ts +3 -3
- package/umd/typings/types/Prompt.d.ts +2 -2
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -2
- package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +2 -2
- package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +2 -2
- package/umd/typings/types/TaskProgress.d.ts +2 -2
- package/umd/typings/types/typeAliases.d.ts +0 -26
- package/umd/typings/utils/markdown-json/MarkdownStructure.d.ts +2 -2
- package/esm/typings/classes/PromptbookLibrary.d.ts +0 -75
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/ITranslatorOptions.d.ts +0 -4
- package/umd/typings/classes/PromptbookLibrary.d.ts +0 -75
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/ITranslatorOptions.d.ts +0 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PromptbookLibrary } from '../classes/PromptbookLibrary';
|
|
2
1
|
import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
|
|
3
2
|
import { validatePromptbookJson } from '../conversion/validatePromptbookJson';
|
|
4
3
|
import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
|
|
@@ -6,9 +5,10 @@ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-ex
|
|
|
6
5
|
import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
|
|
7
6
|
import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
|
|
8
7
|
import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
|
|
8
|
+
import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
|
|
9
9
|
import { ExecutionTypes } from '../types/ExecutionTypes';
|
|
10
10
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
11
|
-
export { ExecutionTypes, PROMPTBOOK_VERSION,
|
|
11
|
+
export { ExecutionTypes, PROMPTBOOK_VERSION, SimplePromptbookLibrary };
|
|
12
12
|
export { SimplePromptInterfaceTools };
|
|
13
13
|
export { promptbookStringToJson, validatePromptbookJson };
|
|
14
14
|
export { MockedEchoNaturalExecutionTools };
|
|
@@ -5,6 +5,7 @@ import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, Prom
|
|
|
5
5
|
import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
|
|
6
6
|
import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
7
7
|
import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
|
|
8
|
+
import { PromptbookLibrary } from '../library/PromptbookLibrary';
|
|
8
9
|
import type { ExecutionType } from '../types/ExecutionTypes';
|
|
9
10
|
import type { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
|
|
10
11
|
import type { Parameters } from '../types/Parameters';
|
|
@@ -19,7 +20,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
|
|
|
19
20
|
import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
20
21
|
import type { client_id, string_char, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version } from '../types/typeAliases';
|
|
21
22
|
import { FromtoItems } from '../utils/FromtoItems';
|
|
22
|
-
export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, };
|
|
23
|
+
export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, };
|
|
23
24
|
/**
|
|
24
25
|
* TODO: Delete type aliases that are not exported here
|
|
25
26
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CommonExecutionToolsOptions = {
|
|
2
2
|
/**
|
|
3
3
|
* If true, the internal executions will be logged
|
|
4
4
|
*/
|
|
5
5
|
readonly isVerbose?: boolean;
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
/**
|
|
8
8
|
* TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
|
|
9
9
|
*/
|
|
@@ -6,7 +6,7 @@ import { UserInterfaceTools } from './UserInterfaceTools';
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://github.com/webgptorg/promptbook#execution-tools
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type ExecutionTools = {
|
|
10
10
|
/**
|
|
11
11
|
* Tools for executing prompts to large language models like GPT-4
|
|
12
12
|
*/
|
|
@@ -22,4 +22,4 @@ export interface ExecutionTools {
|
|
|
22
22
|
* Tools for interacting with the user
|
|
23
23
|
*/
|
|
24
24
|
userInterface: UserInterfaceTools;
|
|
25
|
-
}
|
|
25
|
+
};
|
|
@@ -7,7 +7,7 @@ import { PromptChatResult, PromptCompletionResult } from './PromptResult';
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.com/webgptorg/promptbook#natural-execution-tools
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type NaturalExecutionTools = {
|
|
11
11
|
/**
|
|
12
12
|
* Use a chat model
|
|
13
13
|
*/
|
|
@@ -16,7 +16,7 @@ export interface NaturalExecutionTools {
|
|
|
16
16
|
* Use a completion model
|
|
17
17
|
*/
|
|
18
18
|
gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
/**
|
|
21
21
|
* TODO: [🏳] gptChat -> chat, gptComplete -> complete, translate
|
|
22
22
|
* TODO: [🧠] Should or should not there be a word "GPT" in both gptComplete and gptChat
|
|
@@ -14,9 +14,8 @@ export type PromptCompletionResult = PromptCommonResult;
|
|
|
14
14
|
/**
|
|
15
15
|
* Prompt chat result
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export interface PromptCommonResult {
|
|
17
|
+
export type PromptChatResult = PromptCommonResult & {};
|
|
18
|
+
export type PromptCommonResult = {
|
|
20
19
|
/**
|
|
21
20
|
* Exact text response from the model
|
|
22
21
|
*/
|
|
@@ -65,7 +64,7 @@ export interface PromptCommonResult {
|
|
|
65
64
|
* Raw response from the model
|
|
66
65
|
*/
|
|
67
66
|
readonly rawResponse: object;
|
|
68
|
-
}
|
|
67
|
+
};
|
|
69
68
|
/**
|
|
70
69
|
* TODO: [🧠] Maybe timing more accurate then seconds?
|
|
71
70
|
* TODO: [🧠] Should here be link to the prompt?
|
|
@@ -12,7 +12,7 @@ import type { string_name } from '../types/typeAliases';
|
|
|
12
12
|
*
|
|
13
13
|
* @see https://github.com/webgptorg/promptbook#executor
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type PromptbookExecutor = {
|
|
16
16
|
(inputParameters: Record<string_name, string>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
|
|
17
17
|
/**
|
|
18
18
|
* Whether the execution was successful
|
|
@@ -33,7 +33,7 @@ export interface PromptbookExecutor {
|
|
|
33
33
|
*/
|
|
34
34
|
outputParameters: Record<string_name, string>;
|
|
35
35
|
}>;
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
/**
|
|
38
38
|
* TODO: [🧠] Should this file be in /execution or /types folder?
|
|
39
39
|
*/
|
|
@@ -5,13 +5,13 @@ import { ScriptLanguage } from '../types/ScriptLanguage';
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/webgptorg/promptbook#script-execution-tools
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type ScriptExecutionTools = {
|
|
9
9
|
execute(options: ScriptExecutionToolsExecuteOptions): Promise<string>;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
/**
|
|
12
12
|
* Input for the script execution
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type ScriptExecutionToolsExecuteOptions = {
|
|
15
15
|
/**
|
|
16
16
|
* Language of the script
|
|
17
17
|
*/
|
|
@@ -31,7 +31,7 @@ export interface ScriptExecutionToolsExecuteOptions {
|
|
|
31
31
|
* - It can use the parameters as variables and functions from global scope
|
|
32
32
|
*/
|
|
33
33
|
script: string_script;
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
35
|
/**
|
|
36
36
|
* TODO: [🧠][💙] Distinct between options passed into ExecutionTools and to ExecutionTools.execute
|
|
37
|
-
*/
|
|
37
|
+
*/
|
|
@@ -4,7 +4,7 @@ import { number_integer, number_positive } from '../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/webgptorg/promptbook#user-interface-tools
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type UserInterfaceTools = {
|
|
8
8
|
/**
|
|
9
9
|
* Asks the user to answer a free-text (multiline) question
|
|
10
10
|
*
|
|
@@ -12,8 +12,8 @@ export interface UserInterfaceTools {
|
|
|
12
12
|
* @returns the answer from the user
|
|
13
13
|
*/
|
|
14
14
|
promptDialog(options: UserInterfaceToolsPromptDialogOptions): Promise<string>;
|
|
15
|
-
}
|
|
16
|
-
export
|
|
15
|
+
};
|
|
16
|
+
export type UserInterfaceToolsPromptDialogOptions = {
|
|
17
17
|
/**
|
|
18
18
|
* Prompt title
|
|
19
19
|
*
|
|
@@ -42,4 +42,4 @@ export interface UserInterfaceToolsPromptDialogOptions {
|
|
|
42
42
|
* Note: This would be reflected for example into the UI z-index of the prompt modal
|
|
43
43
|
*/
|
|
44
44
|
priority: number_integer & number_positive;
|
|
45
|
-
}
|
|
45
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PromptbookJson } from '../_packages/types.index';
|
|
2
2
|
import { ExecutionTools } from './ExecutionTools';
|
|
3
3
|
import { PromptbookExecutor } from './PromptbookExecutor';
|
|
4
|
-
export
|
|
4
|
+
export type CreatePromptbookExecutorSettings = {
|
|
5
5
|
/**
|
|
6
6
|
* When executor does not satisfy expectations it will be retried this amount of times
|
|
7
7
|
*
|
|
8
8
|
* @default 3
|
|
9
9
|
*/
|
|
10
10
|
readonly maxExecutionAttempts: number;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
/**
|
|
13
13
|
* Options for creating a promptbook executor
|
|
14
14
|
*/
|
|
@@ -3,7 +3,7 @@ import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOption
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for OpenAiExecutionTools
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type OpenAiExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
7
7
|
/**
|
|
8
8
|
* OpenAI API key
|
|
9
9
|
*/
|
|
@@ -13,4 +13,4 @@ export interface OpenAiExecutionToolsOptions extends CommonExecutionToolsOptions
|
|
|
13
13
|
* and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
|
|
14
14
|
*/
|
|
15
15
|
user?: string_token;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
@@ -3,7 +3,7 @@ import { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOption
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for RemoteNaturalExecutionTools
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type RemoteNaturalExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
7
7
|
/**
|
|
8
8
|
* URL of the remote PROMPTBOOK server
|
|
9
9
|
* On this server will be connected to the socket.io server
|
|
@@ -20,4 +20,4 @@ export interface RemoteNaturalExecutionToolsOptions extends CommonExecutionTools
|
|
|
20
20
|
* Your client ID
|
|
21
21
|
*/
|
|
22
22
|
readonly clientId: client_id;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PromptbookLibrary } from '../../../../../
|
|
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
4
|
import type { NaturalExecutionTools } from '../../../../NaturalExecutionTools';
|
|
5
|
-
export
|
|
5
|
+
export type RemoteServerOptions = CommonExecutionToolsOptions & {
|
|
6
6
|
/**
|
|
7
7
|
* Port on which the server will listen
|
|
8
8
|
*/
|
|
@@ -24,4 +24,4 @@ export interface RemoteServerOptions extends CommonExecutionToolsOptions {
|
|
|
24
24
|
* Creates natural execution tools for each client
|
|
25
25
|
*/
|
|
26
26
|
createNaturalExecutionTools(clientId: client_id): NaturalExecutionTools;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
@@ -4,9 +4,9 @@ import { UserInterfaceToolsPromptDialogOptions } from '../../../UserInterfaceToo
|
|
|
4
4
|
/**
|
|
5
5
|
* Options for CallbackInterfaceTools
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type CallbackInterfaceToolsOptions = CommonExecutionToolsOptions & {
|
|
8
8
|
/**
|
|
9
9
|
* The callback function to be called when promptDialog is called
|
|
10
10
|
*/
|
|
11
11
|
callback(prompt: UserInterfaceToolsPromptDialogOptions): Promisable<string>;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AutomaticTranslator } from './AutomaticTranslator';
|
|
2
2
|
/**
|
|
3
3
|
* This will wrap an automatic translator and log each translation into the console
|
|
4
4
|
*/
|
|
5
|
-
export declare class DebugAutomaticTranslator implements
|
|
5
|
+
export declare class DebugAutomaticTranslator implements AutomaticTranslator {
|
|
6
6
|
private readonly automaticTranslator;
|
|
7
|
-
constructor(automaticTranslator:
|
|
7
|
+
constructor(automaticTranslator: AutomaticTranslator);
|
|
8
8
|
translate(message: string): Promise<string>;
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class FakeAutomaticTranslator implements
|
|
1
|
+
import { AutomaticTranslator } from './AutomaticTranslator';
|
|
2
|
+
export declare class FakeAutomaticTranslator implements AutomaticTranslator {
|
|
3
3
|
constructor();
|
|
4
4
|
translate(message: string): string;
|
|
5
5
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
1
|
+
import { AutomaticTranslator } from './AutomaticTranslator';
|
|
2
|
+
import { TranslatorOptions } from './TranslatorOptions';
|
|
3
|
+
interface LindatAutomaticTranslatorOptions extends TranslatorOptions {
|
|
4
4
|
apiUrl: URL;
|
|
5
5
|
}
|
|
6
|
-
export declare class LindatAutomaticTranslator implements
|
|
6
|
+
export declare class LindatAutomaticTranslator implements AutomaticTranslator {
|
|
7
7
|
private readonly options;
|
|
8
|
-
constructor(options:
|
|
8
|
+
constructor(options: LindatAutomaticTranslatorOptions);
|
|
9
9
|
translate(message: string): Promise<string>;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AutomaticTranslator } from './automatic-translators/AutomaticTranslator';
|
|
2
|
+
import { TranslatorOptions } from './automatic-translators/TranslatorOptions';
|
|
3
3
|
export declare function translateMessages({ automaticTranslator, from, to, }: {
|
|
4
|
-
automaticTranslator:
|
|
5
|
-
} &
|
|
4
|
+
automaticTranslator: AutomaticTranslator;
|
|
5
|
+
} & TranslatorOptions): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Prompt } from '../types/Prompt';
|
|
2
|
+
import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
|
|
3
|
+
import type { string_promptbook_url } from '../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* Library of promptbooks that groups together promptbooks for an application.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
8
|
+
*/
|
|
9
|
+
export type PromptbookLibrary = {
|
|
10
|
+
/**
|
|
11
|
+
* Gets all promptbooks in the library
|
|
12
|
+
*/
|
|
13
|
+
listPromptbooks(): Array<string_promptbook_url>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets promptbook by its URL
|
|
16
|
+
*
|
|
17
|
+
* Note: This is not a direct fetching from the URL, but a lookup in the library
|
|
18
|
+
*/
|
|
19
|
+
getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether given prompt was defined in any promptbook in the library
|
|
22
|
+
*/
|
|
23
|
+
isResponsibleForPrompt(prompt: Prompt): boolean;
|
|
24
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
|
|
2
|
+
import type { Prompt } from '../types/Prompt';
|
|
3
|
+
import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
|
|
4
|
+
import type { PromptbookString } from '../types/PromptbookString';
|
|
5
|
+
import type { string_promptbook_url } from '../types/typeAliases';
|
|
6
|
+
import { PromptbookLibrary } from './PromptbookLibrary';
|
|
7
|
+
/**
|
|
8
|
+
* Library of promptbooks that groups together promptbooks for an application.
|
|
9
|
+
* This implementation is a very thin wrapper around the Array / Set of promptbooks.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
12
|
+
*/
|
|
13
|
+
export declare class SimplePromptbookLibrary implements PromptbookLibrary {
|
|
14
|
+
private readonly options;
|
|
15
|
+
/**
|
|
16
|
+
* Constructs Promptbook from any sources
|
|
17
|
+
*
|
|
18
|
+
* Note: During the construction syntax and logic of all sources are validated
|
|
19
|
+
* Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
|
|
20
|
+
*
|
|
21
|
+
* @param promptbookSources contents of .ptbk.md or .ptbk.json files
|
|
22
|
+
* @param settings settings for creating executor functions
|
|
23
|
+
* @returns PromptbookLibrary
|
|
24
|
+
*/
|
|
25
|
+
static fromSources(promptbookSources: Record<string_promptbook_url, PromptbookJson | PromptbookString>, settings?: Partial<CreatePromptbookExecutorSettings>): SimplePromptbookLibrary;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Gets all promptbooks in the library
|
|
29
|
+
*/
|
|
30
|
+
listPromptbooks(): Array<string_promptbook_url>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets promptbook by its URL
|
|
33
|
+
*
|
|
34
|
+
* Note: This is not a direct fetching from the URL, but a lookup in the library
|
|
35
|
+
*/
|
|
36
|
+
getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether given prompt was defined in any promptbook in the library
|
|
39
|
+
*/
|
|
40
|
+
isResponsibleForPrompt(prompt: Prompt): boolean;
|
|
41
|
+
}
|
|
@@ -13,43 +13,43 @@ export type Command = PromptbookUrlCommand | PromptbookVersionCommand | ExecuteC
|
|
|
13
13
|
* - It is used for backward compatibility
|
|
14
14
|
* - It is defined per whole .promptbook file in the header
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type PromptbookUrlCommand = {
|
|
17
17
|
readonly type: 'PROMPTBOOK_URL';
|
|
18
18
|
readonly promptbookUrl: URL;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
/**
|
|
21
21
|
* PromptbookVersion command tells which version is .promptbook file using
|
|
22
22
|
*
|
|
23
23
|
* - It is used for backward compatibility
|
|
24
24
|
* - It is defined per whole .promptbook file in the header
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type PromptbookVersionCommand = {
|
|
27
27
|
readonly type: 'PROMPTBOOK_VERSION';
|
|
28
28
|
readonly promptbookVersion: string_version;
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
/**
|
|
31
31
|
* Execute command tells how to execute the section
|
|
32
32
|
* It can be either prompt template, script or SIMPLE TEMPLATE etc.
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type ExecuteCommand = {
|
|
35
35
|
readonly type: 'EXECUTE';
|
|
36
36
|
readonly executionType: ExecutionType;
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
/**
|
|
39
39
|
* Model command tells which model and modelRequirements to use for the prompt template. execution
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type ModelCommand = {
|
|
42
42
|
readonly type: 'MODEL';
|
|
43
43
|
readonly key: keyof ModelRequirements;
|
|
44
44
|
readonly value: any;
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
46
|
/**
|
|
47
47
|
* Joker parameter is used instead of executing the prompt template if it meet the expectations requirements
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export type JokerCommand = {
|
|
50
50
|
readonly type: 'JOKER';
|
|
51
51
|
readonly parameterName: string_name;
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
/**
|
|
54
54
|
* Parameter command describes one parameter of the prompt template
|
|
55
55
|
*
|
|
@@ -57,21 +57,21 @@ export interface JokerCommand {
|
|
|
57
57
|
* - It can have description
|
|
58
58
|
* - In description it can have simple formatting BUT not markdown structure or reference to other parameters
|
|
59
59
|
*/
|
|
60
|
-
export
|
|
60
|
+
export type ParameterCommand = {
|
|
61
61
|
readonly type: 'PARAMETER';
|
|
62
62
|
readonly isInput: boolean;
|
|
63
63
|
readonly isOutput: boolean;
|
|
64
64
|
readonly parameterName: string_name;
|
|
65
65
|
readonly parameterDescription: string_markdown_text | null;
|
|
66
|
-
}
|
|
66
|
+
};
|
|
67
67
|
/**
|
|
68
68
|
* Postprocess command describes which function to use for postprocessing
|
|
69
69
|
* This will be created as separate EXECUTE SCRIPT block bellow
|
|
70
70
|
*/
|
|
71
|
-
export
|
|
71
|
+
export type PostprocessCommand = {
|
|
72
72
|
readonly type: 'POSTPROCESS';
|
|
73
73
|
readonly functionName: string_name;
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
/**
|
|
76
76
|
* Expect command describes the desired output of the prompt template (after post-processing)
|
|
77
77
|
* It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
@@ -83,16 +83,16 @@ export type ExpectCommand = ExpectAmountCommand | ExpectFormatCommand;
|
|
|
83
83
|
*
|
|
84
84
|
* Note: LLMs work with tokens, not characters, but in Promptbooks we want to use some human-recognisable and cross-model interoperable units.
|
|
85
85
|
*/
|
|
86
|
-
export
|
|
86
|
+
export type ExpectAmountCommand = {
|
|
87
87
|
readonly type: 'EXPECT_AMOUNT';
|
|
88
88
|
readonly sign: 'EXACTLY' | 'MINIMUM' | 'MAXIMUM';
|
|
89
89
|
readonly unit: ExpectationUnit;
|
|
90
90
|
readonly amount: ExpectationAmount;
|
|
91
|
-
}
|
|
91
|
+
};
|
|
92
92
|
/**
|
|
93
93
|
* Represents a command that expects a specific format.
|
|
94
94
|
*/
|
|
95
|
-
export
|
|
95
|
+
export type ExpectFormatCommand = {
|
|
96
96
|
readonly type: 'EXPECT_FORMAT';
|
|
97
97
|
readonly format: 'JSON';
|
|
98
|
-
}
|
|
98
|
+
};
|
|
@@ -7,13 +7,13 @@ export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT"];
|
|
|
7
7
|
* - **COMPLETION** - model that takes prompt and writes the rest of the text
|
|
8
8
|
* - **CHAT** - model that takes prompt and previous messages and returns response
|
|
9
9
|
*/
|
|
10
|
-
export type ModelVariant =
|
|
10
|
+
export type ModelVariant = typeof MODEL_VARIANTS[number];
|
|
11
11
|
/**
|
|
12
12
|
* Abstract way to specify the LLM. It does not specify the LLM with concrete version itself, only the requirements for the LLM.
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.com/webgptorg/promptbook#model-requirements
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type ModelRequirements = {
|
|
17
17
|
/**
|
|
18
18
|
* Model variant describes the very general type of the model
|
|
19
19
|
*
|
|
@@ -34,7 +34,7 @@ export interface ModelRequirements {
|
|
|
34
34
|
* Maximum number of tokens that can be generated by the model
|
|
35
35
|
*/
|
|
36
36
|
readonly maxTokens?: number;
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
/**
|
|
39
39
|
* TODO: Maybe figure out better word than "variant"
|
|
40
40
|
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
@@ -5,7 +5,7 @@ import type { ModelRequirements } from './ModelRequirements';
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/webgptorg/promptbook#prompt
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Prompt = {
|
|
9
9
|
/**
|
|
10
10
|
* The title of the prompt
|
|
11
11
|
*
|
|
@@ -35,7 +35,7 @@ export interface Prompt {
|
|
|
35
35
|
* Note: This is redundant (same information is in promptbookUrl+content) but useful for logging and debugging
|
|
36
36
|
*/
|
|
37
37
|
readonly parameters: Record<string_name, string>;
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
39
|
/**
|
|
40
40
|
* TODO: [✔] Check ModelRequirements in runtime
|
|
41
41
|
*/
|
|
@@ -10,14 +10,14 @@ export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | Scri
|
|
|
10
10
|
/**
|
|
11
11
|
* Template for prompt to LLM
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type NaturalTemplateJson = PromptTemplateJsonCommon & {
|
|
14
14
|
readonly executionType: 'PROMPT_TEMPLATE';
|
|
15
15
|
/**
|
|
16
16
|
* Requirements for the model
|
|
17
17
|
* - This is required only for executionType PROMPT_TEMPLATE
|
|
18
18
|
*/
|
|
19
19
|
readonly modelRequirements: ModelRequirements;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
/**
|
|
22
22
|
* Units of text measurement
|
|
23
23
|
*/
|
|
@@ -2,7 +2,7 @@ import { string_name } from '../typeAliases';
|
|
|
2
2
|
/**
|
|
3
3
|
* Describes one parameter of the promptbook
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type PromptTemplateParameterJson = {
|
|
6
6
|
/**
|
|
7
7
|
* Name of the parameter
|
|
8
8
|
* - It must be unique across the pipeline
|
|
@@ -22,4 +22,4 @@ export interface PromptTemplateParameterJson {
|
|
|
22
22
|
* - It can use simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
23
23
|
*/
|
|
24
24
|
readonly description?: string;
|
|
25
|
-
}
|
|
25
|
+
};
|
|
@@ -7,7 +7,7 @@ import { PromptTemplateParameterJson } from './PromptTemplateParameterJson';
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.com/webgptorg/promptbook#promptbook
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type PromptbookJson = {
|
|
11
11
|
/**
|
|
12
12
|
* Unique identifier of the promptbook
|
|
13
13
|
*
|
|
@@ -40,7 +40,7 @@ export interface PromptbookJson {
|
|
|
40
40
|
* Sequence of prompt templates that are chained together to form a pipeline
|
|
41
41
|
*/
|
|
42
42
|
readonly promptTemplates: Array<PromptTemplateJson>;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
/**
|
|
45
45
|
* TODO: [🧠] Best format of this code?
|
|
46
46
|
* There must be possible to make
|
|
@@ -3,7 +3,7 @@ import { string_markdown_text, string_name } from './typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* TaskProgress represents the progress of a Promptbook execution.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type TaskProgress = {
|
|
7
7
|
/**
|
|
8
8
|
* The unique name of the task.
|
|
9
9
|
*
|
|
@@ -39,4 +39,4 @@ export interface TaskProgress {
|
|
|
39
39
|
* The parameter value or null if the parameter is not yet processed.
|
|
40
40
|
*/
|
|
41
41
|
readonly parameterValue: string | null;
|
|
42
|
-
}
|
|
42
|
+
};
|