@promptbook/components 0.103.0-67 → 0.103.0-68
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 +248 -33
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +10 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +4 -0
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +5 -1
- package/esm/typings/src/execution/PromptResult.d.ts +7 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +13 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -1
- package/esm/typings/src/types/ModelVariant.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +248 -32
- package/umd/index.umd.js.map +1 -1
|
@@ -45,6 +45,7 @@ import type { MessageButton } from '../book-components/Chat/utils/parseMessageBu
|
|
|
45
45
|
import { parseMessageButtons } from '../book-components/Chat/utils/parseMessageButtons';
|
|
46
46
|
import { ArrowIcon } from '../book-components/icons/ArrowIcon';
|
|
47
47
|
import { AttachmentIcon } from '../book-components/icons/AttachmentIcon';
|
|
48
|
+
import { CameraIcon } from '../book-components/icons/CameraIcon';
|
|
48
49
|
import { MicIcon } from '../book-components/icons/MicIcon';
|
|
49
50
|
import { PauseIcon } from '../book-components/icons/PauseIcon';
|
|
50
51
|
import { PlayIcon } from '../book-components/icons/PlayIcon';
|
|
@@ -105,6 +106,7 @@ export type { MessageButton };
|
|
|
105
106
|
export { parseMessageButtons };
|
|
106
107
|
export { ArrowIcon };
|
|
107
108
|
export { AttachmentIcon };
|
|
109
|
+
export { CameraIcon };
|
|
108
110
|
export { MicIcon };
|
|
109
111
|
export { PauseIcon };
|
|
110
112
|
export { PlayIcon };
|
|
@@ -88,6 +88,7 @@ import type { PromptbookFetch } from '../execution/PromptbookFetch';
|
|
|
88
88
|
import type { PromptResult } from '../execution/PromptResult';
|
|
89
89
|
import type { CompletionPromptResult } from '../execution/PromptResult';
|
|
90
90
|
import type { ChatPromptResult } from '../execution/PromptResult';
|
|
91
|
+
import type { ImagePromptResult } from '../execution/PromptResult';
|
|
91
92
|
import type { EmbeddingPromptResult } from '../execution/PromptResult';
|
|
92
93
|
import type { ScriptExecutionTools } from '../execution/ScriptExecutionTools';
|
|
93
94
|
import type { ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
|
|
@@ -187,6 +188,7 @@ import type { LlmCall } from '../types/LlmCall';
|
|
|
187
188
|
import type { ModelRequirements } from '../types/ModelRequirements';
|
|
188
189
|
import type { CompletionModelRequirements } from '../types/ModelRequirements';
|
|
189
190
|
import type { ChatModelRequirements } from '../types/ModelRequirements';
|
|
191
|
+
import type { ImageGenerationModelRequirements } from '../types/ModelRequirements';
|
|
190
192
|
import type { EmbeddingModelRequirements } from '../types/ModelRequirements';
|
|
191
193
|
import type { ModelVariant } from '../types/ModelVariant';
|
|
192
194
|
import type { NonEmptyArray } from '../types/NonEmptyArray';
|
|
@@ -194,6 +196,7 @@ import type { NonEmptyReadonlyArray } from '../types/NonEmptyArray';
|
|
|
194
196
|
import type { Prompt } from '../types/Prompt';
|
|
195
197
|
import type { CompletionPrompt } from '../types/Prompt';
|
|
196
198
|
import type { ChatPrompt } from '../types/Prompt';
|
|
199
|
+
import type { ImagePrompt } from '../types/Prompt';
|
|
197
200
|
import type { EmbeddingPrompt } from '../types/Prompt';
|
|
198
201
|
import type { ScriptLanguage } from '../types/ScriptLanguage';
|
|
199
202
|
import type { SectionType } from '../types/SectionType';
|
|
@@ -449,6 +452,7 @@ export type { PromptbookFetch };
|
|
|
449
452
|
export type { PromptResult };
|
|
450
453
|
export type { CompletionPromptResult };
|
|
451
454
|
export type { ChatPromptResult };
|
|
455
|
+
export type { ImagePromptResult };
|
|
452
456
|
export type { EmbeddingPromptResult };
|
|
453
457
|
export type { ScriptExecutionTools };
|
|
454
458
|
export type { ScriptExecutionToolsExecuteOptions };
|
|
@@ -548,6 +552,7 @@ export type { LlmCall };
|
|
|
548
552
|
export type { ModelRequirements };
|
|
549
553
|
export type { CompletionModelRequirements };
|
|
550
554
|
export type { ChatModelRequirements };
|
|
555
|
+
export type { ImageGenerationModelRequirements };
|
|
551
556
|
export type { EmbeddingModelRequirements };
|
|
552
557
|
export type { ModelVariant };
|
|
553
558
|
export type { NonEmptyArray };
|
|
@@ -555,6 +560,7 @@ export type { NonEmptyReadonlyArray };
|
|
|
555
560
|
export type { Prompt };
|
|
556
561
|
export type { CompletionPrompt };
|
|
557
562
|
export type { ChatPrompt };
|
|
563
|
+
export type { ImagePrompt };
|
|
558
564
|
export type { EmbeddingPrompt };
|
|
559
565
|
export type { ScriptLanguage };
|
|
560
566
|
export type { SectionType };
|
|
@@ -81,6 +81,16 @@ export type BookEditorProps = {
|
|
|
81
81
|
*/
|
|
82
82
|
readonly readonlyMessage?: string;
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* If true, shows the upload button in the action bar.
|
|
86
|
+
* By default, the upload button is shown.
|
|
87
|
+
*/
|
|
88
|
+
readonly isUploadButtonShown?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* If true, shows the camera button in the action bar.
|
|
91
|
+
* By default, the camera button is shown on mobile devices.
|
|
92
|
+
*/
|
|
93
|
+
readonly isCameraButtonShown?: boolean;
|
|
84
94
|
/**
|
|
85
95
|
* If true, shows the download button in the action bar.
|
|
86
96
|
* By default, the download button is shown.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
type BookEditorActionbarProps = {
|
|
2
2
|
value: string | undefined;
|
|
3
3
|
isDownloadButtonShown?: boolean;
|
|
4
|
+
isUploadButtonShown?: boolean;
|
|
5
|
+
isCameraButtonShown?: boolean;
|
|
4
6
|
isAboutButtonShown?: boolean;
|
|
5
7
|
isFullscreenButtonShown?: boolean;
|
|
6
8
|
onFullscreenClick?: () => void;
|
|
9
|
+
onUploadDocument?: () => void;
|
|
10
|
+
onTakePhoto?: () => void;
|
|
7
11
|
isFullscreen?: boolean;
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type CameraIconProps = {
|
|
2
|
+
size?: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @@@
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/components`
|
|
9
|
+
*/
|
|
10
|
+
export declare function CameraIcon({ size, color }: CameraIconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { ChatParticipant } from '../book-components/Chat/types/ChatParticip
|
|
|
3
3
|
import type { Prompt } from '../types/Prompt';
|
|
4
4
|
import type { string_markdown, string_markdown_text, string_title } from '../types/typeAliases';
|
|
5
5
|
import type { AvailableModel } from './AvailableModel';
|
|
6
|
-
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult } from './PromptResult';
|
|
6
|
+
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, ImagePromptResult } from './PromptResult';
|
|
7
7
|
/**
|
|
8
8
|
* Container for all the tools needed to execute prompts to large language models like GPT-4
|
|
9
9
|
* On its interface it exposes common methods for prompt execution.
|
|
@@ -70,6 +70,10 @@ export type LlmExecutionTools = {
|
|
|
70
70
|
* Calls a completion model
|
|
71
71
|
*/
|
|
72
72
|
callCompletionModel?(prompt: Prompt): Promise<CompletionPromptResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Calls a image generation model
|
|
75
|
+
*/
|
|
76
|
+
callImageGenerationModel?(prompt: Prompt): Promise<ImagePromptResult>;
|
|
73
77
|
/**
|
|
74
78
|
* Calls an embedding model
|
|
75
79
|
*/
|
|
@@ -8,7 +8,7 @@ import type { Usage } from './Usage';
|
|
|
8
8
|
*
|
|
9
9
|
* @see https://github.com/webgptorg/promptbook#prompt-result
|
|
10
10
|
*/
|
|
11
|
-
export type PromptResult = CompletionPromptResult | ChatPromptResult | EmbeddingPromptResult;
|
|
11
|
+
export type PromptResult = CompletionPromptResult | ChatPromptResult | ImagePromptResult | EmbeddingPromptResult;
|
|
12
12
|
/**
|
|
13
13
|
* Completion prompt result
|
|
14
14
|
*
|
|
@@ -22,6 +22,12 @@ export type CompletionPromptResult = CommonPromptResult;
|
|
|
22
22
|
* Note: [🚉] This is fully serializable as JSON
|
|
23
23
|
*/
|
|
24
24
|
export type ChatPromptResult = CommonPromptResult & {};
|
|
25
|
+
/**
|
|
26
|
+
* Image prompt result
|
|
27
|
+
*
|
|
28
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
29
|
+
*/
|
|
30
|
+
export type ImagePromptResult = CommonPromptResult;
|
|
25
31
|
/**
|
|
26
32
|
* Embedding prompt result
|
|
27
33
|
*
|
|
@@ -38,6 +38,10 @@ export declare class OllamaExecutionTools extends OpenAiCompatibleExecutionTools
|
|
|
38
38
|
* Default model for completion variant.
|
|
39
39
|
*/
|
|
40
40
|
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
41
|
+
/**
|
|
42
|
+
* Default model for image generation variant.
|
|
43
|
+
*/
|
|
44
|
+
protected getDefaultImageGenerationModel(): AvailableModel;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
3
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
|
-
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult } from '../../execution/PromptResult';
|
|
4
|
+
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, ImagePromptResult } from '../../execution/PromptResult';
|
|
5
5
|
import type { Usage } from '../../execution/Usage';
|
|
6
6
|
import type { Prompt } from '../../types/Prompt';
|
|
7
7
|
import type { string_markdown, string_markdown_text, string_model_name, string_title } from '../../types/typeAliases';
|
|
@@ -63,6 +63,14 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
63
63
|
* Internal method that handles parameter retry for embedding model calls
|
|
64
64
|
*/
|
|
65
65
|
private callEmbeddingModelWithRetry;
|
|
66
|
+
/**
|
|
67
|
+
* Calls OpenAI compatible API to use a image generation model
|
|
68
|
+
*/
|
|
69
|
+
callImageGenerationModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ImagePromptResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Internal method that handles parameter retry for image generation model calls
|
|
72
|
+
*/
|
|
73
|
+
private callImageGenerationModelWithRetry;
|
|
66
74
|
/**
|
|
67
75
|
* Get the model that should be used as default
|
|
68
76
|
*/
|
|
@@ -89,6 +97,10 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
89
97
|
* Default model for completion variant.
|
|
90
98
|
*/
|
|
91
99
|
protected abstract getDefaultEmbeddingModel(): AvailableModel;
|
|
100
|
+
/**
|
|
101
|
+
* Default model for image generation variant.
|
|
102
|
+
*/
|
|
103
|
+
protected abstract getDefaultImageGenerationModel(): AvailableModel;
|
|
92
104
|
/**
|
|
93
105
|
* Makes a request with retry logic for network errors like ECONNRESET
|
|
94
106
|
*/
|
|
@@ -35,4 +35,8 @@ export declare class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools
|
|
|
35
35
|
* Default model for completion variant.
|
|
36
36
|
*/
|
|
37
37
|
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
38
|
+
/**
|
|
39
|
+
* Default model for image generation variant.
|
|
40
|
+
*/
|
|
41
|
+
protected getDefaultImageGenerationModel(): AvailableModel;
|
|
38
42
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { Usage } from '../../execution/Usage';
|
|
4
|
-
import type { string_markdown } from '../../types/typeAliases';
|
|
5
|
-
import type { string_markdown_text } from '../../types/typeAliases';
|
|
6
|
-
import type { string_model_name } from '../../types/typeAliases';
|
|
7
|
-
import type { string_title } from '../../types/typeAliases';
|
|
4
|
+
import type { string_markdown, string_markdown_text, string_model_name, string_title } from '../../types/typeAliases';
|
|
8
5
|
import { RemoteLlmExecutionTools } from '../remote/RemoteLlmExecutionTools';
|
|
9
6
|
import { computeOpenAiUsage } from './computeOpenAiUsage';
|
|
10
7
|
import { OpenAiCompatibleExecutionTools } from './OpenAiCompatibleExecutionTools';
|
|
11
|
-
import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
12
|
-
import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
8
|
+
import type { OpenAiCompatibleExecutionToolsNonProxiedOptions, OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
13
9
|
/**
|
|
14
10
|
* Execution Tools for calling OpenAI compatible API
|
|
15
11
|
*
|
|
@@ -67,6 +63,10 @@ export declare class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompa
|
|
|
67
63
|
* Default model for completion variant.
|
|
68
64
|
*/
|
|
69
65
|
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
66
|
+
/**
|
|
67
|
+
* Default model for image generation variant.
|
|
68
|
+
*/
|
|
69
|
+
protected getDefaultImageGenerationModel(): AvailableModel;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
@@ -7,7 +7,7 @@ import type { number_model_temperature, number_seed, string_model_name, string_s
|
|
|
7
7
|
* Note: [🚉] This is fully serializable as JSON
|
|
8
8
|
* @see https://github.com/webgptorg/promptbook#model-requirements
|
|
9
9
|
*/
|
|
10
|
-
export type ModelRequirements = CompletionModelRequirements | ChatModelRequirements | EmbeddingModelRequirements;
|
|
10
|
+
export type ModelRequirements = CompletionModelRequirements | ChatModelRequirements | ImageGenerationModelRequirements | EmbeddingModelRequirements;
|
|
11
11
|
/**
|
|
12
12
|
* Model requirements for the completion variant
|
|
13
13
|
*
|
|
@@ -34,6 +34,17 @@ export type ChatModelRequirements = CommonModelRequirements & {
|
|
|
34
34
|
*/
|
|
35
35
|
readonly systemMessage?: string_system_message;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Model requirements for the image generation variant
|
|
39
|
+
*
|
|
40
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
41
|
+
*/
|
|
42
|
+
export type ImageGenerationModelRequirements = CommonModelRequirements & {
|
|
43
|
+
/**
|
|
44
|
+
* Image generation model variant
|
|
45
|
+
*/
|
|
46
|
+
modelVariant: 'IMAGE_GENERATION';
|
|
47
|
+
};
|
|
37
48
|
/**
|
|
38
49
|
* Model requirements for the embedding variant
|
|
39
50
|
*
|
|
@@ -59,6 +70,7 @@ export type CommonModelRequirements = {
|
|
|
59
70
|
* There are 3 variants:
|
|
60
71
|
* - **COMPLETION** - model that takes prompt and writes the rest of the text
|
|
61
72
|
* - **CHAT** - model that takes prompt and previous messages and returns response
|
|
73
|
+
* - **IMAGE_GENERATION** - model that takes prompt and returns image
|
|
62
74
|
* - **EMBEDDING** - model that takes prompt and returns embedding
|
|
63
75
|
* <- [🤖]
|
|
64
76
|
*/
|
|
@@ -12,4 +12,4 @@ export type ModelVariant = TupleToUnion<typeof MODEL_VARIANTS>;
|
|
|
12
12
|
* @see {@link ModelVariant}
|
|
13
13
|
* @public exported from `@promptbook/core`
|
|
14
14
|
*/
|
|
15
|
-
export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT", "EMBEDDING"];
|
|
15
|
+
export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT", "IMAGE_GENERATION", "EMBEDDING"];
|
|
@@ -4,6 +4,7 @@ import type { Expectations } from '../pipeline/PipelineJson/Expectations';
|
|
|
4
4
|
import type { ChatModelRequirements } from './ModelRequirements';
|
|
5
5
|
import type { CompletionModelRequirements } from './ModelRequirements';
|
|
6
6
|
import type { EmbeddingModelRequirements } from './ModelRequirements';
|
|
7
|
+
import type { ImageGenerationModelRequirements } from './ModelRequirements';
|
|
7
8
|
import type { ModelRequirements } from './ModelRequirements';
|
|
8
9
|
import type { Parameters } from './typeAliases';
|
|
9
10
|
import type { string_pipeline_url_with_task_hash } from './typeAliases';
|
|
@@ -17,7 +18,7 @@ import type { string_title } from './typeAliases';
|
|
|
17
18
|
* Note: [🚉] This is fully serializable as JSON
|
|
18
19
|
* @see https://github.com/webgptorg/promptbook#prompt
|
|
19
20
|
*/
|
|
20
|
-
export type Prompt = CompletionPrompt | ChatPrompt | EmbeddingPrompt;
|
|
21
|
+
export type Prompt = CompletionPrompt | ChatPrompt | ImagePrompt | EmbeddingPrompt;
|
|
21
22
|
/**
|
|
22
23
|
* Completion prompt
|
|
23
24
|
*
|
|
@@ -44,6 +45,17 @@ export type ChatPrompt = CommonPrompt & {
|
|
|
44
45
|
*/
|
|
45
46
|
thread?: ChatMessage[];
|
|
46
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Image prompt
|
|
50
|
+
*
|
|
51
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
52
|
+
*/
|
|
53
|
+
export type ImagePrompt = CommonPrompt & {
|
|
54
|
+
/**
|
|
55
|
+
* Requirements for image generation model
|
|
56
|
+
*/
|
|
57
|
+
modelRequirements: ImageGenerationModelRequirements;
|
|
58
|
+
};
|
|
47
59
|
/**
|
|
48
60
|
* Embedding prompt
|
|
49
61
|
*
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.103.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.103.0-67`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|