@promptbook/remote-client 0.31.0-0 → 0.31.0-10
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/types.index.d.ts +2 -1
- package/esm/typings/_packages/utils.index.d.ts +6 -2
- package/esm/typings/execution/PromptResult.d.ts +38 -1
- package/esm/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +3 -0
- package/esm/typings/types/execution-report/ExecutionReportStringOptions.d.ts +13 -0
- package/esm/typings/types/execution-report/config.d.ts +8 -0
- package/esm/typings/types/execution-report/countWorkingDuration.d.ts +7 -0
- package/esm/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -0
- package/esm/typings/types/execution-report/executionReportJsonToString.d.ts +5 -1
- package/esm/typings/types/typeAliases.d.ts +16 -0
- package/esm/typings/utils/FromtoItems.d.ts +19 -0
- package/esm/typings/utils/extractParameters.d.ts +2 -0
- package/esm/typings/utils/extractVariables.d.ts +10 -0
- package/esm/typings/utils/extractVariables.test.d.ts +1 -0
- package/esm/typings/utils/formatNumber.d.ts +6 -0
- package/esm/typings/utils/formatNumber.test.d.ts +1 -0
- package/esm/typings/utils/getCurrentIsoDate.d.ts +7 -0
- package/esm/typings/utils/markdown/createMarkdownChart.d.ts +37 -0
- package/esm/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -0
- package/esm/typings/utils/markdown/createMarkdownTable.d.ts +7 -0
- package/esm/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -0
- package/esm/typings/utils/replaceParameters.d.ts +2 -0
- package/package.json +2 -2
- package/umd/typings/_packages/types.index.d.ts +2 -1
- package/umd/typings/_packages/utils.index.d.ts +6 -2
- package/umd/typings/execution/PromptResult.d.ts +38 -1
- package/umd/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +3 -0
- package/umd/typings/types/execution-report/ExecutionReportStringOptions.d.ts +13 -0
- package/umd/typings/types/execution-report/config.d.ts +8 -0
- package/umd/typings/types/execution-report/countWorkingDuration.d.ts +7 -0
- package/umd/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -0
- package/umd/typings/types/execution-report/executionReportJsonToString.d.ts +5 -1
- package/umd/typings/types/typeAliases.d.ts +16 -0
- package/umd/typings/utils/FromtoItems.d.ts +19 -0
- package/umd/typings/utils/extractParameters.d.ts +2 -0
- package/umd/typings/utils/extractVariables.d.ts +10 -0
- package/umd/typings/utils/extractVariables.test.d.ts +1 -0
- package/umd/typings/utils/formatNumber.d.ts +6 -0
- package/umd/typings/utils/formatNumber.test.d.ts +1 -0
- package/umd/typings/utils/getCurrentIsoDate.d.ts +7 -0
- package/umd/typings/utils/markdown/createMarkdownChart.d.ts +37 -0
- package/umd/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -0
- package/umd/typings/utils/markdown/createMarkdownTable.d.ts +7 -0
- package/umd/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -0
- package/umd/typings/utils/replaceParameters.d.ts +2 -0
|
@@ -18,7 +18,8 @@ import type { TaskProgress } from '../types/TaskProgress';
|
|
|
18
18
|
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
|
|
19
19
|
import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
20
20
|
import type { ILicense, IPersonProfile, IRepository, client_id, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_property, string_css_selector, string_css_value, 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_license_token, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptbk_url, string_ptbk_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_xml } from '../types/typeAliases';
|
|
21
|
-
|
|
21
|
+
import { FromtoItems } from '../utils/FromtoItems';
|
|
22
|
+
export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ILicense, IPersonProfile, IRepository, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptTemplatePipelineJson, PromptTemplatePipelineString, PtpExecutor, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_char_emoji, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_property, string_css_selector, string_css_value, 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_license_token, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptbk_url, string_ptbk_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_xml, };
|
|
22
23
|
/**
|
|
23
24
|
* TODO: !!! Filter out all the types that are not used in the library
|
|
24
25
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
2
|
+
import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
|
|
2
3
|
import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
|
|
3
4
|
import { EMOJIS, EMOJIS_IN_CATEGORIES } from '../utils/emojis';
|
|
4
5
|
import { CountUtils } from '../utils/expectation-counters';
|
|
@@ -17,8 +18,11 @@ import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormat
|
|
|
17
18
|
import { parseNumber } from '../utils/parseNumber';
|
|
18
19
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
19
20
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
20
|
-
import { replaceParameters } from '../utils/replaceParameters';
|
|
21
21
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
22
22
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
23
23
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
24
|
-
export { CountUtils, EMOJIS, EMOJIS_IN_CATEGORIES, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractOneBlockFromMarkdown, isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes,
|
|
24
|
+
export { CountUtils, EMOJIS, EMOJIS_IN_CATEGORIES, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractOneBlockFromMarkdown, isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
25
|
+
/**
|
|
26
|
+
* TODO: !!!! prune utils in 32
|
|
27
|
+
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
28
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { string_model_name } from '.././types/typeAliases';
|
|
1
|
+
import type { number_positive_or_zero, number_tokens, number_usd, string_date_iso8601, string_model_name } from '.././types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Prompt result is the simplest concept of execution.
|
|
4
4
|
* It is the result of executing one prompt _(NOT a template)_.
|
|
@@ -25,12 +25,49 @@ export interface PromptCommonResult {
|
|
|
25
25
|
* Name of the model used to generate the response
|
|
26
26
|
*/
|
|
27
27
|
readonly model: string_model_name;
|
|
28
|
+
/**
|
|
29
|
+
* Timing
|
|
30
|
+
*/
|
|
31
|
+
readonly timing: {
|
|
32
|
+
/**
|
|
33
|
+
* Start of the execution
|
|
34
|
+
*/
|
|
35
|
+
start: string_date_iso8601;
|
|
36
|
+
/**
|
|
37
|
+
* First token generated
|
|
38
|
+
*/
|
|
39
|
+
firstToken?: string_date_iso8601;
|
|
40
|
+
/**
|
|
41
|
+
* End of the execution
|
|
42
|
+
*/
|
|
43
|
+
complete: string_date_iso8601;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Usage of the prompt execution
|
|
47
|
+
*/
|
|
48
|
+
readonly usage: {
|
|
49
|
+
/**
|
|
50
|
+
* Cost of the execution in USD
|
|
51
|
+
*
|
|
52
|
+
* If the cost is unknown, the value is `'UNKNOWN'`
|
|
53
|
+
*/
|
|
54
|
+
price: (number_positive_or_zero & number_usd) | 'UNKNOWN';
|
|
55
|
+
/**
|
|
56
|
+
* Number of tokens used in the input aka. `prompt_tokens`
|
|
57
|
+
*/
|
|
58
|
+
inputTokens: number_tokens;
|
|
59
|
+
/**
|
|
60
|
+
* Number of tokens used in the output aka. `completion_tokens`
|
|
61
|
+
*/
|
|
62
|
+
outputTokens: number_tokens;
|
|
63
|
+
};
|
|
28
64
|
/**
|
|
29
65
|
* Raw response from the model
|
|
30
66
|
*/
|
|
31
67
|
readonly rawResponse: object;
|
|
32
68
|
}
|
|
33
69
|
/**
|
|
70
|
+
* TODO: [🧠] Maybe timing more accurate then seconds?
|
|
34
71
|
* TODO: [🧠] Should here be link to the prompt?
|
|
35
72
|
* TODO: [🧠] Maybe type raw properly - not onject but OpenAI.result.whatever
|
|
36
73
|
* TODO: [🧠] Maybe remove redundant raw.choices.text
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { number_percent } from '../typeAliases';
|
|
2
|
+
export type ExecutionReportStringOptions = {
|
|
3
|
+
taxRate: number_percent;
|
|
4
|
+
chartsWidth: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const ExecutionReportStringOptionsDefaults: {
|
|
7
|
+
taxRate: number;
|
|
8
|
+
chartsWidth: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* !!! Annotate
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ExecutionReportJson } from './ExecutionReportJson';
|
|
2
2
|
import type { ExecutionReportString } from './ExecutionReportString';
|
|
3
|
+
import type { ExecutionReportStringOptions } from './ExecutionReportStringOptions';
|
|
3
4
|
/**
|
|
4
5
|
* Converts execution report from JSON to string format
|
|
5
6
|
*/
|
|
6
|
-
export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson): ExecutionReportString;
|
|
7
|
+
export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson, options?: Partial<ExecutionReportStringOptions>): ExecutionReportString;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
10
|
+
*/
|
|
@@ -404,6 +404,22 @@ export type string_license_token = string_token;
|
|
|
404
404
|
export type string_password = string;
|
|
405
405
|
export type string_ssh_key = string;
|
|
406
406
|
export type string_pgp_key = string;
|
|
407
|
+
/**
|
|
408
|
+
* Semantic helper for `Date.toISOString()` result
|
|
409
|
+
*
|
|
410
|
+
* @example "2011-10-05T14:48:00.000Z".
|
|
411
|
+
* @see https://en.wikipedia.org/wiki/ISO_8601
|
|
412
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
|
413
|
+
*/
|
|
414
|
+
export type string_date_iso8601 = `${number}-${number}-${number}${string}${number}:${number}:${number}${string}`;
|
|
415
|
+
/**
|
|
416
|
+
* Semantic helper for US Dollars
|
|
417
|
+
*/
|
|
418
|
+
export type number_usd = number;
|
|
419
|
+
/**
|
|
420
|
+
* Semantic helper for number of tokens
|
|
421
|
+
*/
|
|
422
|
+
export type number_tokens = number_integer & number_positive_or_zero;
|
|
407
423
|
export type number_positive = number;
|
|
408
424
|
export type number_negative = number;
|
|
409
425
|
export type number_positive_or_zero = number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents items which are compared to each other
|
|
3
|
+
*/
|
|
4
|
+
export type FromtoItems = Array<{
|
|
5
|
+
/**
|
|
6
|
+
* The title of the item
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* The start of the item
|
|
11
|
+
*
|
|
12
|
+
* This can mean anything, like seconds, milliseconds, dollars, etc.
|
|
13
|
+
*/
|
|
14
|
+
from: number;
|
|
15
|
+
/**
|
|
16
|
+
* The end of the item
|
|
17
|
+
*/
|
|
18
|
+
to: number;
|
|
19
|
+
}>;
|
|
@@ -4,5 +4,7 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @param template the template with parameters in {curly} braces
|
|
6
6
|
* @returns the list of parameter names
|
|
7
|
+
*
|
|
8
|
+
* @private within the library
|
|
7
9
|
*/
|
|
8
10
|
export declare function extractParameters(template: string_template): Array<string_name>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { string_javascript, string_javascript_name } from '../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
4
|
+
*
|
|
5
|
+
* @param script from which to extract the variables
|
|
6
|
+
* @returns the list of variable names
|
|
7
|
+
*
|
|
8
|
+
* @private within the library
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractVariables(script: string_javascript): Array<string_javascript_name>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
import { FromtoItems } from '../FromtoItems';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a markdown chart
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a markdown chart.
|
|
8
|
+
*/
|
|
9
|
+
type CreateMarkdownChartOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* The header for the first column - the name of the item
|
|
12
|
+
*/
|
|
13
|
+
nameHeader: string;
|
|
14
|
+
/**
|
|
15
|
+
* The header for the second column - the value of the item
|
|
16
|
+
*/
|
|
17
|
+
valueHeader: string;
|
|
18
|
+
/**
|
|
19
|
+
* The items to be charted
|
|
20
|
+
*/
|
|
21
|
+
items: FromtoItems;
|
|
22
|
+
/**
|
|
23
|
+
* The width of the chart in squares
|
|
24
|
+
*/
|
|
25
|
+
width: number;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the unit shown in the chart
|
|
28
|
+
*/
|
|
29
|
+
unitName: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
|
|
33
|
+
*
|
|
34
|
+
* @private within the library
|
|
35
|
+
*/
|
|
36
|
+
export declare function createMarkdownChart(options: CreateMarkdownChartOptions): string_markdown;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { string_markdown, string_markdown_text } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Create a markdown table from a 2D array of strings
|
|
4
|
+
*
|
|
5
|
+
* @private within the library
|
|
6
|
+
*/
|
|
7
|
+
export declare function createMarkdownTable(table: Array<Array<string_markdown_text>>): string_markdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,5 +6,7 @@ import { Parameters } from '../types/Parameters';
|
|
|
6
6
|
* @param template the template with parameters in {curly} braces
|
|
7
7
|
* @param parameters the object with parameters
|
|
8
8
|
* @returns the template with replaced parameters
|
|
9
|
+
*
|
|
10
|
+
* @private within the library
|
|
9
11
|
*/
|
|
10
12
|
export declare function replaceParameters(template: string_template, parameters: Parameters): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-client",
|
|
3
|
-
"version": "0.31.0-
|
|
3
|
+
"version": "0.31.0-10",
|
|
4
4
|
"description": "Library to supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"socket.io-client": "4.7.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@promptbook/core": "0.31.0-
|
|
40
|
+
"@promptbook/core": "0.31.0-10"
|
|
41
41
|
},
|
|
42
42
|
"main": "./umd/index.umd.js",
|
|
43
43
|
"module": "./esm/index.es.js",
|
|
@@ -18,7 +18,8 @@ import type { TaskProgress } from '../types/TaskProgress';
|
|
|
18
18
|
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
|
|
19
19
|
import type { string_char_emoji } from '../types/typeAliasEmoji';
|
|
20
20
|
import type { ILicense, IPersonProfile, IRepository, client_id, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_property, string_css_selector, string_css_value, 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_license_token, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptbk_url, string_ptbk_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_xml } from '../types/typeAliases';
|
|
21
|
-
|
|
21
|
+
import { FromtoItems } from '../utils/FromtoItems';
|
|
22
|
+
export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ILicense, IPersonProfile, IRepository, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptTemplatePipelineJson, PromptTemplatePipelineString, PtpExecutor, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_char_emoji, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_property, string_css_selector, string_css_value, 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_license_token, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptbk_url, string_ptbk_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_xml, };
|
|
22
23
|
/**
|
|
23
24
|
* TODO: !!! Filter out all the types that are not used in the library
|
|
24
25
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
|
|
2
|
+
import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
|
|
2
3
|
import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
|
|
3
4
|
import { EMOJIS, EMOJIS_IN_CATEGORIES } from '../utils/emojis';
|
|
4
5
|
import { CountUtils } from '../utils/expectation-counters';
|
|
@@ -17,8 +18,11 @@ import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormat
|
|
|
17
18
|
import { parseNumber } from '../utils/parseNumber';
|
|
18
19
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
19
20
|
import { removeQuotes } from '../utils/removeQuotes';
|
|
20
|
-
import { replaceParameters } from '../utils/replaceParameters';
|
|
21
21
|
import { trimCodeBlock } from '../utils/trimCodeBlock';
|
|
22
22
|
import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
|
|
23
23
|
import { unwrapResult } from '../utils/unwrapResult';
|
|
24
|
-
export { CountUtils, EMOJIS, EMOJIS_IN_CATEGORIES, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractOneBlockFromMarkdown, isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes,
|
|
24
|
+
export { CountUtils, EMOJIS, EMOJIS_IN_CATEGORIES, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractOneBlockFromMarkdown, isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
|
|
25
|
+
/**
|
|
26
|
+
* TODO: !!!! prune utils in 32
|
|
27
|
+
* TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
|
|
28
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { string_model_name } from '.././types/typeAliases';
|
|
1
|
+
import type { number_positive_or_zero, number_tokens, number_usd, string_date_iso8601, string_model_name } from '.././types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Prompt result is the simplest concept of execution.
|
|
4
4
|
* It is the result of executing one prompt _(NOT a template)_.
|
|
@@ -25,12 +25,49 @@ export interface PromptCommonResult {
|
|
|
25
25
|
* Name of the model used to generate the response
|
|
26
26
|
*/
|
|
27
27
|
readonly model: string_model_name;
|
|
28
|
+
/**
|
|
29
|
+
* Timing
|
|
30
|
+
*/
|
|
31
|
+
readonly timing: {
|
|
32
|
+
/**
|
|
33
|
+
* Start of the execution
|
|
34
|
+
*/
|
|
35
|
+
start: string_date_iso8601;
|
|
36
|
+
/**
|
|
37
|
+
* First token generated
|
|
38
|
+
*/
|
|
39
|
+
firstToken?: string_date_iso8601;
|
|
40
|
+
/**
|
|
41
|
+
* End of the execution
|
|
42
|
+
*/
|
|
43
|
+
complete: string_date_iso8601;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Usage of the prompt execution
|
|
47
|
+
*/
|
|
48
|
+
readonly usage: {
|
|
49
|
+
/**
|
|
50
|
+
* Cost of the execution in USD
|
|
51
|
+
*
|
|
52
|
+
* If the cost is unknown, the value is `'UNKNOWN'`
|
|
53
|
+
*/
|
|
54
|
+
price: (number_positive_or_zero & number_usd) | 'UNKNOWN';
|
|
55
|
+
/**
|
|
56
|
+
* Number of tokens used in the input aka. `prompt_tokens`
|
|
57
|
+
*/
|
|
58
|
+
inputTokens: number_tokens;
|
|
59
|
+
/**
|
|
60
|
+
* Number of tokens used in the output aka. `completion_tokens`
|
|
61
|
+
*/
|
|
62
|
+
outputTokens: number_tokens;
|
|
63
|
+
};
|
|
28
64
|
/**
|
|
29
65
|
* Raw response from the model
|
|
30
66
|
*/
|
|
31
67
|
readonly rawResponse: object;
|
|
32
68
|
}
|
|
33
69
|
/**
|
|
70
|
+
* TODO: [🧠] Maybe timing more accurate then seconds?
|
|
34
71
|
* TODO: [🧠] Should here be link to the prompt?
|
|
35
72
|
* TODO: [🧠] Maybe type raw properly - not onject but OpenAI.result.whatever
|
|
36
73
|
* TODO: [🧠] Maybe remove redundant raw.choices.text
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { number_percent } from '../typeAliases';
|
|
2
|
+
export type ExecutionReportStringOptions = {
|
|
3
|
+
taxRate: number_percent;
|
|
4
|
+
chartsWidth: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const ExecutionReportStringOptionsDefaults: {
|
|
7
|
+
taxRate: number;
|
|
8
|
+
chartsWidth: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* !!! Annotate
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ExecutionReportJson } from './ExecutionReportJson';
|
|
2
2
|
import type { ExecutionReportString } from './ExecutionReportString';
|
|
3
|
+
import type { ExecutionReportStringOptions } from './ExecutionReportStringOptions';
|
|
3
4
|
/**
|
|
4
5
|
* Converts execution report from JSON to string format
|
|
5
6
|
*/
|
|
6
|
-
export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson): ExecutionReportString;
|
|
7
|
+
export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson, options?: Partial<ExecutionReportStringOptions>): ExecutionReportString;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
10
|
+
*/
|
|
@@ -404,6 +404,22 @@ export type string_license_token = string_token;
|
|
|
404
404
|
export type string_password = string;
|
|
405
405
|
export type string_ssh_key = string;
|
|
406
406
|
export type string_pgp_key = string;
|
|
407
|
+
/**
|
|
408
|
+
* Semantic helper for `Date.toISOString()` result
|
|
409
|
+
*
|
|
410
|
+
* @example "2011-10-05T14:48:00.000Z".
|
|
411
|
+
* @see https://en.wikipedia.org/wiki/ISO_8601
|
|
412
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
|
|
413
|
+
*/
|
|
414
|
+
export type string_date_iso8601 = `${number}-${number}-${number}${string}${number}:${number}:${number}${string}`;
|
|
415
|
+
/**
|
|
416
|
+
* Semantic helper for US Dollars
|
|
417
|
+
*/
|
|
418
|
+
export type number_usd = number;
|
|
419
|
+
/**
|
|
420
|
+
* Semantic helper for number of tokens
|
|
421
|
+
*/
|
|
422
|
+
export type number_tokens = number_integer & number_positive_or_zero;
|
|
407
423
|
export type number_positive = number;
|
|
408
424
|
export type number_negative = number;
|
|
409
425
|
export type number_positive_or_zero = number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents items which are compared to each other
|
|
3
|
+
*/
|
|
4
|
+
export type FromtoItems = Array<{
|
|
5
|
+
/**
|
|
6
|
+
* The title of the item
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* The start of the item
|
|
11
|
+
*
|
|
12
|
+
* This can mean anything, like seconds, milliseconds, dollars, etc.
|
|
13
|
+
*/
|
|
14
|
+
from: number;
|
|
15
|
+
/**
|
|
16
|
+
* The end of the item
|
|
17
|
+
*/
|
|
18
|
+
to: number;
|
|
19
|
+
}>;
|
|
@@ -4,5 +4,7 @@ import { string_name, string_template } from '../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @param template the template with parameters in {curly} braces
|
|
6
6
|
* @returns the list of parameter names
|
|
7
|
+
*
|
|
8
|
+
* @private within the library
|
|
7
9
|
*/
|
|
8
10
|
export declare function extractParameters(template: string_template): Array<string_name>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { string_javascript, string_javascript_name } from '../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
4
|
+
*
|
|
5
|
+
* @param script from which to extract the variables
|
|
6
|
+
* @returns the list of variable names
|
|
7
|
+
*
|
|
8
|
+
* @private within the library
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractVariables(script: string_javascript): Array<string_javascript_name>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
import { FromtoItems } from '../FromtoItems';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a markdown chart
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a markdown chart.
|
|
8
|
+
*/
|
|
9
|
+
type CreateMarkdownChartOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* The header for the first column - the name of the item
|
|
12
|
+
*/
|
|
13
|
+
nameHeader: string;
|
|
14
|
+
/**
|
|
15
|
+
* The header for the second column - the value of the item
|
|
16
|
+
*/
|
|
17
|
+
valueHeader: string;
|
|
18
|
+
/**
|
|
19
|
+
* The items to be charted
|
|
20
|
+
*/
|
|
21
|
+
items: FromtoItems;
|
|
22
|
+
/**
|
|
23
|
+
* The width of the chart in squares
|
|
24
|
+
*/
|
|
25
|
+
width: number;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the unit shown in the chart
|
|
28
|
+
*/
|
|
29
|
+
unitName: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
|
|
33
|
+
*
|
|
34
|
+
* @private within the library
|
|
35
|
+
*/
|
|
36
|
+
export declare function createMarkdownChart(options: CreateMarkdownChartOptions): string_markdown;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { string_markdown, string_markdown_text } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Create a markdown table from a 2D array of strings
|
|
4
|
+
*
|
|
5
|
+
* @private within the library
|
|
6
|
+
*/
|
|
7
|
+
export declare function createMarkdownTable(table: Array<Array<string_markdown_text>>): string_markdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,5 +6,7 @@ import { Parameters } from '../types/Parameters';
|
|
|
6
6
|
* @param template the template with parameters in {curly} braces
|
|
7
7
|
* @param parameters the object with parameters
|
|
8
8
|
* @returns the template with replaced parameters
|
|
9
|
+
*
|
|
10
|
+
* @private within the library
|
|
9
11
|
*/
|
|
10
12
|
export declare function replaceParameters(template: string_template, parameters: Parameters): string;
|