@promptbook/remote-client 0.19.7 → 0.20.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.
Files changed (31) hide show
  1. package/esm/typings/config.d.ts +6 -0
  2. package/esm/typings/conversion/parseCommand.test.d.ts +1 -2
  3. package/esm/typings/conversion/promptTemplatePipelineStringToJson.test.d.ts +3 -0
  4. package/esm/typings/conversion/validatePromptTemplatePipelineJson.test.d.ts +3 -0
  5. package/esm/typings/execution/NaturalExecutionTools.d.ts +1 -0
  6. package/esm/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -0
  7. package/esm/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -0
  8. package/esm/typings/execution/translation/automatic-translate/automatic-translators/IAutomaticTranslator.d.ts +4 -0
  9. package/esm/typings/execution/translation/automatic-translate/automatic-translators/ITranslatorOptions.d.ts +4 -0
  10. package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -0
  11. package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -0
  12. package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -0
  13. package/esm/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -0
  14. package/esm/typings/types/Command.d.ts +4 -4
  15. package/esm/typings/types/ModelRequirements.d.ts +10 -1
  16. package/package.json +2 -2
  17. package/umd/typings/config.d.ts +6 -0
  18. package/umd/typings/conversion/parseCommand.test.d.ts +1 -2
  19. package/umd/typings/conversion/promptTemplatePipelineStringToJson.test.d.ts +3 -0
  20. package/umd/typings/conversion/validatePromptTemplatePipelineJson.test.d.ts +3 -0
  21. package/umd/typings/execution/NaturalExecutionTools.d.ts +1 -0
  22. package/umd/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -0
  23. package/umd/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -0
  24. package/umd/typings/execution/translation/automatic-translate/automatic-translators/IAutomaticTranslator.d.ts +4 -0
  25. package/umd/typings/execution/translation/automatic-translate/automatic-translators/ITranslatorOptions.d.ts +4 -0
  26. package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -0
  27. package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -0
  28. package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -0
  29. package/umd/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -0
  30. package/umd/typings/types/Command.d.ts +4 -4
  31. package/umd/typings/types/ModelRequirements.d.ts +10 -1
@@ -6,5 +6,11 @@ import { string_version } from './types/typeAliases';
6
6
  export declare const PTBK_VERSION: string_version;
7
7
  /**
8
8
  * Default model requirements for the pipeline
9
+ *
10
+ * Note: As default, we use the chat model gpt-3.5-turbo. For most tasks, this is the best model with most intuitive usage.
11
+ * GPT-4 is overkill for most tasks so keeping it as opt-in option.
9
12
  */
10
13
  export declare const DEFAULT_MODEL_REQUIREMENTS: ModelRequirements;
14
+ /**
15
+ * TODO: [🧠] What should be the default model?
16
+ */
@@ -1,7 +1,6 @@
1
1
  export {};
2
2
  /**
3
- * TODO: [🧠] Probbably change syntax USE -> MODEL
4
- * TODO: !!!! Allow to use other models
3
+ * TODO: [🧠] Probbably change syntax MODEL VARIANT -> MODEL
5
4
  * TODO: !!!! Allow to skip segments SKIP IF {foo} NOT DEFINED
6
5
  * TODO: !!! Allow to EXPECT 3 words
7
6
  */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [💥] Some system to automatically generate tests for all the templates in the folder
4
+ */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [💥] Some system to automatically generate tests for all the templates in the folder
4
+ */
@@ -18,5 +18,6 @@ export interface NaturalExecutionTools {
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  }
20
20
  /**
21
+ * TODO: [🏳] gptChat -> chat, gptComplete -> complete, translate
21
22
  * TODO: [🧠] Should or should not there be a word "GPT" in both gptComplete and gptChat
22
23
  */
@@ -0,0 +1,9 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ /**
3
+ * This will wrap an automatic translator and log each translation into the console
4
+ */
5
+ export declare class DebugAutomaticTranslator implements IAutomaticTranslator {
6
+ private readonly automaticTranslator;
7
+ constructor(automaticTranslator: IAutomaticTranslator);
8
+ translate(message: string): Promise<string>;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ export declare class FakeAutomaticTranslator implements IAutomaticTranslator {
3
+ constructor();
4
+ translate(message: string): string;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Promisable } from 'type-fest';
2
+ export interface IAutomaticTranslator {
3
+ translate(message: string): Promisable<string>;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface ITranslatorOptions {
2
+ from: string;
3
+ to: string;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ import { ITranslatorOptions } from './ITranslatorOptions';
3
+ interface ILindatAutomaticTranslatorOptions extends ITranslatorOptions {
4
+ apiUrl: URL;
5
+ }
6
+ export declare class LindatAutomaticTranslator implements IAutomaticTranslator {
7
+ private readonly options;
8
+ constructor(options: ILindatAutomaticTranslatorOptions);
9
+ translate(message: string): Promise<string>;
10
+ }
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare function extractMultiplicatedOccurrence(message: string): string;
@@ -0,0 +1,5 @@
1
+ import { IAutomaticTranslator } from './automatic-translators/IAutomaticTranslator';
2
+ import { ITranslatorOptions } from './automatic-translators/ITranslatorOptions';
3
+ export declare function translateMessages({ automaticTranslator, from, to, }: {
4
+ automaticTranslator: IAutomaticTranslator;
5
+ } & ITranslatorOptions): Promise<void>;
@@ -5,7 +5,7 @@ import { ModelRequirements } from './ModelRequirements';
5
5
  * Command is one piece of the prompt template which adds some logic to the prompt template or the whole pipeline.
6
6
  * It is parsed from the markdown from ul/ol items - one command per one item.
7
7
  */
8
- export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | UseCommand | ParameterCommand | PostprocessCommand;
8
+ export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | ParameterCommand | PostprocessCommand;
9
9
  /**
10
10
  * PtpVersion command tells which version is .ptp file using
11
11
  *
@@ -35,10 +35,10 @@ export interface ExecuteCommand {
35
35
  readonly executionType: ExecutionType;
36
36
  }
37
37
  /**
38
- * Use command tells which model and modelRequirements to use for the prompt template. execution
38
+ * Model command tells which model and modelRequirements to use for the prompt template. execution
39
39
  */
40
- export interface UseCommand {
41
- readonly type: 'USE';
40
+ export interface ModelCommand {
41
+ readonly type: 'MODEL';
42
42
  readonly key: keyof ModelRequirements;
43
43
  readonly value: any;
44
44
  }
@@ -1,3 +1,4 @@
1
+ import { string_model_name } from './typeAliases';
1
2
  export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT"];
2
3
  /**
3
4
  * Model variant describes the very general type of the model
@@ -20,7 +21,15 @@ export interface ModelRequirements {
20
21
  * - **COMPLETION** - model that takes prompt and writes the rest of the text
21
22
  * - **CHAT** - model that takes prompt and previous messages and returns response
22
23
  */
23
- readonly variant: ModelVariant;
24
+ readonly modelVariant: ModelVariant;
25
+ /**
26
+ * The model for text prompt
27
+ *
28
+ * Note: Model must be compatible with the model variant
29
+ *
30
+ * @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
31
+ */
32
+ readonly modelName: string_model_name;
24
33
  /**
25
34
  * Maximum number of tokens that can be generated by the model
26
35
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.19.7",
3
+ "version": "0.20.0",
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.19.7"
40
+ "@promptbook/core": "0.20.0"
41
41
  },
42
42
  "main": "./umd/index.umd.js",
43
43
  "module": "./esm/index.es.js",
@@ -6,5 +6,11 @@ import { string_version } from './types/typeAliases';
6
6
  export declare const PTBK_VERSION: string_version;
7
7
  /**
8
8
  * Default model requirements for the pipeline
9
+ *
10
+ * Note: As default, we use the chat model gpt-3.5-turbo. For most tasks, this is the best model with most intuitive usage.
11
+ * GPT-4 is overkill for most tasks so keeping it as opt-in option.
9
12
  */
10
13
  export declare const DEFAULT_MODEL_REQUIREMENTS: ModelRequirements;
14
+ /**
15
+ * TODO: [🧠] What should be the default model?
16
+ */
@@ -1,7 +1,6 @@
1
1
  export {};
2
2
  /**
3
- * TODO: [🧠] Probbably change syntax USE -> MODEL
4
- * TODO: !!!! Allow to use other models
3
+ * TODO: [🧠] Probbably change syntax MODEL VARIANT -> MODEL
5
4
  * TODO: !!!! Allow to skip segments SKIP IF {foo} NOT DEFINED
6
5
  * TODO: !!! Allow to EXPECT 3 words
7
6
  */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [💥] Some system to automatically generate tests for all the templates in the folder
4
+ */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [💥] Some system to automatically generate tests for all the templates in the folder
4
+ */
@@ -18,5 +18,6 @@ export interface NaturalExecutionTools {
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  }
20
20
  /**
21
+ * TODO: [🏳] gptChat -> chat, gptComplete -> complete, translate
21
22
  * TODO: [🧠] Should or should not there be a word "GPT" in both gptComplete and gptChat
22
23
  */
@@ -0,0 +1,9 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ /**
3
+ * This will wrap an automatic translator and log each translation into the console
4
+ */
5
+ export declare class DebugAutomaticTranslator implements IAutomaticTranslator {
6
+ private readonly automaticTranslator;
7
+ constructor(automaticTranslator: IAutomaticTranslator);
8
+ translate(message: string): Promise<string>;
9
+ }
@@ -0,0 +1,5 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ export declare class FakeAutomaticTranslator implements IAutomaticTranslator {
3
+ constructor();
4
+ translate(message: string): string;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Promisable } from 'type-fest';
2
+ export interface IAutomaticTranslator {
3
+ translate(message: string): Promisable<string>;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface ITranslatorOptions {
2
+ from: string;
3
+ to: string;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { IAutomaticTranslator } from './IAutomaticTranslator';
2
+ import { ITranslatorOptions } from './ITranslatorOptions';
3
+ interface ILindatAutomaticTranslatorOptions extends ITranslatorOptions {
4
+ apiUrl: URL;
5
+ }
6
+ export declare class LindatAutomaticTranslator implements IAutomaticTranslator {
7
+ private readonly options;
8
+ constructor(options: ILindatAutomaticTranslatorOptions);
9
+ translate(message: string): Promise<string>;
10
+ }
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare function extractMultiplicatedOccurrence(message: string): string;
@@ -0,0 +1,5 @@
1
+ import { IAutomaticTranslator } from './automatic-translators/IAutomaticTranslator';
2
+ import { ITranslatorOptions } from './automatic-translators/ITranslatorOptions';
3
+ export declare function translateMessages({ automaticTranslator, from, to, }: {
4
+ automaticTranslator: IAutomaticTranslator;
5
+ } & ITranslatorOptions): Promise<void>;
@@ -5,7 +5,7 @@ import { ModelRequirements } from './ModelRequirements';
5
5
  * Command is one piece of the prompt template which adds some logic to the prompt template or the whole pipeline.
6
6
  * It is parsed from the markdown from ul/ol items - one command per one item.
7
7
  */
8
- export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | UseCommand | ParameterCommand | PostprocessCommand;
8
+ export type Command = PtbkUrlCommand | PtbkVersionCommand | ExecuteCommand | ModelCommand | ParameterCommand | PostprocessCommand;
9
9
  /**
10
10
  * PtpVersion command tells which version is .ptp file using
11
11
  *
@@ -35,10 +35,10 @@ export interface ExecuteCommand {
35
35
  readonly executionType: ExecutionType;
36
36
  }
37
37
  /**
38
- * Use command tells which model and modelRequirements to use for the prompt template. execution
38
+ * Model command tells which model and modelRequirements to use for the prompt template. execution
39
39
  */
40
- export interface UseCommand {
41
- readonly type: 'USE';
40
+ export interface ModelCommand {
41
+ readonly type: 'MODEL';
42
42
  readonly key: keyof ModelRequirements;
43
43
  readonly value: any;
44
44
  }
@@ -1,3 +1,4 @@
1
+ import { string_model_name } from './typeAliases';
1
2
  export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT"];
2
3
  /**
3
4
  * Model variant describes the very general type of the model
@@ -20,7 +21,15 @@ export interface ModelRequirements {
20
21
  * - **COMPLETION** - model that takes prompt and writes the rest of the text
21
22
  * - **CHAT** - model that takes prompt and previous messages and returns response
22
23
  */
23
- readonly variant: ModelVariant;
24
+ readonly modelVariant: ModelVariant;
25
+ /**
26
+ * The model for text prompt
27
+ *
28
+ * Note: Model must be compatible with the model variant
29
+ *
30
+ * @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
31
+ */
32
+ readonly modelName: string_model_name;
24
33
  /**
25
34
  * Maximum number of tokens that can be generated by the model
26
35
  */