@promptbook/openai 0.95.0 → 0.98.0-10
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 +63 -2
- package/esm/index.es.js +602 -4
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/openai.index.d.ts +10 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -2
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +8 -0
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +53 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +4 -4
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +52 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +3 -5
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +74 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +11 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +14 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +3 -2
- package/umd/index.umd.js +606 -7
- package/umd/index.umd.js.map +1 -1
|
@@ -11,14 +11,14 @@ import type { string_markdown_text } from '../../types/typeAliases';
|
|
|
11
11
|
import type { string_model_name } from '../../types/typeAliases';
|
|
12
12
|
import type { string_title } from '../../types/typeAliases';
|
|
13
13
|
import { computeOpenAiUsage } from './computeOpenAiUsage';
|
|
14
|
-
import type {
|
|
14
|
+
import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
15
15
|
/**
|
|
16
|
-
* Execution Tools for calling OpenAI API or other
|
|
16
|
+
* Execution Tools for calling OpenAI API or other OpenAI compatible provider
|
|
17
17
|
*
|
|
18
18
|
* @public exported from `@promptbook/openai`
|
|
19
19
|
*/
|
|
20
20
|
export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecutionTools {
|
|
21
|
-
protected readonly options:
|
|
21
|
+
protected readonly options: OpenAiCompatibleExecutionToolsNonProxiedOptions;
|
|
22
22
|
/**
|
|
23
23
|
* OpenAI API client.
|
|
24
24
|
*/
|
|
@@ -32,7 +32,7 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
32
32
|
*
|
|
33
33
|
* @param options which are relevant are directly passed to the OpenAI compatible client
|
|
34
34
|
*/
|
|
35
|
-
constructor(options:
|
|
35
|
+
constructor(options: OpenAiCompatibleExecutionToolsNonProxiedOptions);
|
|
36
36
|
abstract get title(): string_title & string_markdown_text;
|
|
37
37
|
abstract get description(): string_markdown;
|
|
38
38
|
getClient(): Promise<OpenAI>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ClientOptions } from 'openai';
|
|
2
|
+
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
|
+
import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Options for `createOpenAiCompatibleExecutionTools` and `OpenAiCompatibleExecutionTools`
|
|
6
|
+
*
|
|
7
|
+
* This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
|
|
8
|
+
* Rest is used by the `OpenAiCompatibleExecutionTools`.
|
|
9
|
+
*
|
|
10
|
+
* @public exported from `@promptbook/openai`
|
|
11
|
+
*/
|
|
12
|
+
export type OpenAiCompatibleExecutionToolsOptions = OpenAiCompatibleExecutionToolsNonProxiedOptions | OpenAiCompatibleExecutionToolsProxiedOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Options for directly used `OpenAiCompatibleExecutionTools`
|
|
15
|
+
*
|
|
16
|
+
* This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
|
|
17
|
+
* @public exported from `@promptbook/openai`
|
|
18
|
+
*/
|
|
19
|
+
export type OpenAiCompatibleExecutionToolsNonProxiedOptions = CommonToolsOptions & ClientOptions & {
|
|
20
|
+
/**
|
|
21
|
+
* Base URL for the OpenAI-compatible API endpoint
|
|
22
|
+
*
|
|
23
|
+
* This allows connecting to any OpenAI-compatible LLM service by specifying their API endpoint.
|
|
24
|
+
*
|
|
25
|
+
* @example 'https://https://promptbook.s5.ptbk.io/' (Promptbook)
|
|
26
|
+
* @example 'https://api.openai.com/v1' (OpenAI)
|
|
27
|
+
* @example 'http://localhost:11434/v1' (Ollama)
|
|
28
|
+
* @example 'https://api.deepseek.com/v1' (DeepSeek)
|
|
29
|
+
*/
|
|
30
|
+
baseURL?: string;
|
|
31
|
+
isProxied?: false;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Options for proxied `OpenAiCompatibleExecutionTools`
|
|
35
|
+
*
|
|
36
|
+
* This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
|
|
37
|
+
* @public exported from `@promptbook/openai`
|
|
38
|
+
*/
|
|
39
|
+
export type OpenAiCompatibleExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
|
|
40
|
+
/**
|
|
41
|
+
* Base URL for the OpenAI-compatible API endpoint
|
|
42
|
+
*
|
|
43
|
+
* This allows connecting to any OpenAI-compatible LLM service by specifying their API endpoint.
|
|
44
|
+
*
|
|
45
|
+
* @example 'https://https://promptbook.s5.ptbk.io/' (Promptbook)
|
|
46
|
+
* @example 'https://api.openai.com/v1' (OpenAI)
|
|
47
|
+
* @example 'http://localhost:11434/v1' (Ollama)
|
|
48
|
+
* @example 'https://api.deepseek.com/v1' (DeepSeek)
|
|
49
|
+
*/
|
|
50
|
+
baseURL?: string;
|
|
51
|
+
isProxied: true;
|
|
52
|
+
} & Pick<RemoteClientOptions<undefined>, 'remoteServerUrl'>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
1
|
+
import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
3
2
|
/**
|
|
4
3
|
* Options for `createOpenAiExecutionTools` and `OpenAiExecutionTools`
|
|
5
4
|
*
|
|
6
|
-
* This extends
|
|
7
|
-
* Rest is used by the `OpenAiExecutionTools`.
|
|
5
|
+
* This extends OpenAiCompatibleExecutionToolsOptions.
|
|
8
6
|
*
|
|
9
7
|
* @public exported from `@promptbook/openai`
|
|
10
8
|
*/
|
|
11
|
-
export type OpenAiExecutionToolsOptions =
|
|
9
|
+
export type OpenAiExecutionToolsOptions = OpenAiCompatibleExecutionToolsOptions;
|
|
@@ -0,0 +1,74 @@
|
|
|
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_model_name } from '../../types/typeAliases';
|
|
7
|
+
import type { string_title } from '../../types/typeAliases';
|
|
8
|
+
import { RemoteLlmExecutionTools } from '../remote/RemoteLlmExecutionTools';
|
|
9
|
+
import { computeOpenAiUsage } from './computeOpenAiUsage';
|
|
10
|
+
import { OpenAiCompatibleExecutionTools } from './OpenAiCompatibleExecutionTools';
|
|
11
|
+
import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
12
|
+
import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
|
|
13
|
+
/**
|
|
14
|
+
* Execution Tools for calling OpenAI compatible API
|
|
15
|
+
*
|
|
16
|
+
* Note: This can be used for any OpenAI compatible APIs
|
|
17
|
+
*
|
|
18
|
+
* @public exported from `@promptbook/openai`
|
|
19
|
+
*/
|
|
20
|
+
export declare const createOpenAiCompatibleExecutionTools: ((options: OpenAiCompatibleExecutionToolsOptions & {
|
|
21
|
+
/**
|
|
22
|
+
* The model name to use for all operations
|
|
23
|
+
*
|
|
24
|
+
* This will be the only model available through this LLM provider and it will be a chat model.
|
|
25
|
+
* Other variants won't be available for now.
|
|
26
|
+
*/
|
|
27
|
+
defaultModelName: string_model_name;
|
|
28
|
+
}) => OpenAiCompatibleExecutionTools | RemoteLlmExecutionTools) & {
|
|
29
|
+
packageName: string;
|
|
30
|
+
className: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Execution Tools for calling ONE SPECIFIC PRECONFIGURED OpenAI compatible provider
|
|
34
|
+
*
|
|
35
|
+
* @private for `createOpenAiCompatibleExecutionTools`
|
|
36
|
+
*/
|
|
37
|
+
export declare class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
|
|
38
|
+
private readonly defaultModelName;
|
|
39
|
+
protected readonly options: OpenAiCompatibleExecutionToolsNonProxiedOptions;
|
|
40
|
+
/**
|
|
41
|
+
* Creates OpenAI compatible Execution Tools.
|
|
42
|
+
*
|
|
43
|
+
* @param options which are relevant are directly passed to the OpenAI compatible client
|
|
44
|
+
*/
|
|
45
|
+
constructor(defaultModelName: string_model_name, options: OpenAiCompatibleExecutionToolsNonProxiedOptions);
|
|
46
|
+
get title(): string_title & string_markdown_text;
|
|
47
|
+
get description(): string_markdown;
|
|
48
|
+
/**
|
|
49
|
+
* List all available models (non dynamically)
|
|
50
|
+
*
|
|
51
|
+
* Note: Purpose of this is to provide more information about models than standard listing from API
|
|
52
|
+
*/
|
|
53
|
+
protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
|
|
54
|
+
/**
|
|
55
|
+
* Computes the usage
|
|
56
|
+
*/
|
|
57
|
+
protected computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
|
|
58
|
+
/**
|
|
59
|
+
* Default model for chat variant.
|
|
60
|
+
*/
|
|
61
|
+
protected getDefaultChatModel(): AvailableModel;
|
|
62
|
+
/**
|
|
63
|
+
* Default model for completion variant.
|
|
64
|
+
*/
|
|
65
|
+
protected getDefaultCompletionModel(): AvailableModel;
|
|
66
|
+
/**
|
|
67
|
+
* Default model for completion variant.
|
|
68
|
+
*/
|
|
69
|
+
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
73
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
74
|
+
*/
|
|
@@ -19,6 +19,17 @@ export declare const _OpenAiMetadataRegistration: Registration;
|
|
|
19
19
|
* @public exported from `@promptbook/cli`
|
|
20
20
|
*/
|
|
21
21
|
export declare const _OpenAiAssistantMetadataRegistration: Registration;
|
|
22
|
+
/**
|
|
23
|
+
* Registration of the OpenAI Compatible metadata
|
|
24
|
+
*
|
|
25
|
+
* Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly.
|
|
26
|
+
* It serves as a base class for OpenAiExecutionTools and other compatible implementations.
|
|
27
|
+
*
|
|
28
|
+
* @public exported from `@promptbook/core`
|
|
29
|
+
* @public exported from `@promptbook/wizard`
|
|
30
|
+
* @public exported from `@promptbook/cli`
|
|
31
|
+
*/
|
|
32
|
+
export declare const _OpenAiCompatibleMetadataRegistration: Registration;
|
|
22
33
|
/**
|
|
23
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24
35
|
*/
|
|
@@ -19,6 +19,20 @@ export declare const _OpenAiRegistration: Registration;
|
|
|
19
19
|
* @public exported from `@promptbook/cli`
|
|
20
20
|
*/
|
|
21
21
|
export declare const _OpenAiAssistantRegistration: Registration;
|
|
22
|
+
/**
|
|
23
|
+
* Registration of the OpenAI Compatible provider
|
|
24
|
+
*
|
|
25
|
+
* Note: [🏐] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
|
|
26
|
+
*
|
|
27
|
+
* @public exported from `@promptbook/openai`
|
|
28
|
+
* @public exported from `@promptbook/wizard`
|
|
29
|
+
* @public exported from `@promptbook/cli`
|
|
30
|
+
*/
|
|
31
|
+
export declare const _OpenAiCompatibleRegistration: Registration;
|
|
32
|
+
/**
|
|
33
|
+
* Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
|
|
34
|
+
* It serves as a base class for OpenAiExecutionTools and other compatible implementations.
|
|
35
|
+
*/
|
|
22
36
|
/**
|
|
23
37
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
24
38
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -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.
|
|
18
|
+
* It follows semantic versioning (e.g., `0.98.0-9`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0-10",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -74,13 +74,14 @@
|
|
|
74
74
|
"module": "./esm/index.es.js",
|
|
75
75
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@promptbook/core": "0.
|
|
77
|
+
"@promptbook/core": "0.98.0-10"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"bottleneck": "^2.19.5",
|
|
81
81
|
"colors": "1.4.0",
|
|
82
82
|
"crypto": "1.0.1",
|
|
83
83
|
"openai": "4.63.0",
|
|
84
|
+
"socket.io-client": "4.7.2",
|
|
84
85
|
"spacetrim": "0.11.59"
|
|
85
86
|
}
|
|
86
87
|
}
|