@promptbook/types 0.66.0-0 → 0.66.0-4
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/typings/src/_packages/anthropic-claude.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +12 -2
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -2
- package/esm/typings/src/config.d.ts +15 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +20 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +12 -24
- package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsConfigurationBoilerplatesRegister.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/$llmToolsRegister.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +2 -10
- package/esm/typings/src/llm-providers/_common/config.d.ts +5 -6
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +18 -0
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.test.d.ts +4 -0
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +7 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register1.d.ts +4 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
- package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.d.ts → computeOpenAiUsage.d.ts} +6 -2
- package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.test.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +15 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +11 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +5 -2
- package/esm/typings/src/utils/Register.d.ts +22 -0
- package/esm/typings/src/utils/environment/getGlobalScope.d.ts +3 -0
- package/package.json +2 -2
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.test.d.ts +0 -1
|
@@ -5,6 +5,8 @@ import type { AnthropicClaudeExecutionToolsOptions } from '../llm-providers/anth
|
|
|
5
5
|
import type { AnthropicClaudeExecutionToolsDirectOptions } from '../llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions';
|
|
6
6
|
import type { AnthropicClaudeExecutionToolsProxiedOptions } from '../llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions';
|
|
7
7
|
import { createAnthropicClaudeExecutionTools } from '../llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools';
|
|
8
|
+
import { _AnthropicClaudeRegistration } from '../llm-providers/anthropic-claude/register-constructor';
|
|
9
|
+
import { _ } from '../llm-providers/anthropic-claude/register1';
|
|
8
10
|
export { PROMPTBOOK_VERSION };
|
|
9
11
|
export { ANTHROPIC_CLAUDE_MODELS };
|
|
10
12
|
export { AnthropicClaudeExecutionTools };
|
|
@@ -12,3 +14,5 @@ export type { AnthropicClaudeExecutionToolsOptions };
|
|
|
12
14
|
export type { AnthropicClaudeExecutionToolsDirectOptions };
|
|
13
15
|
export type { AnthropicClaudeExecutionToolsProxiedOptions };
|
|
14
16
|
export { createAnthropicClaudeExecutionTools };
|
|
17
|
+
export { _AnthropicClaudeRegistration };
|
|
18
|
+
export { _ };
|
|
@@ -15,6 +15,8 @@ import { MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL } from '../config';
|
|
|
15
15
|
import { EXECUTIONS_CACHE_DIRNAME } from '../config';
|
|
16
16
|
import { PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
|
|
17
17
|
import { RESERVED_PARAMETER_NAMES } from '../config';
|
|
18
|
+
import { DEFAULT_REMOTE_URL } from '../config';
|
|
19
|
+
import { DEFAULT_REMOTE_URL_PATH } from '../config';
|
|
18
20
|
import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
|
|
19
21
|
import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
|
|
20
22
|
import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
|
|
@@ -45,12 +47,15 @@ import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackIn
|
|
|
45
47
|
import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
|
|
46
48
|
import { prepareKnowledgePieces } from '../knowledge/prepare-knowledge/_common/prepareKnowledgePieces';
|
|
47
49
|
import { prepareKnowledgeFromMarkdown } from '../knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown';
|
|
48
|
-
import {
|
|
50
|
+
import { $llmToolsConfigurationBoilerplatesRegister } from '../llm-providers/_common/$llmToolsConfigurationBoilerplatesRegister';
|
|
51
|
+
import { $llmToolsRegister } from '../llm-providers/_common/$llmToolsRegister';
|
|
49
52
|
import { createLlmToolsFromConfiguration } from '../llm-providers/_common/createLlmToolsFromConfiguration';
|
|
50
53
|
import { cacheLlmTools } from '../llm-providers/_common/utils/cache/cacheLlmTools';
|
|
51
54
|
import { countTotalUsage } from '../llm-providers/_common/utils/count-total-usage/countTotalUsage';
|
|
52
55
|
import { limitTotalUsage } from '../llm-providers/_common/utils/count-total-usage/limitTotalUsage';
|
|
56
|
+
import { _AnthropicClaudeConfigurationRegistration } from '../llm-providers/anthropic-claude/register-configuration';
|
|
53
57
|
import { joinLlmExecutionTools } from '../llm-providers/multiple/joinLlmExecutionTools';
|
|
58
|
+
import { _OpenAiConfigurationRegistration } from '../llm-providers/openai/register-configuration';
|
|
54
59
|
import { preparePersona } from '../personas/preparePersona';
|
|
55
60
|
import { isPipelinePrepared } from '../prepare/isPipelinePrepared';
|
|
56
61
|
import { preparePipeline } from '../prepare/preparePipeline';
|
|
@@ -80,6 +85,8 @@ export { MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL };
|
|
|
80
85
|
export { EXECUTIONS_CACHE_DIRNAME };
|
|
81
86
|
export { PIPELINE_COLLECTION_BASE_FILENAME };
|
|
82
87
|
export { RESERVED_PARAMETER_NAMES };
|
|
88
|
+
export { DEFAULT_REMOTE_URL };
|
|
89
|
+
export { DEFAULT_REMOTE_URL_PATH };
|
|
83
90
|
export { pipelineJsonToString };
|
|
84
91
|
export type { PipelineStringToJsonOptions };
|
|
85
92
|
export { pipelineStringToJson };
|
|
@@ -110,12 +117,15 @@ export { CallbackInterfaceTools };
|
|
|
110
117
|
export type { CallbackInterfaceToolsOptions };
|
|
111
118
|
export { prepareKnowledgePieces };
|
|
112
119
|
export { prepareKnowledgeFromMarkdown };
|
|
113
|
-
export {
|
|
120
|
+
export { $llmToolsConfigurationBoilerplatesRegister };
|
|
121
|
+
export { $llmToolsRegister };
|
|
114
122
|
export { createLlmToolsFromConfiguration };
|
|
115
123
|
export { cacheLlmTools };
|
|
116
124
|
export { countTotalUsage };
|
|
117
125
|
export { limitTotalUsage };
|
|
126
|
+
export { _AnthropicClaudeConfigurationRegistration };
|
|
118
127
|
export { joinLlmExecutionTools };
|
|
128
|
+
export { _OpenAiConfigurationRegistration };
|
|
119
129
|
export { preparePersona };
|
|
120
130
|
export { isPipelinePrepared };
|
|
121
131
|
export { preparePipeline };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { PROMPTBOOK_VERSION } from '../version';
|
|
2
|
+
import { createOpenAiExecutionTools } from '../llm-providers/openai/createOpenAiExecutionTools';
|
|
2
3
|
import { OPENAI_MODELS } from '../llm-providers/openai/openai-models';
|
|
3
4
|
import { OpenAiExecutionTools } from '../llm-providers/openai/OpenAiExecutionTools';
|
|
4
5
|
import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
|
|
6
|
+
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
5
7
|
export { PROMPTBOOK_VERSION };
|
|
8
|
+
export { createOpenAiExecutionTools };
|
|
6
9
|
export { OPENAI_MODELS };
|
|
7
10
|
export { OpenAiExecutionTools };
|
|
8
11
|
export type { OpenAiExecutionToolsOptions };
|
|
12
|
+
export { _OpenAiRegistration };
|
|
@@ -10,11 +10,12 @@ import type { ExpectFormatCommand } from '../commands/EXPECT/ExpectFormatCommand
|
|
|
10
10
|
import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
|
|
11
11
|
import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
|
|
12
12
|
import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
13
|
+
import type { AvailableModel } from '../execution/AvailableModel';
|
|
13
14
|
import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
|
|
14
15
|
import type { EmbeddingVector } from '../execution/EmbeddingVector';
|
|
15
16
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
16
17
|
import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
17
|
-
import type {
|
|
18
|
+
import type { LlmExecutionToolsConstructor } from '../execution/LlmExecutionToolsConstructor';
|
|
18
19
|
import type { PipelineExecutor } from '../execution/PipelineExecutor';
|
|
19
20
|
import type { PipelineExecutorResult } from '../execution/PipelineExecutor';
|
|
20
21
|
import type { PromptResult } from '../execution/PromptResult';
|
|
@@ -212,6 +213,7 @@ import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_S
|
|
|
212
213
|
import type { string_snake_case } from '../utils/normalization/normalizeTo_snake_case';
|
|
213
214
|
import type { really_any } from '../utils/organization/really_any';
|
|
214
215
|
import type { TODO_any } from '../utils/organization/TODO_any';
|
|
216
|
+
import type { Registered } from '../utils/Register';
|
|
215
217
|
import type { string_promptbook_version } from '../version';
|
|
216
218
|
export type { PipelineCollection };
|
|
217
219
|
export type { Command };
|
|
@@ -225,11 +227,12 @@ export type { ExpectFormatCommand };
|
|
|
225
227
|
export type { PipelineStringToJsonOptions };
|
|
226
228
|
export type { PrettifyOptions };
|
|
227
229
|
export type { renderPipelineMermaidOptions };
|
|
230
|
+
export type { AvailableModel };
|
|
228
231
|
export type { CommonExecutionToolsOptions };
|
|
229
232
|
export type { EmbeddingVector };
|
|
230
233
|
export type { ExecutionTools };
|
|
231
234
|
export type { LlmExecutionTools };
|
|
232
|
-
export type {
|
|
235
|
+
export type { LlmExecutionToolsConstructor };
|
|
233
236
|
export type { PipelineExecutor };
|
|
234
237
|
export type { PipelineExecutorResult };
|
|
235
238
|
export type { PromptResult };
|
|
@@ -427,4 +430,5 @@ export type { string_SCREAMING_CASE };
|
|
|
427
430
|
export type { string_snake_case };
|
|
428
431
|
export type { really_any };
|
|
429
432
|
export type { TODO_any };
|
|
433
|
+
export type { Registered };
|
|
430
434
|
export type { string_promptbook_version };
|
|
@@ -107,9 +107,24 @@ export declare const RESERVED_PARAMETER_RESTRICTED: string;
|
|
|
107
107
|
export declare const MOMENT_ARG_THRESHOLDS: {
|
|
108
108
|
readonly ss: 3;
|
|
109
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* @@@
|
|
112
|
+
*
|
|
113
|
+
* @public exported from `@promptbook/core`
|
|
114
|
+
*/
|
|
115
|
+
export declare const DEFAULT_REMOTE_URL = "https://api.pavolhejny.com/";
|
|
116
|
+
/**
|
|
117
|
+
* @@@
|
|
118
|
+
*
|
|
119
|
+
* @public exported from `@promptbook/core`
|
|
120
|
+
*/
|
|
121
|
+
export declare const DEFAULT_REMOTE_URL_PATH = "/promptbook/socket.io";
|
|
110
122
|
/**
|
|
111
123
|
* @@@
|
|
112
124
|
*
|
|
113
125
|
* @private within the repository
|
|
114
126
|
*/
|
|
115
127
|
export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
130
|
+
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelVariant } from '../types/ModelVariant';
|
|
2
|
+
import type { string_model_name } from '../types/typeAliases';
|
|
3
|
+
import type { string_title } from '../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a model that can be used for prompt execution
|
|
6
|
+
*/
|
|
7
|
+
export type AvailableModel = {
|
|
8
|
+
/**
|
|
9
|
+
* The model title
|
|
10
|
+
*/
|
|
11
|
+
readonly modelTitle: string_title;
|
|
12
|
+
/**
|
|
13
|
+
* The model name aviailable
|
|
14
|
+
*/
|
|
15
|
+
readonly modelName: string_model_name;
|
|
16
|
+
/**
|
|
17
|
+
* Variant of the model
|
|
18
|
+
*/
|
|
19
|
+
readonly modelVariant: ModelVariant;
|
|
20
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { ModelVariant } from '../types/ModelVariant';
|
|
3
2
|
import type { Prompt } from '../types/Prompt';
|
|
4
3
|
import type { string_markdown } from '../types/typeAliases';
|
|
5
4
|
import type { string_markdown_text } from '../types/typeAliases';
|
|
6
|
-
import type { string_model_name } from '../types/typeAliases';
|
|
7
5
|
import type { string_title } from '../types/typeAliases';
|
|
6
|
+
import type { AvailableModel } from './AvailableModel';
|
|
8
7
|
import type { ChatPromptResult } from './PromptResult';
|
|
9
8
|
import type { CompletionPromptResult } from './PromptResult';
|
|
10
9
|
import type { EmbeddingPromptResult } from './PromptResult';
|
|
@@ -29,42 +28,31 @@ export type LlmExecutionTools = {
|
|
|
29
28
|
*/
|
|
30
29
|
readonly description: string_markdown;
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* Calls a completion model
|
|
37
|
-
*/
|
|
38
|
-
callCompletionModel?(prompt: Prompt): Promise<CompletionPromptResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Calls an embedding model
|
|
31
|
+
* Check comfiguration
|
|
32
|
+
*
|
|
33
|
+
* @returns nothing if configuration is correct
|
|
34
|
+
* @throws {Error} if configuration is incorrect
|
|
41
35
|
*/
|
|
42
|
-
callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
|
|
43
36
|
/**
|
|
44
37
|
* List all available models that can be used
|
|
45
38
|
*/
|
|
46
39
|
listModels(): Promisable<Array<AvailableModel>>;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Represents a model that can be used for prompt execution
|
|
50
|
-
*/
|
|
51
|
-
export type AvailableModel = {
|
|
52
40
|
/**
|
|
53
|
-
*
|
|
41
|
+
* Calls a chat model
|
|
54
42
|
*/
|
|
55
|
-
|
|
43
|
+
callChatModel?(prompt: Prompt): Promise<ChatPromptResult>;
|
|
56
44
|
/**
|
|
57
|
-
*
|
|
45
|
+
* Calls a completion model
|
|
58
46
|
*/
|
|
59
|
-
|
|
47
|
+
callCompletionModel?(prompt: Prompt): Promise<CompletionPromptResult>;
|
|
60
48
|
/**
|
|
61
|
-
*
|
|
49
|
+
* Calls an embedding model
|
|
62
50
|
*/
|
|
63
|
-
|
|
51
|
+
callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
|
|
64
52
|
};
|
|
65
53
|
/**
|
|
54
|
+
* TODO: Implement destroyable pattern to free resources
|
|
66
55
|
* TODO: [🏳] Add `callTranslationModel`
|
|
67
|
-
* TODO: Maybe reorder `listModels` and put it befor `callChatModel`, `callCompletionModel`, `callEmbeddingModel`
|
|
68
56
|
* TODO: [🧠] Emulation of one type of model with another one - emuate chat with completion; emulate translation with chat
|
|
69
57
|
* TODO: [🍓][♐] Some heuristic to pick the best model in listed models
|
|
70
58
|
* TODO: [🧠] Should or should not there be a word "GPT" in both callCompletionModel and callChatModel
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TODO_any } from '../utils/organization/TODO_any';
|
|
2
|
+
import type { Registered } from '../utils/Register';
|
|
3
|
+
import type { LlmExecutionTools } from './LlmExecutionTools';
|
|
4
|
+
/**
|
|
5
|
+
* @@@
|
|
6
|
+
*/
|
|
7
|
+
export type LlmExecutionToolsConstructor = Registered & ((options: TODO_any) => LlmExecutionTools);
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
10
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Register } from '../../utils/Register';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
6
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
7
|
+
* @public exported from `@promptbook/core`
|
|
8
|
+
*/
|
|
9
|
+
export declare const $llmToolsConfigurationBoilerplatesRegister: Register<import("../../utils/Register").Registered & {
|
|
10
|
+
title: string;
|
|
11
|
+
options: object;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LlmExecutionToolsConstructor } from '../../execution/LlmExecutionToolsConstructor';
|
|
2
|
+
import { Register } from '../../utils/Register';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* Note: `$` is used to indicate that this interacts with the global scope
|
|
7
|
+
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
8
|
+
* @public exported from `@promptbook/core`
|
|
9
|
+
*/
|
|
10
|
+
export declare const $llmToolsRegister: Register<LlmExecutionToolsConstructor>;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import type { string_title } from '../../types/typeAliases';
|
|
2
2
|
import type { TODO_object } from '../../utils/organization/TODO_object';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Registered } from '../../utils/Register';
|
|
4
4
|
/**
|
|
5
5
|
* @@@
|
|
6
6
|
*/
|
|
7
|
-
export type LlmToolsConfiguration = Array<{
|
|
7
|
+
export type LlmToolsConfiguration = Array<Registered & {
|
|
8
8
|
/**
|
|
9
9
|
* @@@
|
|
10
10
|
*/
|
|
11
11
|
title: string_title;
|
|
12
|
-
/**
|
|
13
|
-
* @@@
|
|
14
|
-
*/
|
|
15
|
-
packageName: TODO_string;
|
|
16
|
-
/**
|
|
17
|
-
* @@@
|
|
18
|
-
*/
|
|
19
|
-
className: TODO_string;
|
|
20
12
|
/**
|
|
21
13
|
* @@@
|
|
22
14
|
*/
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
2
2
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
3
|
-
import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
|
|
4
|
-
/**
|
|
5
|
-
* @public exported from `@promptbook/core`
|
|
6
|
-
*/
|
|
7
|
-
export declare const LLM_CONFIGURATION_BOILERPLATES: LlmToolsConfiguration;
|
|
8
3
|
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*
|
|
6
|
+
* TODO: !!!!!! Not centralized - register each provider to each package
|
|
7
|
+
*
|
|
9
8
|
* @private internal type for `createLlmToolsFromConfiguration`
|
|
10
9
|
*/
|
|
11
10
|
export declare const EXECUTION_TOOLS_CLASSES: Record<`create${string}`, (options: TODO_any) => LlmExecutionTools>;
|
|
12
11
|
/**
|
|
13
|
-
* TODO:
|
|
12
|
+
* TODO: !!!!!!! Make global register for this
|
|
14
13
|
* TODO: [🧠][🎌] Adding this should be responsibility of each provider package NOT this one central place
|
|
15
14
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AvailableModel } from '../../execution/
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { Prompt } from '../../types/Prompt';
|
|
@@ -47,7 +47,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
|
|
|
47
47
|
* TODO: [🍆] JSON mode
|
|
48
48
|
* TODO: [🧠] Maybe handle errors via transformAnthropicError (like transformAzureError)
|
|
49
49
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
50
|
-
* TODO: Maybe make custom
|
|
50
|
+
* TODO: Maybe make custom OpenAiError
|
|
51
51
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
52
52
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
53
53
|
* TODO: [📅] Maybe instead of `RemoteLlmExecutionToolsOptions` use `proxyWithAnonymousRemoteServer` (if implemented)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
3
|
+
import type { PromptResultUsage } from '../../execution/PromptResultUsage';
|
|
4
|
+
import type { Prompt } from '../../types/Prompt';
|
|
5
|
+
/**
|
|
6
|
+
* Computes the usage of the Anthropic Claude API based on the response from Anthropic Claude
|
|
7
|
+
*
|
|
8
|
+
* @param promptContent The content of the prompt
|
|
9
|
+
* @param resultContent The content of the result (for embedding prompts or failed prompts pass empty string)
|
|
10
|
+
* @param rawResponse The raw response from Anthropic Claude API
|
|
11
|
+
* @throws {PipelineExecutionError} If the usage is not defined in the response from Anthropic Claude
|
|
12
|
+
* @private internal utility of `AnthropicClaudeExecutionTools`
|
|
13
|
+
*/
|
|
14
|
+
export declare function computeAnthropicClaudeUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
15
|
+
resultContent: string, rawResponse: PartialDeep<Pick<Anthropic.Messages.Message, 'model' | 'usage'>>): PromptResultUsage;
|
|
16
|
+
/**
|
|
17
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
18
|
+
*/
|
package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts
CHANGED
|
@@ -6,9 +6,14 @@ import type { AnthropicClaudeExecutionToolsOptions } from './AnthropicClaudeExec
|
|
|
6
6
|
*
|
|
7
7
|
* @public exported from `@promptbook/anthropic-claude`
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare const createAnthropicClaudeExecutionTools: ((options: AnthropicClaudeExecutionToolsOptions) => AnthropicClaudeExecutionTools | RemoteLlmExecutionTools) & {
|
|
10
|
+
packageName: string;
|
|
11
|
+
className: string;
|
|
12
|
+
};
|
|
10
13
|
/**
|
|
11
14
|
* TODO: [🧠] !!!! Make anonymous this with all LLM providers
|
|
12
|
-
* TODO: [🧠] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
15
|
+
* TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
13
16
|
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
17
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
18
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
14
19
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@ registration1 of default configuration for Anthropic Claude
|
|
3
|
+
*
|
|
4
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/core`
|
|
7
|
+
*/
|
|
8
|
+
export declare const _AnthropicClaudeConfigurationRegistration: void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@ registration2
|
|
3
|
+
*
|
|
4
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/anthropic-claude`
|
|
7
|
+
*/
|
|
8
|
+
export declare const _AnthropicClaudeRegistration: void;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
11
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AvailableModel } from '../../execution/
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -45,7 +45,7 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
48
|
-
* TODO: Maybe make custom
|
|
48
|
+
* TODO: Maybe make custom AzureOpenAiError
|
|
49
49
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
50
50
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
51
51
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
1
2
|
import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
|
|
2
|
-
import type { AvailableModel } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
5
5
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
1
2
|
import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
|
|
2
|
-
import type { AvailableModel } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
5
5
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AvailableModel } from '../../execution/
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AvailableModel } from '../../execution/
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -9,7 +9,7 @@ import type { string_markdown_text } from '../../types/typeAliases';
|
|
|
9
9
|
import type { string_title } from '../../types/typeAliases';
|
|
10
10
|
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
11
11
|
/**
|
|
12
|
-
* Execution Tools for calling OpenAI API
|
|
12
|
+
* Execution Tools for calling OpenAI API
|
|
13
13
|
*
|
|
14
14
|
* @public exported from `@promptbook/openai`
|
|
15
15
|
*/
|
|
@@ -63,7 +63,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
|
63
63
|
/**
|
|
64
64
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
65
65
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
66
|
-
* TODO: Maybe make custom
|
|
66
|
+
* TODO: Maybe make custom OpenAiError
|
|
67
67
|
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
68
68
|
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
69
69
|
*/
|
package/esm/typings/src/llm-providers/openai/{computeOpenaiUsage.d.ts → computeOpenAiUsage.d.ts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type OpenAI from 'openai';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
import type { PromptResultUsage } from '../../execution/PromptResultUsage';
|
|
3
4
|
import type { Prompt } from '../../types/Prompt';
|
|
4
5
|
/**
|
|
@@ -10,5 +11,8 @@ import type { Prompt } from '../../types/Prompt';
|
|
|
10
11
|
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
11
12
|
* @private internal utility of `OpenAiExecutionTools`
|
|
12
13
|
*/
|
|
13
|
-
export declare function
|
|
14
|
-
resultContent: string, rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion | OpenAI.Embeddings.CreateEmbeddingResponse, 'model' | 'usage'
|
|
14
|
+
export declare function computeOpenAiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
15
|
+
resultContent: string, rawResponse: PartialDeep<Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion | OpenAI.Embeddings.CreateEmbeddingResponse, 'model' | 'usage'>>): PromptResultUsage;
|
|
16
|
+
/**
|
|
17
|
+
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
18
|
+
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
2
|
+
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Execution Tools for calling OpenAI API
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/openai`
|
|
7
|
+
*/
|
|
8
|
+
export declare const createOpenAiExecutionTools: ((options: OpenAiExecutionToolsOptions) => OpenAiExecutionTools) & {
|
|
9
|
+
packageName: string;
|
|
10
|
+
className: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
14
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15
|
+
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@ registration2
|
|
3
|
+
*
|
|
4
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/openai`
|
|
7
|
+
*/
|
|
8
|
+
export declare const _OpenAiRegistration: void;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
11
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AvailableModel } from '../../execution/
|
|
1
|
+
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { AvailableModel } from '../../../execution/AvailableModel';
|
|
1
2
|
import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
|
|
2
|
-
import type { AvailableModel } from '../../../execution/LlmExecutionTools';
|
|
3
3
|
import type { client_id } from '../../../types/typeAliases';
|
|
4
4
|
import type { string_base_url } from '../../../types/typeAliases';
|
|
5
5
|
import type { string_uri } from '../../../types/typeAliases';
|
|
@@ -25,7 +25,7 @@ export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
|
25
25
|
/**
|
|
26
26
|
* If set, only these models will be listed as available
|
|
27
27
|
*
|
|
28
|
-
* TODO: [🧠]
|
|
28
|
+
* TODO: [🧠] !!!!!! Figure out better solution
|
|
29
29
|
*/
|
|
30
30
|
readonly models?: Array<AvailableModel>;
|
|
31
31
|
/**
|
|
@@ -51,3 +51,6 @@ export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
|
|
|
51
51
|
*/
|
|
52
52
|
readonly clientId: client_id;
|
|
53
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
56
|
+
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TODO_string } from './organization/TODO_string';
|
|
2
|
+
export type Registered = {
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*/
|
|
6
|
+
packageName: TODO_string;
|
|
7
|
+
/**
|
|
8
|
+
* @@@
|
|
9
|
+
*/
|
|
10
|
+
className: TODO_string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Register is @@@
|
|
14
|
+
*
|
|
15
|
+
* @private internal utility, exported are only signleton instances of this class
|
|
16
|
+
*/
|
|
17
|
+
export declare class Register<TRegistered extends Registered> {
|
|
18
|
+
private readonly storage;
|
|
19
|
+
constructor(storage: Array<TRegistered>);
|
|
20
|
+
list(): Array<TRegistered>;
|
|
21
|
+
register(registered: TRegistered): void;
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/types",
|
|
3
|
-
"version": "0.66.0-
|
|
3
|
+
"version": "0.66.0-4",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
],
|
|
46
46
|
"typings": "./esm/typings/src/_packages/types.index.d.ts",
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@promptbook/core": "0.66.0-
|
|
48
|
+
"@promptbook/core": "0.66.0-4"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|