@promptbook/types 0.66.0-0 → 0.66.0-1

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.
@@ -5,6 +5,7 @@ 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 { _ } from '../llm-providers/anthropic-claude/register1';
8
9
  export { PROMPTBOOK_VERSION };
9
10
  export { ANTHROPIC_CLAUDE_MODELS };
10
11
  export { AnthropicClaudeExecutionTools };
@@ -12,3 +13,4 @@ export type { AnthropicClaudeExecutionToolsOptions };
12
13
  export type { AnthropicClaudeExecutionToolsDirectOptions };
13
14
  export type { AnthropicClaudeExecutionToolsProxiedOptions };
14
15
  export { createAnthropicClaudeExecutionTools };
16
+ export { _ };
@@ -15,6 +15,9 @@ 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';
20
+ import { BOILERPLATE_LLM_TOOLS_CONFIGURATION_ } from '../config';
18
21
  import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
19
22
  import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
20
23
  import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
@@ -45,7 +48,6 @@ import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackIn
45
48
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
46
49
  import { prepareKnowledgePieces } from '../knowledge/prepare-knowledge/_common/prepareKnowledgePieces';
47
50
  import { prepareKnowledgeFromMarkdown } from '../knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown';
48
- import { LLM_CONFIGURATION_BOILERPLATES } from '../llm-providers/_common/config';
49
51
  import { createLlmToolsFromConfiguration } from '../llm-providers/_common/createLlmToolsFromConfiguration';
50
52
  import { cacheLlmTools } from '../llm-providers/_common/utils/cache/cacheLlmTools';
51
53
  import { countTotalUsage } from '../llm-providers/_common/utils/count-total-usage/countTotalUsage';
@@ -80,6 +82,9 @@ export { MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL };
80
82
  export { EXECUTIONS_CACHE_DIRNAME };
81
83
  export { PIPELINE_COLLECTION_BASE_FILENAME };
82
84
  export { RESERVED_PARAMETER_NAMES };
85
+ export { DEFAULT_REMOTE_URL };
86
+ export { DEFAULT_REMOTE_URL_PATH };
87
+ export { BOILERPLATE_LLM_TOOLS_CONFIGURATION_ };
83
88
  export { pipelineJsonToString };
84
89
  export type { PipelineStringToJsonOptions };
85
90
  export { pipelineStringToJson };
@@ -110,7 +115,6 @@ export { CallbackInterfaceTools };
110
115
  export type { CallbackInterfaceToolsOptions };
111
116
  export { prepareKnowledgePieces };
112
117
  export { prepareKnowledgeFromMarkdown };
113
- export { LLM_CONFIGURATION_BOILERPLATES };
114
118
  export { createLlmToolsFromConfiguration };
115
119
  export { cacheLlmTools };
116
120
  export { countTotalUsage };
@@ -1,3 +1,4 @@
1
+ import type { LlmToolsConfiguration } from './llm-providers/_common/LlmToolsConfiguration';
1
2
  /**
2
3
  * Warning message for the generated sections and files files
3
4
  *
@@ -107,9 +108,30 @@ export declare const RESERVED_PARAMETER_RESTRICTED: string;
107
108
  export declare const MOMENT_ARG_THRESHOLDS: {
108
109
  readonly ss: 3;
109
110
  };
111
+ /**
112
+ * @@@
113
+ *
114
+ * @public exported from `@promptbook/core`
115
+ */
116
+ export declare const DEFAULT_REMOTE_URL = "https://api.pavolhejny.com/";
117
+ /**
118
+ * @@@
119
+ *
120
+ * @public exported from `@promptbook/core`
121
+ */
122
+ export declare const DEFAULT_REMOTE_URL_PATH = "/promptbook/socket.io";
123
+ /**
124
+ * @@@
125
+ *
126
+ * @public exported from `@promptbook/core`
127
+ */
128
+ export declare const BOILERPLATE_LLM_TOOLS_CONFIGURATION_: LlmToolsConfiguration;
110
129
  /**
111
130
  * @@@
112
131
  *
113
132
  * @private within the repository
114
133
  */
115
134
  export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
135
+ /**
136
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
137
+ */
@@ -28,6 +28,16 @@ export type LlmExecutionTools = {
28
28
  * @example "Use all models from OpenAI"
29
29
  */
30
30
  readonly description: string_markdown;
31
+ /**
32
+ * Check comfiguration
33
+ *
34
+ * @returns nothing if configuration is correct
35
+ * @throws {Error} if configuration is incorrect
36
+ */
37
+ /**
38
+ * List all available models that can be used
39
+ */
40
+ listModels(): Promisable<Array<AvailableModel>>;
31
41
  /**
32
42
  * Calls a chat model
33
43
  */
@@ -40,10 +50,6 @@ export type LlmExecutionTools = {
40
50
  * Calls an embedding model
41
51
  */
42
52
  callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
43
- /**
44
- * List all available models that can be used
45
- */
46
- listModels(): Promisable<Array<AvailableModel>>;
47
53
  };
48
54
  /**
49
55
  * Represents a model that can be used for prompt execution
@@ -63,8 +69,8 @@ export type AvailableModel = {
63
69
  readonly modelVariant: ModelVariant;
64
70
  };
65
71
  /**
72
+ * TODO: Implement destroyable pattern to free resources
66
73
  * TODO: [🏳] Add `callTranslationModel`
67
- * TODO: Maybe reorder `listModels` and put it befor `callChatModel`, `callCompletionModel`, `callEmbeddingModel`
68
74
  * TODO: [🧠] Emulation of one type of model with another one - emuate chat with completion; emulate translation with chat
69
75
  * TODO: [🍓][♐] Some heuristic to pick the best model in listed models
70
76
  * TODO: [🧠] Should or should not there be a word "GPT" in both callCompletionModel and callChatModel
@@ -1,15 +1,10 @@
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
  /**
9
4
  * @private internal type for `createLlmToolsFromConfiguration`
10
5
  */
11
6
  export declare const EXECUTION_TOOLS_CLASSES: Record<`create${string}`, (options: TODO_any) => LlmExecutionTools>;
12
7
  /**
13
- * TODO: [🧠] Better file name than `config.ts` + maybe move to two separate files
8
+ * TODO: !!!!!!! Make global register for this
14
9
  * TODO: [🧠][🎌] Adding this should be responsibility of each provider package NOT this one central place
15
10
  */
@@ -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
+ */
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenaiUsage` and `computeAnthropicClaudeUsage`
4
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @public exported from `@promptbook/anthropic-claude`
3
+ */
4
+ export declare const _: undefined;
@@ -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
  /**
@@ -11,4 +12,7 @@ import type { Prompt } from '../../types/Prompt';
11
12
  * @private internal utility of `OpenAiExecutionTools`
12
13
  */
13
14
  export declare function computeOpenaiUsage(promptContent: Prompt['content'], // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
14
- resultContent: string, rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion | OpenAI.Embeddings.CreateEmbeddingResponse, 'model' | 'usage'>): PromptResultUsage;
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
+ */
@@ -1 +1,4 @@
1
1
  export {};
2
+ /**
3
+ * TODO: [🤝] DRY Maybe some common abstraction between `computeOpenaiUsage` and `computeAnthropicClaudeUsage`
4
+ */
@@ -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: [🧠] !!!! Figure out better solution
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
+ */
@@ -7,3 +7,6 @@ import type { really_any } from '../organization/really_any';
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
9
  export declare function $getGlobalScope(): really_any;
10
+ /***
11
+ * TODO: !!!!! Make private and promptbook registry from this
12
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/types",
3
- "version": "0.66.0-0",
3
+ "version": "0.66.0-1",
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-0"
48
+ "@promptbook/core": "0.66.0-1"
49
49
  }
50
50
  }