@promptbook/editable 0.94.0-3 → 0.94.0-5

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 CHANGED
@@ -17,7 +17,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
17
17
  * @generated
18
18
  * @see https://github.com/webgptorg/promptbook
19
19
  */
20
- const PROMPTBOOK_ENGINE_VERSION = '0.94.0-3';
20
+ const PROMPTBOOK_ENGINE_VERSION = '0.94.0-5';
21
21
  /**
22
22
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
23
23
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1,10 +1,14 @@
1
1
  import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { createOllamaExecutionTools } from '../llm-providers/ollama/createOllamaExecutionTools';
3
+ import { OLLAMA_MODELS } from '../llm-providers/ollama/ollama-models';
4
+ import { OllamaExecutionTools } from '../llm-providers/ollama/OllamaExecutionTools';
3
5
  import { DEFAULT_OLLAMA_BASE_URL } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
4
6
  import type { OllamaExecutionToolsOptions } from '../llm-providers/ollama/OllamaExecutionToolsOptions';
5
7
  import { _OllamaRegistration } from '../llm-providers/ollama/register-constructor';
6
8
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
7
9
  export { createOllamaExecutionTools };
10
+ export { OLLAMA_MODELS };
11
+ export { OllamaExecutionTools };
8
12
  export { DEFAULT_OLLAMA_BASE_URL };
9
13
  export type { OllamaExecutionToolsOptions };
10
14
  export { _OllamaRegistration };
@@ -4,6 +4,7 @@ import { createOpenAiExecutionTools } from '../llm-providers/openai/createOpenAi
4
4
  import { OPENAI_MODELS } from '../llm-providers/openai/openai-models';
5
5
  import { OpenAiAssistantExecutionTools } from '../llm-providers/openai/OpenAiAssistantExecutionTools';
6
6
  import type { OpenAiAssistantExecutionToolsOptions } from '../llm-providers/openai/OpenAiAssistantExecutionToolsOptions';
7
+ import { OpenAiCompatibleExecutionTools } from '../llm-providers/openai/OpenAiCompatibleExecutionTools';
7
8
  import { OpenAiExecutionTools } from '../llm-providers/openai/OpenAiExecutionTools';
8
9
  import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
9
10
  import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
@@ -14,6 +15,7 @@ export { createOpenAiExecutionTools };
14
15
  export { OPENAI_MODELS };
15
16
  export { OpenAiAssistantExecutionTools };
16
17
  export type { OpenAiAssistantExecutionToolsOptions };
18
+ export { OpenAiCompatibleExecutionTools };
17
19
  export { OpenAiExecutionTools };
18
20
  export type { OpenAiExecutionToolsOptions };
19
21
  export { _OpenAiRegistration };
@@ -8,9 +8,9 @@
8
8
  */
9
9
  type string_model_price = `$${number}.${number} / ${number}M tokens`;
10
10
  /**
11
- * Function computeUsage will create price per one token based on the string value found on openai page
11
+ * Create price per one token based on the string value found on openai page
12
12
  *
13
13
  * @private within the repository, used only as internal helper for `OPENAI_MODELS`
14
14
  */
15
- export declare function computeUsage(value: string_model_price): number;
15
+ export declare function pricing(value: string_model_price): number;
16
16
  export {};
@@ -0,0 +1,44 @@
1
+ import type { AvailableModel } from '../../execution/AvailableModel';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
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_title } from '../../types/typeAliases';
7
+ import { computeOpenAiUsage } from '../openai/computeOpenAiUsage';
8
+ import { OpenAiCompatibleExecutionTools } from '../openai/OpenAiCompatibleExecutionTools';
9
+ import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions';
10
+ /**
11
+ * Execution Tools for calling Ollama API
12
+ *
13
+ * @public exported from `@promptbook/ollama`
14
+ */
15
+ export declare class OllamaExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
16
+ constructor(ollamaOptions: OllamaExecutionToolsOptions);
17
+ get title(): string_title & string_markdown_text;
18
+ get description(): string_markdown;
19
+ /**
20
+ * List all available models (non dynamically)
21
+ *
22
+ * Note: Purpose of this is to provide more information about models than standard listing from API
23
+ */
24
+ protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
25
+ /**
26
+ * Computes the usage of the Ollama API based on the response from Ollama
27
+ */
28
+ protected computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
29
+ /**
30
+ * Default model for chat variant.
31
+ */
32
+ protected getDefaultChatModel(): AvailableModel;
33
+ /**
34
+ * Default model for completion variant.
35
+ */
36
+ protected getDefaultCompletionModel(): AvailableModel;
37
+ /**
38
+ * Default model for completion variant.
39
+ */
40
+ protected getDefaultEmbeddingModel(): AvailableModel;
41
+ }
42
+ /**
43
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
44
+ */
@@ -4,7 +4,7 @@ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionTools
4
4
  *
5
5
  * @public exported from `@promptbook/ollama`
6
6
  */
7
- export declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434";
7
+ export declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434/v1";
8
8
  /**
9
9
  * Options for `createOllamaExecutionTools`
10
10
  *
@@ -5,7 +5,7 @@ import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions'
5
5
  *
6
6
  * @public exported from `@promptbook/ollama`
7
7
  */
8
- export declare const createOllamaExecutionTools: ((ollamaOptions: OllamaExecutionToolsOptions) => LlmExecutionTools) & {
8
+ export declare const createOllamaExecutionTools: ((options: OllamaExecutionToolsOptions) => LlmExecutionTools) & {
9
9
  packageName: string;
10
10
  className: string;
11
11
  };
@@ -0,0 +1,14 @@
1
+ import type { AvailableModel } from '../../execution/AvailableModel';
2
+ /**
3
+ * List of available models in Ollama library
4
+ *
5
+ * Note: Done at 2025-05-19
6
+ *
7
+ * @see https://ollama.com/library
8
+ * @public exported from `@promptbook/ollama`
9
+ */
10
+ export declare const OLLAMA_MODELS: ReadonlyArray<AvailableModel>;
11
+ /**
12
+ * TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
13
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14
+ */
@@ -0,0 +1,91 @@
1
+ import OpenAI from 'openai';
2
+ import type { AvailableModel } from '../../execution/AvailableModel';
3
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
+ import type { ChatPromptResult } from '../../execution/PromptResult';
5
+ import type { CompletionPromptResult } from '../../execution/PromptResult';
6
+ import type { EmbeddingPromptResult } from '../../execution/PromptResult';
7
+ import type { Usage } from '../../execution/Usage';
8
+ import type { Prompt } from '../../types/Prompt';
9
+ import type { string_markdown } from '../../types/typeAliases';
10
+ import type { string_markdown_text } from '../../types/typeAliases';
11
+ import type { string_model_name } from '../../types/typeAliases';
12
+ import type { string_title } from '../../types/typeAliases';
13
+ import { computeOpenAiUsage } from './computeOpenAiUsage';
14
+ import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
15
+ /**
16
+ * Execution Tools for calling OpenAI API or other OpeenAI compatible provider
17
+ *
18
+ * @public exported from `@promptbook/openai`
19
+ */
20
+ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecutionTools {
21
+ protected readonly options: OpenAiExecutionToolsOptions;
22
+ /**
23
+ * OpenAI API client.
24
+ */
25
+ private client;
26
+ /**
27
+ * Rate limiter instance
28
+ */
29
+ private limiter;
30
+ /**
31
+ * Creates OpenAI compatible Execution Tools.
32
+ *
33
+ * @param options which are relevant are directly passed to the OpenAI compatible client
34
+ */
35
+ constructor(options: OpenAiExecutionToolsOptions);
36
+ abstract get title(): string_title & string_markdown_text;
37
+ abstract get description(): string_markdown;
38
+ getClient(): Promise<OpenAI>;
39
+ /**
40
+ * Check the `options` passed to `constructor`
41
+ */
42
+ checkConfiguration(): Promise<void>;
43
+ /**
44
+ * List all available OpenAI compatible models that can be used
45
+ */
46
+ listModels(): Promise<ReadonlyArray<AvailableModel>>;
47
+ /**
48
+ * Calls OpenAI compatible API to use a chat model.
49
+ */
50
+ callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
51
+ /**
52
+ * Calls OpenAI API to use a complete model.
53
+ */
54
+ callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
55
+ /**
56
+ * Calls OpenAI compatible API to use a embedding model
57
+ */
58
+ callEmbeddingModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<EmbeddingPromptResult>;
59
+ /**
60
+ * Get the model that should be used as default
61
+ */
62
+ protected getDefaultModel(defaultModelName: string_model_name): AvailableModel;
63
+ /**
64
+ * List all available models (non dynamically)
65
+ *
66
+ * Note: Purpose of this is to provide more information about models than standard listing from API
67
+ */
68
+ protected abstract get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
69
+ /**
70
+ * Computes the usage of the OpenAI API based on the response from OpenAI Compatible API
71
+ */
72
+ protected abstract computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
73
+ /**
74
+ * Default model for chat variant.
75
+ */
76
+ protected abstract getDefaultChatModel(): AvailableModel;
77
+ /**
78
+ * Default model for completion variant.
79
+ */
80
+ protected abstract getDefaultCompletionModel(): AvailableModel;
81
+ /**
82
+ * Default model for completion variant.
83
+ */
84
+ protected abstract getDefaultEmbeddingModel(): AvailableModel;
85
+ }
86
+ /**
87
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
88
+ * TODO: [🛄] Maybe make custom `OpenAiCompatibleError`
89
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
90
+ * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
91
+ */
@@ -1,79 +1,38 @@
1
- import OpenAI from 'openai';
2
1
  import type { AvailableModel } from '../../execution/AvailableModel';
3
2
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import type { ChatPromptResult } from '../../execution/PromptResult';
5
- import type { CompletionPromptResult } from '../../execution/PromptResult';
6
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
7
- import type { Prompt } from '../../types/Prompt';
8
3
  import type { string_markdown } from '../../types/typeAliases';
9
4
  import type { string_markdown_text } from '../../types/typeAliases';
10
5
  import type { string_title } from '../../types/typeAliases';
11
- import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
6
+ import { computeOpenAiUsage } from './computeOpenAiUsage';
7
+ import { OpenAiCompatibleExecutionTools } from './OpenAiCompatibleExecutionTools';
12
8
  /**
13
9
  * Execution Tools for calling OpenAI API
14
10
  *
15
11
  * @public exported from `@promptbook/openai`
16
12
  */
17
- export declare class OpenAiExecutionTools implements LlmExecutionTools {
18
- protected readonly options: OpenAiExecutionToolsOptions;
19
- /**
20
- * OpenAI API client.
21
- */
22
- private client;
23
- /**
24
- * Rate limiter instance
25
- */
26
- private limiter;
27
- /**
28
- * Creates OpenAI Execution Tools.
29
- *
30
- * @param options which are relevant are directly passed to the OpenAI client
31
- */
32
- constructor(options: OpenAiExecutionToolsOptions);
13
+ export declare class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
33
14
  get title(): string_title & string_markdown_text;
34
15
  get description(): string_markdown;
35
- getClient(): Promise<OpenAI>;
36
- /**
37
- * Check the `options` passed to `constructor`
38
- */
39
- checkConfiguration(): Promise<void>;
40
16
  /**
41
- * List all available OpenAI models that can be used
42
- */
43
- listModels(): Promise<ReadonlyArray<AvailableModel>>;
44
- /**
45
- * Calls OpenAI API to use a chat model.
46
- */
47
- callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
48
- /**
49
- * Calls OpenAI API to use a complete model.
50
- */
51
- callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
52
- /**
53
- * Calls OpenAI API to use a embedding model
17
+ * List all available models (non dynamically)
18
+ *
19
+ * Note: Purpose of this is to provide more information about models than standard listing from API
54
20
  */
55
- callEmbeddingModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<EmbeddingPromptResult>;
21
+ protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
56
22
  /**
57
- * Get the model that should be used as default
23
+ * Computes the usage of the OpenAI API based on the response from OpenAI
58
24
  */
59
- private getDefaultModel;
25
+ protected computeUsage: typeof computeOpenAiUsage;
60
26
  /**
61
27
  * Default model for chat variant.
62
28
  */
63
- private getDefaultChatModel;
29
+ protected getDefaultChatModel(): AvailableModel;
64
30
  /**
65
31
  * Default model for completion variant.
66
32
  */
67
- private getDefaultCompletionModel;
33
+ protected getDefaultCompletionModel(): AvailableModel;
68
34
  /**
69
35
  * Default model for completion variant.
70
36
  */
71
- private getDefaultEmbeddingModel;
37
+ protected getDefaultEmbeddingModel(): AvailableModel;
72
38
  }
73
- /**
74
- * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
75
- * TODO: Maybe Create some common util for callChatModel and callCompletionModel
76
- * TODO: Maybe make custom OpenAiError
77
- * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
78
- * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
79
- */
@@ -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.94.0-2`).
18
+ * It follows semantic versioning (e.g., `0.94.0-4`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/editable",
3
- "version": "0.94.0-3",
3
+ "version": "0.94.0-5",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -63,7 +63,7 @@
63
63
  "module": "./esm/index.es.js",
64
64
  "typings": "./esm/typings/src/_packages/editable.index.d.ts",
65
65
  "peerDependencies": {
66
- "@promptbook/core": "0.94.0-3"
66
+ "@promptbook/core": "0.94.0-5"
67
67
  },
68
68
  "dependencies": {
69
69
  "crypto-js": "4.2.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.94.0-3';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.94.0-5';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name