@promptbook/remote-server 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/index.es.js +265 -201
- package/esm/index.es.js.map +1 -1
- 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/umd/index.umd.js +265 -201
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.test.d.ts +0 -1
|
@@ -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/remote-server",
|
|
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,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.66.0-
|
|
50
|
+
"@promptbook/core": "0.66.0-4"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@anthropic-ai/sdk": "0.26.1",
|