@promptbook/types 0.61.0-13 → 0.61.0-14
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/index.es.js +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +6 -3
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/esm/typings/src/config.d.ts +4 -0
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +7 -7
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/esm/typings/src/execution/PromptResult.d.ts +14 -56
- package/esm/typings/src/execution/PromptResultUsage.d.ts +26 -0
- package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +53 -14
- package/esm/typings/src/types/ModelVariant.d.ts +14 -0
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +45 -1
- package/esm/typings/src/types/typeAliases.d.ts +11 -0
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
- package/esm/typings/src/utils/organization/{TODO.d.ts → TODO_any.d.ts} +1 -1
- package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/esm/typings/src/utils/organization/really_any.d.ts +1 -1
- package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1 -1
- package/umd/typings/src/_packages/types.index.d.ts +6 -3
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/umd/typings/src/config.d.ts +4 -0
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
- package/umd/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +7 -7
- package/umd/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/umd/typings/src/execution/PromptResult.d.ts +14 -56
- package/umd/typings/src/execution/PromptResultUsage.d.ts +26 -0
- package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/umd/typings/src/execution/utils/addUsage.d.ts +1 -1
- package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +3 -3
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
- package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/umd/typings/src/types/ModelRequirements.d.ts +53 -14
- package/umd/typings/src/types/ModelVariant.d.ts +14 -0
- package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/umd/typings/src/types/Prompt.d.ts +45 -1
- package/umd/typings/src/types/typeAliases.d.ts +11 -0
- package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
- package/umd/typings/src/utils/organization/{TODO.d.ts → TODO_any.d.ts} +1 -1
- package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/umd/typings/src/utils/organization/really_any.d.ts +1 -1
- package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AvailableModel } from '../../execution/LlmExecutionTools';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
3
|
+
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
|
+
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
5
|
+
import type { EmbeddingPromptResult } from '../../execution/PromptResult';
|
|
6
|
+
import type { ChatPrompt } from '../../types/Prompt';
|
|
7
|
+
import type { CompletionPrompt } from '../../types/Prompt';
|
|
8
|
+
import type { EmbeddingPrompt } from '../../types/Prompt';
|
|
7
9
|
import type { string_markdown } from '../../types/typeAliases';
|
|
8
10
|
import type { string_markdown_text } from '../../types/typeAliases';
|
|
9
11
|
import type { string_title } from '../../types/typeAliases';
|
|
@@ -28,15 +30,15 @@ export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
|
|
|
28
30
|
/**
|
|
29
31
|
* Calls remote proxy server to use a chat model
|
|
30
32
|
*/
|
|
31
|
-
callChatModel(prompt:
|
|
33
|
+
callChatModel(prompt: ChatPrompt): Promise<ChatPromptResult>;
|
|
32
34
|
/**
|
|
33
35
|
* Calls remote proxy server to use a completion model
|
|
34
36
|
*/
|
|
35
|
-
callCompletionModel(prompt:
|
|
37
|
+
callCompletionModel(prompt: CompletionPrompt): Promise<CompletionPromptResult>;
|
|
36
38
|
/**
|
|
37
39
|
* Calls remote proxy server to use a embedding model
|
|
38
40
|
*/
|
|
39
|
-
callEmbeddingModel(prompt:
|
|
41
|
+
callEmbeddingModel(prompt: EmbeddingPrompt): Promise<EmbeddingPromptResult>;
|
|
40
42
|
/**
|
|
41
43
|
* Calls remote proxy server to use both completion or chat model
|
|
42
44
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { really_unknown } from '../../../utils/organization/really_unknown';
|
|
1
2
|
/**
|
|
2
3
|
* Converts anything to string that can be used for debugging and logging
|
|
3
4
|
*
|
|
4
5
|
* @param value String value for logging
|
|
5
6
|
* @private Internal util
|
|
6
7
|
*/
|
|
7
|
-
export declare function unknownToString(value:
|
|
8
|
+
export declare function unknownToString(value: really_unknown): string;
|
|
@@ -1,28 +1,67 @@
|
|
|
1
|
+
import type { ModelVariant } from './ModelVariant';
|
|
1
2
|
import type { number_model_temperature } from './typeAliases';
|
|
2
3
|
import type { number_seed } from './typeAliases';
|
|
3
4
|
import type { string_model_name } from './typeAliases';
|
|
4
5
|
import type { string_system_message } from './typeAliases';
|
|
5
|
-
export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT", "EMBEDDING"];
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Abstract way to specify the LLM.
|
|
8
|
+
* It does not specify the LLM with concrete version itself, only the requirements for the LLM.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - **CHAT** - model that takes prompt and previous messages and returns response
|
|
10
|
+
* Note: This is fully serializable as JSON
|
|
11
|
+
* @see https://github.com/webgptorg/promptbook#model-requirements
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
13
|
+
export type ModelRequirements = CompletionModelRequirements | ChatModelRequirements | EmbeddingModelRequirements;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Model requirements for the completion variant
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Note: This is fully serializable as JSON
|
|
18
|
+
*/
|
|
19
|
+
export type CompletionModelRequirements = CommonModelRequirements & {
|
|
20
|
+
/**
|
|
21
|
+
* Completion model variant
|
|
22
|
+
*/
|
|
23
|
+
modelVariant: 'COMPLETION';
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Model requirements for the chat variant
|
|
27
|
+
*
|
|
28
|
+
* Note: This is fully serializable as JSON
|
|
18
29
|
*/
|
|
19
|
-
export type
|
|
30
|
+
export type ChatModelRequirements = CommonModelRequirements & {
|
|
31
|
+
/**
|
|
32
|
+
* Chat model variant
|
|
33
|
+
*/
|
|
34
|
+
modelVariant: 'CHAT';
|
|
35
|
+
/**
|
|
36
|
+
* System message to be used in the model
|
|
37
|
+
*/
|
|
38
|
+
readonly systemMessage?: string_system_message;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Model requirements for the embedding variant
|
|
42
|
+
*
|
|
43
|
+
* Note: This is fully serializable as JSON
|
|
44
|
+
*/
|
|
45
|
+
export type EmbeddingModelRequirements = CommonModelRequirements & {
|
|
46
|
+
/**
|
|
47
|
+
* Embedding model variant
|
|
48
|
+
*/
|
|
49
|
+
modelVariant: 'EMBEDDING';
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Common properties for all model requirements variants
|
|
53
|
+
*
|
|
54
|
+
* Note: This is fully serializable as JSON
|
|
55
|
+
*/
|
|
56
|
+
export type CommonModelRequirements = {
|
|
20
57
|
/**
|
|
21
58
|
* Model variant describes the very general type of the model
|
|
22
59
|
*
|
|
23
|
-
* There are
|
|
60
|
+
* There are 3 variants:
|
|
24
61
|
* - **COMPLETION** - model that takes prompt and writes the rest of the text
|
|
25
62
|
* - **CHAT** - model that takes prompt and previous messages and returns response
|
|
63
|
+
* - **EMBEDDING** - model that takes prompt and returns embedding
|
|
64
|
+
* <- [🤖]
|
|
26
65
|
*/
|
|
27
66
|
readonly modelVariant: ModelVariant;
|
|
28
67
|
/**
|
|
@@ -34,10 +73,6 @@ export type ModelRequirements = {
|
|
|
34
73
|
* @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
|
|
35
74
|
*/
|
|
36
75
|
readonly modelName?: string_model_name;
|
|
37
|
-
/**
|
|
38
|
-
* System message to be used in the model
|
|
39
|
-
*/
|
|
40
|
-
readonly systemMessage?: string_system_message;
|
|
41
76
|
/**
|
|
42
77
|
* The temperature of the model
|
|
43
78
|
*
|
|
@@ -50,10 +85,13 @@ export type ModelRequirements = {
|
|
|
50
85
|
readonly seed?: number_seed;
|
|
51
86
|
/**
|
|
52
87
|
* Maximum number of tokens that can be generated by the model
|
|
88
|
+
*
|
|
89
|
+
* Note: [🌾]
|
|
53
90
|
*/
|
|
54
91
|
readonly maxTokens?: number;
|
|
55
92
|
};
|
|
56
93
|
/**
|
|
94
|
+
* TODO: [🔼] !!!! Export all from `@promptbook/types`
|
|
57
95
|
* TODO: [🧠][🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (simmilar that `user` identification is not here)
|
|
58
96
|
* TODO: [🧠][💱] Add more model options: `stop_token`, `logit_bias`, `logprobs` (`top_logprobs`), `top_k`, `top_p`, `presence_penalty`, `frequency_penalty`, `bestOf`, `logitBias`, `logitBiasType`,...
|
|
59
97
|
* [💱] Probbably keep using just `temperature` in Promptbook (not `top_k` and `top_p`)
|
|
@@ -61,4 +99,5 @@ export type ModelRequirements = {
|
|
|
61
99
|
* TODO: Maybe figure out better word than "variant"
|
|
62
100
|
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
63
101
|
* TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
|
|
102
|
+
* TODO: [🧄] Replace all "github.com/webgptorg/promptbook#xxx" with "ptbk.io/xxx"
|
|
64
103
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@
|
|
3
|
+
*
|
|
4
|
+
* @private for `ModelVariant` and `modelCommandParser`
|
|
5
|
+
*/
|
|
6
|
+
export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT", "EMBEDDING"];
|
|
7
|
+
/**
|
|
8
|
+
* Model variant describes the very general type of the model
|
|
9
|
+
*
|
|
10
|
+
* There are two variants:
|
|
11
|
+
* - **COMPLETION** - model that takes prompt and writes the rest of the text
|
|
12
|
+
* - **CHAT** - model that takes prompt and previous messages and returns response
|
|
13
|
+
*/
|
|
14
|
+
export type ModelVariant = typeof MODEL_VARIANTS[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChatModelRequirements } from '../ModelRequirements';
|
|
2
2
|
import type { number_id } from '../typeAliases';
|
|
3
3
|
import type { string_name } from '../typeAliases';
|
|
4
4
|
import type { string_persona_description } from '../typeAliases';
|
|
@@ -30,9 +30,7 @@ export type PersonaPreparedJson = PersonaJson & {
|
|
|
30
30
|
*
|
|
31
31
|
* Note: The model must be CHAT variant to be usable through persona
|
|
32
32
|
*/
|
|
33
|
-
readonly modelRequirements:
|
|
34
|
-
readonly modelVariant: 'CHAT';
|
|
35
|
-
};
|
|
33
|
+
readonly modelRequirements: ChatModelRequirements;
|
|
36
34
|
/**
|
|
37
35
|
* List of preparation ids that were used to prepare this persona
|
|
38
36
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PromptResultUsage } from '../../execution/
|
|
1
|
+
import type { PromptResultUsage } from '../../execution/PromptResultUsage';
|
|
2
2
|
import type { string_promptbook_version } from '../../version';
|
|
3
3
|
import type { number_id } from '../typeAliases';
|
|
4
4
|
export type PreparationJson = {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ExpectFormatCommand } from '../commands/EXPECT/ExpectFormatCommand';
|
|
2
2
|
import type { PostprocessingFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
3
|
+
import type { ChatModelRequirements } from './ModelRequirements';
|
|
4
|
+
import type { CompletionModelRequirements } from './ModelRequirements';
|
|
5
|
+
import type { EmbeddingModelRequirements } from './ModelRequirements';
|
|
3
6
|
import type { ModelRequirements } from './ModelRequirements';
|
|
4
7
|
import type { Expectations } from './PipelineJson/Expectations';
|
|
5
8
|
import type { string_parameter_name } from './typeAliases';
|
|
@@ -13,7 +16,46 @@ import type { string_title } from './typeAliases';
|
|
|
13
16
|
* Note: [🛫] This is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
14
17
|
* @see https://github.com/webgptorg/promptbook#prompt
|
|
15
18
|
*/
|
|
16
|
-
export type Prompt =
|
|
19
|
+
export type Prompt = CompletionPrompt | ChatPrompt | EmbeddingPrompt;
|
|
20
|
+
/**
|
|
21
|
+
* Completion prompt
|
|
22
|
+
*
|
|
23
|
+
* Note: [🛫] This is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
24
|
+
*/
|
|
25
|
+
export type CompletionPrompt = CommonPrompt & {
|
|
26
|
+
/**
|
|
27
|
+
* Requirements for completion model
|
|
28
|
+
*/
|
|
29
|
+
modelRequirements: CompletionModelRequirements;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Chat prompt
|
|
33
|
+
*
|
|
34
|
+
* Note: [🛫] This is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
35
|
+
*/
|
|
36
|
+
export type ChatPrompt = CommonPrompt & {
|
|
37
|
+
/**
|
|
38
|
+
* Requirements for chat model
|
|
39
|
+
*/
|
|
40
|
+
modelRequirements: ChatModelRequirements;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Embedding prompt
|
|
44
|
+
*
|
|
45
|
+
* Note: [🛫] This is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
46
|
+
*/
|
|
47
|
+
export type EmbeddingPrompt = CommonPrompt & {
|
|
48
|
+
/**
|
|
49
|
+
* Requirements for chat model
|
|
50
|
+
*/
|
|
51
|
+
modelRequirements: EmbeddingModelRequirements;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Common properties for all prompt results
|
|
55
|
+
*
|
|
56
|
+
* Note: This is fully serializable as JSON
|
|
57
|
+
*/
|
|
58
|
+
export type CommonPrompt = {
|
|
17
59
|
/**
|
|
18
60
|
* The title of the prompt
|
|
19
61
|
*
|
|
@@ -63,6 +105,8 @@ export type Prompt = {
|
|
|
63
105
|
readonly parameters: Record<string_parameter_name, string_parameter_value>;
|
|
64
106
|
};
|
|
65
107
|
/**
|
|
108
|
+
* TODO: [🔼] !!!! Export all from `@promptbook/types`
|
|
109
|
+
* TODO: [🧄] Replace all "github.com/webgptorg/promptbook#xxx" with "ptbk.io/xxx"
|
|
66
110
|
* TODO: [✔] Check ModelRequirements in runtime
|
|
67
111
|
* TODO: [🏳] Add options for translation - maybe create `TranslationPrompt`
|
|
68
112
|
*/
|
|
@@ -196,6 +196,17 @@ export type string_script = string;
|
|
|
196
196
|
* For example `console.info("Hello World!")`
|
|
197
197
|
*/
|
|
198
198
|
export type string_javascript = string;
|
|
199
|
+
/**
|
|
200
|
+
* Semantic helper for JSON strings
|
|
201
|
+
*
|
|
202
|
+
* Note: TType is a type of the JSON object inside the string
|
|
203
|
+
*
|
|
204
|
+
* For example `{"foo": "bar"}`
|
|
205
|
+
*/
|
|
206
|
+
export type string_json<TType> = string & {
|
|
207
|
+
_type: 'string_json';
|
|
208
|
+
scheme: TType;
|
|
209
|
+
};
|
|
199
210
|
/**
|
|
200
211
|
* Semantic helper
|
|
201
212
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { really_unknown } from '../organization/really_unknown';
|
|
1
2
|
import type { IKeywords } from './IKeywords';
|
|
2
3
|
/**
|
|
3
4
|
* Parses keywords from any object and recursively walks through
|
|
@@ -7,7 +8,7 @@ import type { IKeywords } from './IKeywords';
|
|
|
7
8
|
* @param input of any kind
|
|
8
9
|
* @returns {Set} of keywords without diacritics in lowercase
|
|
9
10
|
*/
|
|
10
|
-
export declare function parseKeywords(input:
|
|
11
|
+
export declare function parseKeywords(input: really_unknown): IKeywords;
|
|
11
12
|
/**
|
|
12
13
|
* Note: Not using spread in input param because of keeping second parameter for options
|
|
13
14
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_email } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Checks if value is valid email
|
|
4
5
|
*/
|
|
5
|
-
export declare function isValidEmail(email:
|
|
6
|
+
export declare function isValidEmail(email: really_unknown): email is string_email;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { string_file_path } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid URL.
|
|
4
5
|
*
|
|
5
6
|
* Note: This does not check if the file exists only if the path is valid
|
|
6
7
|
*/
|
|
7
|
-
export declare function isValidFilePath(filePath:
|
|
8
|
+
export declare function isValidFilePath(filePath: really_unknown): filePath is string_file_path;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { string_javascript_name } from '../../../types/typeAliases';
|
|
2
|
-
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
|
+
export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_promptbook_version } from '../../../version';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid promptbook version
|
|
4
5
|
* It looks into list of known promptbook versions.
|
|
@@ -9,4 +10,4 @@ import type { string_promptbook_version } from '../../../version';
|
|
|
9
10
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
10
11
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
11
12
|
*/
|
|
12
|
-
export declare function isValidPromptbookVersion(version:
|
|
13
|
+
export declare function isValidPromptbookVersion(version: really_unknown): version is string_promptbook_version;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_semantic_version } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid semantic version
|
|
4
5
|
*
|
|
@@ -6,4 +7,4 @@ import type { string_semantic_version } from '../../../types/typeAliases';
|
|
|
6
7
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
7
8
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
8
9
|
*/
|
|
9
|
-
export declare function isValidSemanticVersion(version:
|
|
10
|
+
export declare function isValidSemanticVersion(version: really_unknown): version is string_semantic_version;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_pipeline_url } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid pipeline URL URL.
|
|
4
5
|
*
|
|
@@ -6,7 +7,7 @@ import type { string_pipeline_url } from '../../../types/typeAliases';
|
|
|
6
7
|
* - `isValidUrl` which tests any URL
|
|
7
8
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
8
9
|
*/
|
|
9
|
-
export declare function isValidPipelineUrl(url:
|
|
10
|
+
export declare function isValidPipelineUrl(url: really_unknown): url is string_pipeline_url;
|
|
10
11
|
/**
|
|
11
12
|
* TODO: [🐠] Maybe more info why the URL is invalid
|
|
12
13
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_url } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid URL.
|
|
4
5
|
*
|
|
@@ -7,4 +8,4 @@ import type { string_url } from '../../../types/typeAliases';
|
|
|
7
8
|
* - `isValidUrl` which tests any URL
|
|
8
9
|
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
9
10
|
*/
|
|
10
|
-
export declare function isValidUrl(url:
|
|
11
|
+
export declare function isValidUrl(url: really_unknown): url is string_url;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_uuid } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Checks if value is valid uuid
|
|
4
5
|
*/
|
|
5
|
-
export declare function isValidUuid(value:
|
|
6
|
+
export declare function isValidUuid(value: really_unknown): value is string_uuid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/types",
|
|
3
|
-
"version": "0.61.0-
|
|
3
|
+
"version": "0.61.0-14",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@promptbook/core": "0.61.0-
|
|
48
|
+
"@promptbook/core": "0.61.0-14"
|
|
49
49
|
},
|
|
50
50
|
"main": "./umd/index.umd.js",
|
|
51
51
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.61.0-13';
|
|
20
20
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
|
|
@@ -5,10 +5,13 @@ import { EmbeddingVector } from '../execution/EmbeddingVector';
|
|
|
5
5
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
6
6
|
import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
7
7
|
import type { PipelineExecutor } from '../execution/PipelineExecutor';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ChatPromptResult, CommonPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../execution/PromptResult';
|
|
9
|
+
import type { PromptResultUsage, PromptResultUsageCounts } from '../execution/PromptResultUsage';
|
|
9
10
|
import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
11
|
+
import type { UncertainNumber } from '../execution/UncertainNumber';
|
|
10
12
|
import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
|
|
11
|
-
import type { ModelRequirements
|
|
13
|
+
import type { ModelRequirements } from '../types/ModelRequirements';
|
|
14
|
+
import type { ModelVariant } from '../types/ModelVariant';
|
|
12
15
|
import type { Parameters } from '../types/Parameters';
|
|
13
16
|
import type { ExpectationAmount, ExpectationUnit, Expectations } from '../types/PipelineJson/Expectations';
|
|
14
17
|
import { EXPECTATION_UNITS } from '../types/PipelineJson/Expectations';
|
|
@@ -34,7 +37,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
|
|
|
34
37
|
import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
|
|
35
38
|
export { PROMPTBOOK_VERSION };
|
|
36
39
|
export { EXPECTATION_UNITS };
|
|
37
|
-
export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, 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_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_version, string_script, string_semantic_version, string_sha256, string_system_message, 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_uuid, };
|
|
40
|
+
export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, 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_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_version, string_script, string_semantic_version, string_sha256, string_system_message, 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_uuid, };
|
|
38
41
|
/**
|
|
39
42
|
* TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
|
|
40
43
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelRequirements } from '../../types/ModelRequirements';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
3
3
|
/**
|
|
4
4
|
* Parsed MODEL command
|
|
5
5
|
*
|
|
@@ -9,5 +9,5 @@ import type { TODO } from '../../utils/organization/TODO';
|
|
|
9
9
|
export type ModelCommand = {
|
|
10
10
|
readonly type: 'MODEL';
|
|
11
11
|
readonly key: keyof ModelRequirements;
|
|
12
|
-
readonly value:
|
|
12
|
+
readonly value: TODO_any;
|
|
13
13
|
};
|
|
@@ -22,3 +22,7 @@ export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
|
|
|
22
22
|
* The names of the parameters that are reserved for special purposes
|
|
23
23
|
*/
|
|
24
24
|
export declare const RESERVED_PARAMETER_NAMES: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Nonce which is used for replacing things in strings
|
|
27
|
+
*/
|
|
28
|
+
export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { string_json } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Stringify the PipelineJson with proper formatting
|
|
4
|
+
*
|
|
5
|
+
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
6
|
+
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
7
|
+
*/
|
|
8
|
+
export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
11
|
+
* TODO: [🔼] Export alongside pipelineStringToJson
|
|
12
|
+
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
|
|
2
2
|
import type { PipelineString } from '../../types/PipelineString';
|
|
3
|
+
import type { string_json } from '../../types/typeAliases';
|
|
3
4
|
/**
|
|
4
|
-
* Import the
|
|
5
|
+
* Import the pipeline.ptbk.md or pipeline.ptbk.json file
|
|
5
6
|
*
|
|
6
7
|
* Note: Using here custom import to work in jest tests
|
|
7
8
|
* Note: Using sync version is 💩 in the production code, but it's ok here in tests
|
|
@@ -11,3 +12,11 @@ import type { PipelineString } from '../../types/PipelineString';
|
|
|
11
12
|
*/
|
|
12
13
|
export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.md`): PipelineString;
|
|
13
14
|
export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.json`): PipelineJson;
|
|
15
|
+
/**
|
|
16
|
+
* Import the pipeline.ptbk.json file as parsed JSON
|
|
17
|
+
*/
|
|
18
|
+
export declare function importPipelineJson(path: `${string}.ptbk.json`): PipelineJson;
|
|
19
|
+
/**
|
|
20
|
+
* Import the pipeline.ptbk.json file as string
|
|
21
|
+
*/
|
|
22
|
+
export declare function importPipelineJsonAsString(path: `${string}.ptbk.json`): string_json<PipelineJson>;
|
|
@@ -23,7 +23,7 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
|
|
|
23
23
|
* > * It checks:
|
|
24
24
|
* > * - it has a valid structure
|
|
25
25
|
* > * - ...
|
|
26
|
-
* > ex port function validatePipeline(promptbook:
|
|
26
|
+
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
27
27
|
*/
|
|
28
28
|
/**
|
|
29
29
|
* TODO: [🧠][🐣] !!!! Validate that all samples match expectations
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { ModelVariant } from '../types/
|
|
2
|
+
import type { ModelVariant } from '../types/ModelVariant';
|
|
3
3
|
import type { Prompt } from '../types/Prompt';
|
|
4
4
|
import type { string_markdown } from '../types/typeAliases';
|
|
5
5
|
import type { string_markdown_text } from '../types/typeAliases';
|
|
6
6
|
import type { string_model_name } from '../types/typeAliases';
|
|
7
7
|
import type { string_title } from '../types/typeAliases';
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
8
|
+
import type { ChatPromptResult } from './PromptResult';
|
|
9
|
+
import type { CompletionPromptResult } from './PromptResult';
|
|
10
|
+
import type { EmbeddingPromptResult } from './PromptResult';
|
|
11
11
|
/**
|
|
12
12
|
* Container for all the tools needed to execute prompts to large language models like GPT-4
|
|
13
13
|
* On its interface it exposes common methods for prompt execution.
|
|
@@ -31,15 +31,15 @@ export type LlmExecutionTools = {
|
|
|
31
31
|
/**
|
|
32
32
|
* Calls a chat model
|
|
33
33
|
*/
|
|
34
|
-
callChatModel?(prompt: Prompt): Promise<
|
|
34
|
+
callChatModel?(prompt: Prompt): Promise<ChatPromptResult>;
|
|
35
35
|
/**
|
|
36
36
|
* Calls a completion model
|
|
37
37
|
*/
|
|
38
|
-
callCompletionModel?(prompt: Prompt): Promise<
|
|
38
|
+
callCompletionModel?(prompt: Prompt): Promise<CompletionPromptResult>;
|
|
39
39
|
/**
|
|
40
40
|
* Calls an embedding model
|
|
41
41
|
*/
|
|
42
|
-
callEmbeddingModel?(prompt: Prompt): Promise<
|
|
42
|
+
callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
|
|
43
43
|
/**
|
|
44
44
|
* List all available models that can be used
|
|
45
45
|
*/
|
|
@@ -3,7 +3,7 @@ import type { TaskProgress } from '../types/TaskProgress';
|
|
|
3
3
|
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
|
|
4
4
|
import type { string_parameter_name } from '../types/typeAliases';
|
|
5
5
|
import type { string_parameter_value } from '../types/typeAliases';
|
|
6
|
-
import type { PromptResultUsage } from './
|
|
6
|
+
import type { PromptResultUsage } from './PromptResultUsage';
|
|
7
7
|
/**
|
|
8
8
|
* Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
|
|
9
9
|
* Executor is made by combining execution tools and pipeline collection.
|