@promptbook/core 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 +17 -17
- 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 +12 -2
- package/umd/index.umd.js +17 -17
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
2
2
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
4
4
|
import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult } from '../execution/PromptResult';
|
|
5
5
|
import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
|
|
6
6
|
import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
@@ -20,7 +20,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
|
|
|
20
20
|
import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
21
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';
|
|
22
22
|
import { FromtoItems } from '../utils/FromtoItems';
|
|
23
|
-
export {
|
|
23
|
+
export { client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, EXPECTATION_UNITS, ExpectationAmount, ExpectationUnit, FromtoItems, LlmExecutionTools as LlmExecutionTools, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, 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, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
|
|
24
24
|
/**
|
|
25
25
|
* TODO: [🧠][🆔] Is this the best package to export custom errors from?
|
|
26
26
|
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
2
|
import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
|
|
3
|
+
import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
|
|
3
4
|
import { parseNumber } from '../conversion/utils/parseNumber';
|
|
4
5
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
5
6
|
import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
|
|
@@ -56,6 +57,7 @@ export declare const normalizeTo: {
|
|
|
56
57
|
'kebab-case': typeof normalizeToKebabCase;
|
|
57
58
|
};
|
|
58
59
|
export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
|
|
60
|
+
export { renderPromptbookMermaid };
|
|
59
61
|
/**
|
|
60
62
|
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
61
63
|
* Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for `prettifyPromptbookString` function
|
|
3
|
+
*/
|
|
1
4
|
export type PrettifyOptions = {
|
|
5
|
+
/***
|
|
6
|
+
* If true, adds Mermaid graph to the Promptbook string
|
|
7
|
+
*/
|
|
2
8
|
isGraphAdded?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, the string is prettifyed as markdown
|
|
11
|
+
*/
|
|
3
12
|
isPrettifyed?: boolean;
|
|
4
13
|
};
|
|
5
|
-
/**
|
|
6
|
-
* TODO: !!! Annotate all
|
|
7
|
-
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PromptbookString } from '../../types/PromptbookString';
|
|
2
2
|
import type { PrettifyOptions } from './PrettifyOptions';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Prettyfies Promptbook string and adds Mermaid graph
|
|
5
5
|
*/
|
|
6
6
|
export declare function prettifyPromptbookString(promptbookString: PromptbookString, options: PrettifyOptions): PromptbookString;
|
|
7
7
|
/**
|
|
@@ -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/core",
|
|
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,
|
|
@@ -34,8 +34,18 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://www.npmjs.com/package/@promptbook/core",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"spacetrim": "0.11.
|
|
37
|
+
"spacetrim": "0.11.23"
|
|
38
38
|
},
|
|
39
|
+
"funding": [
|
|
40
|
+
{
|
|
41
|
+
"type": "individual",
|
|
42
|
+
"url": "https://buymeacoffee.com/hejny"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"type": "github",
|
|
46
|
+
"url": "https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
39
49
|
"main": "./umd/index.umd.js",
|
|
40
50
|
"module": "./esm/index.es.js",
|
|
41
51
|
"typings": "./esm/typings/_packages/core.index.d.ts"
|
package/umd/index.umd.js
CHANGED
|
@@ -123,6 +123,16 @@
|
|
|
123
123
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Removes HTML or Markdown comments from a string.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} content - The string to remove comments from.
|
|
130
|
+
* @returns {string} The input string with all comments removed.
|
|
131
|
+
*/
|
|
132
|
+
function removeContentComments(content) {
|
|
133
|
+
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
/**
|
|
127
137
|
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
128
138
|
*/
|
|
@@ -137,16 +147,6 @@
|
|
|
137
147
|
return UnexpectedError;
|
|
138
148
|
}(Error));
|
|
139
149
|
|
|
140
|
-
/**
|
|
141
|
-
* Removes HTML or Markdown comments from a string.
|
|
142
|
-
*
|
|
143
|
-
* @param {string} content - The string to remove comments from.
|
|
144
|
-
* @returns {string} The input string with all comments removed.
|
|
145
|
-
*/
|
|
146
|
-
function removeContentComments(content) {
|
|
147
|
-
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
150
|
/**
|
|
151
151
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
152
152
|
*/
|
|
@@ -1136,7 +1136,7 @@
|
|
|
1136
1136
|
/**
|
|
1137
1137
|
* The version of the Promptbook library
|
|
1138
1138
|
*/
|
|
1139
|
-
var PROMPTBOOK_VERSION = '0.
|
|
1139
|
+
var PROMPTBOOK_VERSION = '0.47.0-0';
|
|
1140
1140
|
|
|
1141
1141
|
/**
|
|
1142
1142
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
@@ -2081,13 +2081,13 @@
|
|
|
2081
2081
|
return [7 /*endfinally*/];
|
|
2082
2082
|
case 10:
|
|
2083
2083
|
if (errors.length === 0) {
|
|
2084
|
-
throw new PromptbookExecutionError('Postprocessing in
|
|
2084
|
+
throw new PromptbookExecutionError('Postprocessing in LlmExecutionTools failed because no ScriptExecutionTools were provided');
|
|
2085
2085
|
}
|
|
2086
2086
|
else if (errors.length === 1) {
|
|
2087
2087
|
throw errors[0];
|
|
2088
2088
|
}
|
|
2089
2089
|
else {
|
|
2090
|
-
throw new PromptbookExecutionError(spacetrim.spaceTrim(function (block) { return "\n Postprocessing in
|
|
2090
|
+
throw new PromptbookExecutionError(spacetrim.spaceTrim(function (block) { return "\n Postprocessing in LlmExecutionTools failed ".concat(errors.length, "x\n\n ").concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
|
|
2091
2091
|
}
|
|
2092
2092
|
}
|
|
2093
2093
|
});
|
|
@@ -2099,14 +2099,14 @@
|
|
|
2099
2099
|
case 'COMPLETION': return [3 /*break*/, 9];
|
|
2100
2100
|
}
|
|
2101
2101
|
return [3 /*break*/, 11];
|
|
2102
|
-
case 7: return [4 /*yield*/, tools.
|
|
2102
|
+
case 7: return [4 /*yield*/, tools.llm.gptChat(prompt)];
|
|
2103
2103
|
case 8:
|
|
2104
2104
|
chatThread = _o.sent();
|
|
2105
2105
|
// TODO: [🍬] Destroy chatThread
|
|
2106
2106
|
result = chatThread;
|
|
2107
2107
|
resultString = chatThread.content;
|
|
2108
2108
|
return [3 /*break*/, 12];
|
|
2109
|
-
case 9: return [4 /*yield*/, tools.
|
|
2109
|
+
case 9: return [4 /*yield*/, tools.llm.gptComplete(prompt)];
|
|
2110
2110
|
case 10:
|
|
2111
2111
|
completionResult = _o.sent();
|
|
2112
2112
|
result = completionResult;
|
|
@@ -2293,7 +2293,7 @@
|
|
|
2293
2293
|
currentTemplate.executionType === 'PROMPT_TEMPLATE' &&
|
|
2294
2294
|
prompt
|
|
2295
2295
|
// <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
|
|
2296
|
-
// In that case we don’t want to make a report about it because it’s not a
|
|
2296
|
+
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
2297
2297
|
) {
|
|
2298
2298
|
// TODO: [🧠] Maybe put other executionTypes into report
|
|
2299
2299
|
executionReport.promptExecutions.push({
|
|
@@ -2311,7 +2311,7 @@
|
|
|
2311
2311
|
return [7 /*endfinally*/];
|
|
2312
2312
|
case 47:
|
|
2313
2313
|
if (expectError !== null && attempt === maxAttempts - 1) {
|
|
2314
|
-
throw new PromptbookExecutionError(spacetrim.spaceTrim(function (block) { return "\n
|
|
2314
|
+
throw new PromptbookExecutionError(spacetrim.spaceTrim(function (block) { return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ---\n Last error ").concat((expectError === null || expectError === void 0 ? void 0 : expectError.name) || '', ":\n ").concat(block((expectError === null || expectError === void 0 ? void 0 : expectError.message) || ''), "\n\n Last result:\n ").concat(resultString, "\n ---\n "); }));
|
|
2315
2315
|
}
|
|
2316
2316
|
_o.label = 48;
|
|
2317
2317
|
case 48:
|