@promptbook/remote-server 0.71.0-0 → 0.72.0-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 +6 -5
- package/esm/index.es.js +7 -18
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +5 -11
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -12
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +2 -3
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -16
- package/esm/typings/src/config.d.ts +1 -14
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +0 -3
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -2
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +0 -5
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +8 -9
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +72 -0
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +0 -2
- package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +4 -3
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +15 -14
- package/esm/typings/src/formats/csv/{CsvFormatDefinition.d.ts → ListFormatDefinition.d.ts} +3 -6
- package/esm/typings/src/formats/index.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +3 -4
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +16 -0
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +3 -4
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +2 -9
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +0 -5
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
- package/esm/typings/src/utils/expectation-counters/index.d.ts +0 -3
- package/esm/typings/src/utils/{parameters/extractParameterNames.d.ts → extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/organization/{empty_object.d.ts → f.d.ts} +1 -5
- package/esm/typings/src/utils/{parameters/replaceParameters.d.ts → replaceParameters.d.ts} +2 -2
- package/package.json +13 -17
- package/umd/index.umd.js +7 -18
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +0 -23
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +0 -45
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +0 -20
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -40
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -10
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +0 -55
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +0 -62
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatCells.d.ts +0 -19
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +0 -74
- package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +0 -34
- package/esm/typings/src/execution/createPipelineExecutor/getContextForTemplate.d.ts +0 -10
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
- package/esm/typings/src/execution/createPipelineExecutor/getSamplesForTemplate.d.ts +0 -10
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +0 -30
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +0 -13
- package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +0 -19
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +0 -12
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +0 -27
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +0 -10
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.test.d.ts +0 -1
- /package/esm/typings/src/{utils/parameters/extractParameterNames.test.d.ts → execution/utils/usageToHuman.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{parameters/mapAvailableToExpectedParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{parameters/replaceParameters.test.d.ts → replaceParameters.test.d.ts} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import type { ErrorJson } from '../errors/utils/ErrorJson';
|
|
3
1
|
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
|
|
4
|
-
import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
5
2
|
import type { Parameters } from '../types/typeAliases';
|
|
3
|
+
import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
4
|
+
import type { ErrorJson } from '../errors/utils/ErrorJson';
|
|
6
5
|
import type { PromptResultUsage } from './PromptResultUsage';
|
|
7
6
|
/**
|
|
8
7
|
* @@@
|
|
@@ -15,7 +14,7 @@ export type PipelineExecutorResult = {
|
|
|
15
14
|
*
|
|
16
15
|
* Note: If the execution was not successful, there are only some of the result parameters
|
|
17
16
|
*/
|
|
18
|
-
readonly outputParameters:
|
|
17
|
+
readonly outputParameters: Parameters;
|
|
19
18
|
/**
|
|
20
19
|
* Whether the execution was successful, details are aviable in `executionReport`
|
|
21
20
|
*/
|
|
@@ -23,26 +22,26 @@ export type PipelineExecutorResult = {
|
|
|
23
22
|
/**
|
|
24
23
|
* Added usage of whole execution, detailed usage is aviable in `executionReport`
|
|
25
24
|
*/
|
|
26
|
-
readonly usage:
|
|
25
|
+
readonly usage: PromptResultUsage;
|
|
27
26
|
/**
|
|
28
27
|
* Errors that occured during the execution, details are aviable in `executionReport`
|
|
29
28
|
*/
|
|
30
|
-
readonly errors:
|
|
29
|
+
readonly errors: Array<ErrorJson>;
|
|
31
30
|
/**
|
|
32
31
|
* Warnings that occured during the execution, details are aviable in `executionReport`
|
|
33
32
|
*/
|
|
34
|
-
readonly warnings:
|
|
33
|
+
readonly warnings: Array<ErrorJson>;
|
|
35
34
|
/**
|
|
36
35
|
* The report of the execution with all details
|
|
37
36
|
*/
|
|
38
|
-
readonly executionReport:
|
|
37
|
+
readonly executionReport: ExecutionReportJson;
|
|
39
38
|
/**
|
|
40
39
|
* The prepared pipeline that was used for the execution
|
|
41
40
|
*
|
|
42
41
|
* Note: If you called `createPipelineExecutor` with fully prepared pipeline, this is the same object as this pipeline
|
|
43
42
|
* If you passed not fully prepared pipeline, this is same pipeline but fully prepared
|
|
44
43
|
*/
|
|
45
|
-
readonly preparedPipeline:
|
|
44
|
+
readonly preparedPipeline: PipelineJson;
|
|
46
45
|
};
|
|
47
46
|
/**
|
|
48
47
|
* TODO: [🧠] Should this file be in /execution or /types folder?
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
2
|
+
import type { ExecutionTools } from './ExecutionTools';
|
|
3
|
+
import type { PipelineExecutor } from './PipelineExecutor';
|
|
4
|
+
type CreatePipelineExecutorSettings = {
|
|
5
|
+
/**
|
|
6
|
+
* When executor does not satisfy expectations it will be retried this amount of times
|
|
7
|
+
*
|
|
8
|
+
* @default MAX_EXECUTION_ATTEMPTS
|
|
9
|
+
*/
|
|
10
|
+
readonly maxExecutionAttempts?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum number of tasks running in parallel
|
|
13
|
+
*
|
|
14
|
+
* @default MAX_PARALLEL_COUNT
|
|
15
|
+
*/
|
|
16
|
+
readonly maxParallelCount?: number;
|
|
17
|
+
/**
|
|
18
|
+
* If true, the preparation logs additional information
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
readonly isVerbose?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If you pass fully prepared pipeline, this does not matter
|
|
25
|
+
*
|
|
26
|
+
* Otherwise:
|
|
27
|
+
* If false or not set, warning is shown when pipeline is not prepared
|
|
28
|
+
* If true, warning is suppressed
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
readonly isNotPreparedWarningSupressed?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Options for `createPipelineExecutor`
|
|
36
|
+
*/
|
|
37
|
+
interface CreatePipelineExecutorOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The pipeline to be executed
|
|
40
|
+
*/
|
|
41
|
+
readonly pipeline: PipelineJson;
|
|
42
|
+
/**
|
|
43
|
+
* The execution tools to be used during the execution of the pipeline
|
|
44
|
+
*/
|
|
45
|
+
readonly tools: ExecutionTools;
|
|
46
|
+
/**
|
|
47
|
+
* Optional settings for the pipeline executor
|
|
48
|
+
*/
|
|
49
|
+
readonly settings?: Partial<CreatePipelineExecutorSettings>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates executor function from pipeline and execution tools.
|
|
53
|
+
*
|
|
54
|
+
* @returns The executor function
|
|
55
|
+
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
56
|
+
* @public exported from `@promptbook/core`
|
|
57
|
+
*/
|
|
58
|
+
export declare function createPipelineExecutor(options: CreatePipelineExecutorOptions): PipelineExecutor;
|
|
59
|
+
export {};
|
|
60
|
+
/**
|
|
61
|
+
* TODO:[main] !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
|
|
62
|
+
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
63
|
+
* TODO: [🧠][🌳] Use here `countTotalUsage` and put preparation and prepared pipiline to report
|
|
64
|
+
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
65
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
66
|
+
* TODO: [🧠] When not meet expectations in DIALOG_TEMPLATE, make some way to tell the user
|
|
67
|
+
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
|
|
68
|
+
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
69
|
+
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
70
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
71
|
+
* TODO: [🧠][💷] `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result BUT maybe NOT to preserve pure JSON object
|
|
72
|
+
*/
|
|
@@ -7,7 +7,7 @@ interface LindatAutomaticTranslatorOptions extends TranslatorOptions {
|
|
|
7
7
|
* @private still in development [🏳]
|
|
8
8
|
*/
|
|
9
9
|
export declare class LindatAutomaticTranslator implements AutomaticTranslator {
|
|
10
|
-
|
|
10
|
+
protected readonly options: LindatAutomaticTranslatorOptions;
|
|
11
11
|
constructor(options: LindatAutomaticTranslatorOptions);
|
|
12
12
|
translate(message: string): Promise<string>;
|
|
13
13
|
}
|
|
@@ -1,60 +1,4 @@
|
|
|
1
1
|
import type { PromptResultUsage } from '../PromptResultUsage';
|
|
2
|
-
/**
|
|
3
|
-
* @@@
|
|
4
|
-
*
|
|
5
|
-
* @public exported from `@promptbook/core`
|
|
6
|
-
*/
|
|
7
|
-
export declare const ZERO_USAGE: import("type-fest/source/readonly-deep").ReadonlyObjectDeep<{
|
|
8
|
-
readonly price: {
|
|
9
|
-
readonly value: 0;
|
|
10
|
-
};
|
|
11
|
-
readonly input: {
|
|
12
|
-
readonly tokensCount: {
|
|
13
|
-
readonly value: 0;
|
|
14
|
-
};
|
|
15
|
-
readonly charactersCount: {
|
|
16
|
-
readonly value: 0;
|
|
17
|
-
};
|
|
18
|
-
readonly wordsCount: {
|
|
19
|
-
readonly value: 0;
|
|
20
|
-
};
|
|
21
|
-
readonly sentencesCount: {
|
|
22
|
-
readonly value: 0;
|
|
23
|
-
};
|
|
24
|
-
readonly linesCount: {
|
|
25
|
-
readonly value: 0;
|
|
26
|
-
};
|
|
27
|
-
readonly paragraphsCount: {
|
|
28
|
-
readonly value: 0;
|
|
29
|
-
};
|
|
30
|
-
readonly pagesCount: {
|
|
31
|
-
readonly value: 0;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
readonly output: {
|
|
35
|
-
readonly tokensCount: {
|
|
36
|
-
readonly value: 0;
|
|
37
|
-
};
|
|
38
|
-
readonly charactersCount: {
|
|
39
|
-
readonly value: 0;
|
|
40
|
-
};
|
|
41
|
-
readonly wordsCount: {
|
|
42
|
-
readonly value: 0;
|
|
43
|
-
};
|
|
44
|
-
readonly sentencesCount: {
|
|
45
|
-
readonly value: 0;
|
|
46
|
-
};
|
|
47
|
-
readonly linesCount: {
|
|
48
|
-
readonly value: 0;
|
|
49
|
-
};
|
|
50
|
-
readonly paragraphsCount: {
|
|
51
|
-
readonly value: 0;
|
|
52
|
-
};
|
|
53
|
-
readonly pagesCount: {
|
|
54
|
-
readonly value: 0;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
}>;
|
|
58
2
|
/**
|
|
59
3
|
* Function `addUsage` will add multiple usages into one
|
|
60
4
|
*
|
|
@@ -24,6 +24,4 @@ export declare function checkExpectations(expectations: Expectations, value: str
|
|
|
24
24
|
export declare function isPassingExpectations(expectations: Expectations, value: string): boolean;
|
|
25
25
|
/**
|
|
26
26
|
* TODO: [💝] Unite object for expecting amount and format
|
|
27
|
-
* TODO: [🧠][🤠] This should be part of `TextFormatDefinition`
|
|
28
|
-
* Note: [💝] and [🤠] are interconnected together
|
|
29
27
|
*/
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the usage with no resources consumed
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/core`
|
|
5
|
+
*/
|
|
6
|
+
export declare const ZERO_USAGE: import("type-fest/source/readonly-deep").ReadonlyObjectDeep<{
|
|
7
|
+
readonly price: {
|
|
8
|
+
readonly value: 0;
|
|
9
|
+
};
|
|
10
|
+
readonly input: {
|
|
11
|
+
readonly tokensCount: {
|
|
12
|
+
readonly value: 0;
|
|
13
|
+
};
|
|
14
|
+
readonly charactersCount: {
|
|
15
|
+
readonly value: 0;
|
|
16
|
+
};
|
|
17
|
+
readonly wordsCount: {
|
|
18
|
+
readonly value: 0;
|
|
19
|
+
};
|
|
20
|
+
readonly sentencesCount: {
|
|
21
|
+
readonly value: 0;
|
|
22
|
+
};
|
|
23
|
+
readonly linesCount: {
|
|
24
|
+
readonly value: 0;
|
|
25
|
+
};
|
|
26
|
+
readonly paragraphsCount: {
|
|
27
|
+
readonly value: 0;
|
|
28
|
+
};
|
|
29
|
+
readonly pagesCount: {
|
|
30
|
+
readonly value: 0;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly output: {
|
|
34
|
+
readonly tokensCount: {
|
|
35
|
+
readonly value: 0;
|
|
36
|
+
};
|
|
37
|
+
readonly charactersCount: {
|
|
38
|
+
readonly value: 0;
|
|
39
|
+
};
|
|
40
|
+
readonly wordsCount: {
|
|
41
|
+
readonly value: 0;
|
|
42
|
+
};
|
|
43
|
+
readonly sentencesCount: {
|
|
44
|
+
readonly value: 0;
|
|
45
|
+
};
|
|
46
|
+
readonly linesCount: {
|
|
47
|
+
readonly value: 0;
|
|
48
|
+
};
|
|
49
|
+
readonly paragraphsCount: {
|
|
50
|
+
readonly value: 0;
|
|
51
|
+
};
|
|
52
|
+
readonly pagesCount: {
|
|
53
|
+
readonly value: 0;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Represents the usage with unknown resources consumed
|
|
59
|
+
*
|
|
60
|
+
* @public exported from `@promptbook/core`
|
|
61
|
+
*/
|
|
62
|
+
export declare const UNCERTAIN_USAGE: import("type-fest/source/readonly-deep").ReadonlyObjectDeep<{
|
|
63
|
+
readonly price: {
|
|
64
|
+
readonly value: 0;
|
|
65
|
+
readonly isUncertain: true;
|
|
66
|
+
};
|
|
67
|
+
readonly input: {
|
|
68
|
+
readonly tokensCount: {
|
|
69
|
+
readonly value: 0;
|
|
70
|
+
readonly isUncertain: true;
|
|
71
|
+
};
|
|
72
|
+
readonly charactersCount: {
|
|
73
|
+
readonly value: 0;
|
|
74
|
+
readonly isUncertain: true;
|
|
75
|
+
};
|
|
76
|
+
readonly wordsCount: {
|
|
77
|
+
readonly value: 0;
|
|
78
|
+
readonly isUncertain: true;
|
|
79
|
+
};
|
|
80
|
+
readonly sentencesCount: {
|
|
81
|
+
readonly value: 0;
|
|
82
|
+
readonly isUncertain: true;
|
|
83
|
+
};
|
|
84
|
+
readonly linesCount: {
|
|
85
|
+
readonly value: 0;
|
|
86
|
+
readonly isUncertain: true;
|
|
87
|
+
};
|
|
88
|
+
readonly paragraphsCount: {
|
|
89
|
+
readonly value: 0;
|
|
90
|
+
readonly isUncertain: true;
|
|
91
|
+
};
|
|
92
|
+
readonly pagesCount: {
|
|
93
|
+
readonly value: 0;
|
|
94
|
+
readonly isUncertain: true;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
readonly output: {
|
|
98
|
+
readonly tokensCount: {
|
|
99
|
+
readonly value: 0;
|
|
100
|
+
readonly isUncertain: true;
|
|
101
|
+
};
|
|
102
|
+
readonly charactersCount: {
|
|
103
|
+
readonly value: 0;
|
|
104
|
+
readonly isUncertain: true;
|
|
105
|
+
};
|
|
106
|
+
readonly wordsCount: {
|
|
107
|
+
readonly value: 0;
|
|
108
|
+
readonly isUncertain: true;
|
|
109
|
+
};
|
|
110
|
+
readonly sentencesCount: {
|
|
111
|
+
readonly value: 0;
|
|
112
|
+
readonly isUncertain: true;
|
|
113
|
+
};
|
|
114
|
+
readonly linesCount: {
|
|
115
|
+
readonly value: 0;
|
|
116
|
+
readonly isUncertain: true;
|
|
117
|
+
};
|
|
118
|
+
readonly paragraphsCount: {
|
|
119
|
+
readonly value: 0;
|
|
120
|
+
readonly isUncertain: true;
|
|
121
|
+
};
|
|
122
|
+
readonly pagesCount: {
|
|
123
|
+
readonly value: 0;
|
|
124
|
+
readonly isUncertain: true;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}>;
|
|
@@ -7,10 +7,11 @@ import type { PromptResultUsage } from '../PromptResultUsage';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function usageToHuman(usage: PromptResultUsage): string_markdown;
|
|
9
9
|
/**
|
|
10
|
-
* TODO:
|
|
11
|
-
* TODO:
|
|
12
|
-
* TODO:
|
|
10
|
+
* TODO: Use "$1" not "1 USD"
|
|
11
|
+
* TODO: Use markdown formatting like "Cost approximately **$1**"
|
|
12
|
+
* TODO: Report in minutes, seconds, days NOT 0.1 hours
|
|
13
13
|
* TODO: [🧠] Maybe make from `uncertainNumberToHuman` separate exported utility
|
|
14
|
+
* TODO: When negligible usage, report "Negligible" or just don't report it
|
|
14
15
|
* TODO: [🧠] Maybe use "~" instead of "approximately"
|
|
15
16
|
* TODO: [🏛] Maybe make some markdown builder
|
|
16
17
|
*/
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import type { string_mime_type } from '../../types/typeAliases';
|
|
2
2
|
import type { string_name } from '../../types/typeAliases';
|
|
3
|
-
import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
4
|
-
import type { empty_object } from '../../utils/organization/empty_object';
|
|
5
|
-
import type { FormatSubvalueDefinition } from './FormatSubvalueDefinition';
|
|
6
3
|
/**
|
|
7
4
|
* A format definition is a set of functions that define how to validate, heal and convert response from LLM
|
|
8
5
|
*
|
|
9
|
-
* @@@ Describe setting vs schema
|
|
10
|
-
*
|
|
11
6
|
* @see https://github.com/webgptorg/promptbook/discussions/36
|
|
12
7
|
* @private still in development [🏢]
|
|
13
8
|
*/
|
|
14
|
-
export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string,
|
|
9
|
+
export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSchema extends object> = {
|
|
15
10
|
/**
|
|
16
11
|
* The name of the format used in .ptbk.md files
|
|
17
12
|
*
|
|
18
13
|
* @sample "JSON"
|
|
19
14
|
*/
|
|
20
|
-
readonly
|
|
15
|
+
readonly name: string_name;
|
|
21
16
|
/**
|
|
22
|
-
* Aliases for the
|
|
17
|
+
* Aliases for the name
|
|
23
18
|
*/
|
|
24
|
-
readonly aliases?: Array<string_name
|
|
19
|
+
readonly aliases?: Array<string_name>;
|
|
25
20
|
/**
|
|
26
21
|
* The mime type of the format (if any)
|
|
27
22
|
*
|
|
@@ -34,7 +29,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
34
29
|
* @param value The value to check, for example "{\"foo\": true}"
|
|
35
30
|
* @param schema Optional schema to do extra validation
|
|
36
31
|
*/
|
|
37
|
-
isValid(value: string,
|
|
32
|
+
isValid(value: string, schema?: TSchema): value is TValue;
|
|
38
33
|
/**
|
|
39
34
|
* Check if a first part of a value is valid
|
|
40
35
|
*
|
|
@@ -43,7 +38,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
43
38
|
* @param partialValue Partial value to check, for example "{\"foo\": t"
|
|
44
39
|
* @param schema Optional schema to do extra validation
|
|
45
40
|
*/
|
|
46
|
-
canBeValid(partialValue: string,
|
|
41
|
+
canBeValid(partialValue: string, schema?: TSchema): partialValue is TPartialValue;
|
|
47
42
|
/**
|
|
48
43
|
* Heal a value to make it valid if possible
|
|
49
44
|
*
|
|
@@ -54,11 +49,17 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
54
49
|
* @param scheme
|
|
55
50
|
* @throws {Error} If the value cannot be healed
|
|
56
51
|
*/
|
|
57
|
-
heal(value: string,
|
|
52
|
+
heal(value: string, scheme?: TSchema): TValue;
|
|
58
53
|
/**
|
|
59
|
-
*
|
|
54
|
+
* Parses just the values and removes structural information
|
|
55
|
+
*
|
|
56
|
+
* Note: This is useful when you want to combine format expectations with counting words, characters,...
|
|
57
|
+
*
|
|
58
|
+
* @param value The value to check, for example "{\"name\": "John Smith"}"
|
|
59
|
+
* @param schema Optional schema
|
|
60
|
+
* @example "{\"name\": "John Smith"}" -> ["John Smith"]
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
extractValues(value: string, schema?: TSchema): Array<string>;
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
65
|
* TODO: [♏] Add some prepare hook to modify prompt according to the format
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
|
-
import type { CsvSettings } from './CsvSettings';
|
|
4
2
|
/**
|
|
5
3
|
* Definition for CSV spreadsheet
|
|
6
4
|
*
|
|
7
|
-
* @
|
|
8
|
-
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
5
|
+
* @private still in development [🏢]
|
|
9
6
|
*/
|
|
10
|
-
export declare const CsvFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const CsvFormatDefinition: FormatDefinition<string, string, object>;
|
|
11
8
|
/**
|
|
12
9
|
* TODO: [🍓] In `CsvFormatDefinition` implement simple `isValid`
|
|
13
10
|
* TODO: [🍓] In `CsvFormatDefinition` implement partial `canBeValid`
|
|
14
11
|
* TODO: [🍓] In `CsvFormatDefinition` implement `heal
|
|
15
|
-
* TODO: [🍓] In `CsvFormatDefinition` implement `
|
|
12
|
+
* TODO: [🍓] In `CsvFormatDefinition` implement `extractValues`
|
|
16
13
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
17
14
|
*/
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @private internal index of `...` <- TODO [🏢]
|
|
5
5
|
*/
|
|
6
|
-
export declare const FORMAT_DEFINITIONS:
|
|
6
|
+
export declare const FORMAT_DEFINITIONS: import("./_common/FormatDefinition").FormatDefinition<string, string, object>[];
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
2
|
/**
|
|
4
3
|
* Definition for JSON format
|
|
5
4
|
*
|
|
6
5
|
* @private still in development [🏢]
|
|
7
6
|
*/
|
|
8
|
-
export declare const JsonFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const JsonFormatDefinition: FormatDefinition<string, string, object>;
|
|
9
8
|
/**
|
|
10
9
|
* TODO: [🧠] Maybe propper instance of object
|
|
11
10
|
* TODO: [0] Make string_serialized_json
|
|
12
|
-
* TODO: [1] Make type for JSON
|
|
11
|
+
* TODO: [1] Make type for JSON Schema
|
|
13
12
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
14
13
|
* TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
|
|
15
14
|
* TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
|
|
16
15
|
* TODO: [🍓] In `JsonFormatDefinition` implement `heal
|
|
17
|
-
* TODO: [🍓] In `JsonFormatDefinition` implement `
|
|
16
|
+
* TODO: [🍓] In `JsonFormatDefinition` implement `extractValues`
|
|
18
17
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
19
18
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Definition for list of multiple items
|
|
4
|
+
*
|
|
5
|
+
* Note: list is just a string with multiple lines or multiple items separated by comma
|
|
6
|
+
*
|
|
7
|
+
* @private still in development [🏢]
|
|
8
|
+
*/
|
|
9
|
+
export declare const ListFormatDefinition: FormatDefinition<string, string, object>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🍓] In `ListFormatDefinition` implement simple `isValid`
|
|
12
|
+
* TODO: [🍓] In `ListFormatDefinition` implement partial `canBeValid`
|
|
13
|
+
* TODO: [🍓] In `ListFormatDefinition` implement `heal
|
|
14
|
+
* TODO: [🍓] In `ListFormatDefinition` implement `extractValues`
|
|
15
|
+
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
16
|
+
*/
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
2
|
/**
|
|
4
3
|
* Definition for XML format
|
|
5
4
|
*
|
|
6
5
|
* @private still in development [🏢]
|
|
7
6
|
*/
|
|
8
|
-
export declare const XmlFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const XmlFormatDefinition: FormatDefinition<string, string, object>;
|
|
9
8
|
/**
|
|
10
9
|
* TODO: [🧠] Maybe propper instance of object
|
|
11
10
|
* TODO: [0] Make string_serialized_xml
|
|
12
|
-
* TODO: [1] Make type for XML
|
|
11
|
+
* TODO: [1] Make type for XML Schema
|
|
13
12
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
14
13
|
* TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
|
|
15
14
|
* TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
|
|
16
15
|
* TODO: [🍓] In `XmlFormatDefinition` implement `heal
|
|
17
|
-
* TODO: [🍓] In `XmlFormatDefinition` implement `
|
|
16
|
+
* TODO: [🍓] In `XmlFormatDefinition` implement `extractValues`
|
|
18
17
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
19
18
|
*/
|
|
@@ -8,7 +8,7 @@ import type { CallbackInterfaceToolsOptions } from './CallbackInterfaceToolsOpti
|
|
|
8
8
|
* @public exported from `@promptbook/core`
|
|
9
9
|
*/
|
|
10
10
|
export declare class CallbackInterfaceTools implements UserInterfaceTools {
|
|
11
|
-
|
|
11
|
+
protected readonly options: CallbackInterfaceToolsOptions;
|
|
12
12
|
constructor(options: CallbackInterfaceToolsOptions);
|
|
13
13
|
/**
|
|
14
14
|
* Trigger the custom callback function
|
|
@@ -10,7 +10,7 @@ import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/U
|
|
|
10
10
|
* @public exported from `@promptbook/browser`
|
|
11
11
|
*/
|
|
12
12
|
export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
|
|
13
|
-
|
|
13
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
14
14
|
constructor(options?: CommonExecutionToolsOptions);
|
|
15
15
|
/**
|
|
16
16
|
* Trigger window.DIALOG TEMPLATE
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
1
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
@@ -13,7 +14,7 @@ import type { AnthropicClaudeExecutionToolsDirectOptions } from './AnthropicClau
|
|
|
13
14
|
* @deprecated use `createAnthropicClaudeExecutionTools` instead
|
|
14
15
|
*/
|
|
15
16
|
export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
17
|
+
protected readonly options: AnthropicClaudeExecutionToolsDirectOptions;
|
|
17
18
|
/**
|
|
18
19
|
* Anthropic Claude API client.
|
|
19
20
|
*/
|
|
@@ -26,7 +27,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
|
|
|
26
27
|
constructor(options?: AnthropicClaudeExecutionToolsDirectOptions);
|
|
27
28
|
get title(): string_title & string_markdown_text;
|
|
28
29
|
get description(): string_markdown;
|
|
29
|
-
|
|
30
|
+
getClient(): Promise<Anthropic>;
|
|
30
31
|
/**
|
|
31
32
|
* Check the `options` passed to `constructor`
|
|
32
33
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OpenAIClient } from '@azure/openai';
|
|
1
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
@@ -13,7 +14,7 @@ import type { AzureOpenAiExecutionToolsOptions } from './AzureOpenAiExecutionToo
|
|
|
13
14
|
* @public exported from `@promptbook/azure-openai`
|
|
14
15
|
*/
|
|
15
16
|
export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
17
|
+
protected readonly options: AzureOpenAiExecutionToolsOptions;
|
|
17
18
|
/**
|
|
18
19
|
* OpenAI Azure API client.
|
|
19
20
|
*/
|
|
@@ -26,7 +27,7 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
|
26
27
|
constructor(options: AzureOpenAiExecutionToolsOptions);
|
|
27
28
|
get title(): string_title & string_markdown_text;
|
|
28
29
|
get description(): string_markdown;
|
|
29
|
-
|
|
30
|
+
getClient(): Promise<OpenAIClient>;
|
|
30
31
|
/**
|
|
31
32
|
* Check the `options` passed to `constructor`
|
|
32
33
|
*/
|
|
@@ -13,7 +13,7 @@ import type { string_title } from '../../types/typeAliases';
|
|
|
13
13
|
* @public exported from `@promptbook/fake-llm`
|
|
14
14
|
*/
|
|
15
15
|
export declare class MockedEchoLlmExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
16
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
17
17
|
constructor(options?: CommonExecutionToolsOptions);
|
|
18
18
|
get title(): string_title & string_markdown_text;
|
|
19
19
|
get description(): string_markdown;
|
|
@@ -14,7 +14,7 @@ import type { string_title } from '../../types/typeAliases';
|
|
|
14
14
|
* @public exported from `@promptbook/fake-llm`
|
|
15
15
|
*/
|
|
16
16
|
export declare class MockedFackedLlmExecutionTools implements LlmExecutionTools {
|
|
17
|
-
|
|
17
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
18
18
|
constructor(options?: CommonExecutionToolsOptions);
|
|
19
19
|
get title(): string_title & string_markdown_text;
|
|
20
20
|
get description(): string_markdown;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
2
|
+
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
3
|
+
import type { Prompt } from '../../types/Prompt';
|
|
4
|
+
import type { string_markdown } from '../../types/typeAliases';
|
|
5
|
+
import type { string_markdown_text } from '../../types/typeAliases';
|
|
6
|
+
import type { string_title } from '../../types/typeAliases';
|
|
7
|
+
import type { OpenAiAssistantExecutionToolsOptions } from './OpenAiAssistantExecutionToolsOptions';
|
|
8
|
+
import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
9
|
+
/**
|
|
10
|
+
* Execution Tools for calling OpenAI API Assistants
|
|
11
|
+
*
|
|
12
|
+
* This is usefull for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
13
|
+
*
|
|
14
|
+
* @public exported from `@promptbook/openai`
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
|
|
17
|
+
private readonly assistantId?;
|
|
18
|
+
/**
|
|
19
|
+
* Creates OpenAI Execution Tools.
|
|
20
|
+
*
|
|
21
|
+
* @param options which are relevant are directly passed to the OpenAI client
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: OpenAiAssistantExecutionToolsOptions);
|
|
24
|
+
get title(): string_title & string_markdown_text;
|
|
25
|
+
get description(): string_markdown;
|
|
26
|
+
/**
|
|
27
|
+
* Calls OpenAI API to use a chat model.
|
|
28
|
+
*/
|
|
29
|
+
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* TODO: !!!!!! DO not use colors - can be used in browser
|
|
33
|
+
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
34
|
+
* TODO: Maybe make custom OpenAiError
|
|
35
|
+
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
36
|
+
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
37
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClientOptions } from 'openai';
|
|
2
|
+
import type { string_token } from '../../types/typeAliases';
|
|
3
|
+
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Options for `OpenAiAssistantExecutionTools`
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/openai`
|
|
8
|
+
*/
|
|
9
|
+
export type OpenAiAssistantExecutionToolsOptions = OpenAiExecutionToolsOptions & ClientOptions & {
|
|
10
|
+
/**
|
|
11
|
+
* Which assistant to use
|
|
12
|
+
*/
|
|
13
|
+
assistantId?: string_token;
|
|
14
|
+
};
|