@promptbook/remote-client 0.61.0-10 → 0.61.0-11
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 +37 -4
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +83 -2
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -2
- package/esm/typings/src/_packages/utils.index.d.ts +3 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
- package/esm/typings/src/config.d.ts +4 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/{umd/typings/src/errors/VersionMismatch.d.ts → esm/typings/src/errors/VersionMismatchError.d.ts} +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/execution/PipelineExecutor.d.ts +4 -3
- package/esm/typings/src/execution/PromptResult.d.ts +12 -0
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- 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 +3 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/esm/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/esm/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/esm/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/esm/typings/src/personas/preparePersona.d.ts +0 -3
- package/esm/typings/src/prepare/preparePipeline.d.ts +2 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +21 -1
- package/esm/typings/src/types/Parameters.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/esm/typings/src/types/Prompt.d.ts +5 -2
- package/esm/typings/src/types/typeAliases.d.ts +35 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/package.json +2 -2
- package/umd/index.umd.js +37 -4
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +83 -2
- package/umd/typings/src/_packages/core.index.d.ts +2 -2
- package/umd/typings/src/_packages/types.index.d.ts +2 -2
- package/umd/typings/src/_packages/utils.index.d.ts +3 -1
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
- package/umd/typings/src/config.d.ts +4 -0
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -0
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/{esm/typings/src/errors/VersionMismatch.d.ts → umd/typings/src/errors/VersionMismatchError.d.ts} +1 -1
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/execution/PipelineExecutor.d.ts +4 -3
- package/umd/typings/src/execution/PromptResult.d.ts +12 -0
- package/umd/typings/src/execution/ScriptExecutionTools.d.ts +4 -2
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/umd/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/umd/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/umd/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/umd/typings/src/personas/preparePersona.d.ts +0 -3
- package/umd/typings/src/prepare/preparePipeline.d.ts +2 -1
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +21 -1
- package/umd/typings/src/types/Parameters.d.ts +0 -1
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +0 -1
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -5
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +1 -0
- package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/umd/typings/src/types/Prompt.d.ts +5 -2
- package/umd/typings/src/types/typeAliases.d.ts +35 -1
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +7 -0
- package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
- package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +0 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../../../storage/_common/PromptbookStorage';
|
|
2
|
+
import type { CacheItem } from './CacheItem';
|
|
3
|
+
export type CacheLlmToolsOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Total cost of the execution
|
|
6
|
+
*
|
|
7
|
+
* @default MemoryStorage
|
|
8
|
+
*/
|
|
9
|
+
storage: PromptbookStorage<CacheItem>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
2
|
+
import type { CacheLlmToolsOptions } from './CacheLlmToolsOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
5
|
+
*
|
|
6
|
+
* @param llmTools LLM tools to be intercepted with usage counting
|
|
7
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
8
|
+
*/
|
|
9
|
+
export declare function cacheLlmTools(llmTools: LlmExecutionTools, options?: Partial<CacheLlmToolsOptions>): LlmExecutionTools;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: !!!!! Export this util
|
|
12
|
+
* TODO: !!!!! Use this for tests in promptbook project itself
|
|
13
|
+
* TODO: !!!! write discussion about this and storages
|
|
14
|
+
* write how to combine multiple interceptors
|
|
15
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
16
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
17
|
+
*/
|
package/esm/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
2
|
+
import type { PromptResultUsage } from '../../../execution/PromptResult';
|
|
3
|
+
/**
|
|
4
|
+
* LLM tools with option to get total cost of the execution
|
|
5
|
+
*/
|
|
6
|
+
export type LlmExecutionToolsWithTotalCost = LlmExecutionTools & {
|
|
7
|
+
/**
|
|
8
|
+
* Total cost of the execution
|
|
9
|
+
*/
|
|
10
|
+
totalUsage: PromptResultUsage;
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
2
|
+
import type { LlmExecutionToolsWithTotalCost } from './LlmExecutionToolsWithTotalCost';
|
|
3
|
+
/**
|
|
4
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
5
|
+
*
|
|
6
|
+
* @param llmTools LLM tools to be intercepted with usage counting
|
|
7
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
8
|
+
*/
|
|
9
|
+
export declare function countTotalUsage(llmTools: LlmExecutionTools): LlmExecutionToolsWithTotalCost;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: !!!!! Export this utils
|
|
12
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
13
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
14
|
+
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* Note: This function is not cached, every call creates new instance of LlmExecutionTools
|
|
6
|
+
*
|
|
7
|
+
* It looks for environment variables:
|
|
8
|
+
* - `process.env.OPENAI_API_KEY`
|
|
9
|
+
* - `process.env.ANTHROPIC_CLAUDE_API_KEY`
|
|
10
|
+
*
|
|
11
|
+
* @returns @@@
|
|
12
|
+
*/
|
|
13
|
+
export declare function createLlmToolsFromEnv(): LlmExecutionTools;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: !!!!! Export this util
|
|
16
|
+
* TODO: !!!! write discussion about this - wizzard
|
|
17
|
+
* TODO: Add Azure
|
|
18
|
+
* TODO: [🧠] Which name is better `createLlmToolsFromEnv` or `createLlmToolsFromEnvironment`?
|
|
19
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
20
|
+
* TODO: [🧠] Maybe pass env as argument
|
|
21
|
+
*/
|
|
@@ -8,6 +8,3 @@ import type { string_persona_description } from '../types/typeAliases';
|
|
|
8
8
|
* @private within the package
|
|
9
9
|
*/
|
|
10
10
|
export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
|
|
11
|
-
/**
|
|
12
|
-
* TODO: [🪂] Do it in parallel
|
|
13
|
-
*/
|
|
@@ -11,5 +11,6 @@ export declare function preparePipeline(pipeline: PipelineJson, options: Prepare
|
|
|
11
11
|
* TODO: Write tests for `preparePipeline`
|
|
12
12
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
13
13
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
14
|
-
* TODO:
|
|
14
|
+
* TODO: !!!!! Use here countTotalUsage
|
|
15
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
15
16
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Promisable } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* Storage of objects with asynchronous API
|
|
4
|
+
*
|
|
5
|
+
* Note: Naming `PromptbookStorage` not `Storage` to avoid name collision with global `Storage` interface.
|
|
6
|
+
* Note: This is simmilar to Web Storage API interface but everything is asynchronous and can store JSON objects.
|
|
7
|
+
*/
|
|
8
|
+
export type PromptbookStorage<TItem> = {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object
|
|
11
|
+
*/
|
|
12
|
+
getItem(key: string): Promisable<TItem | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously
|
|
15
|
+
*/
|
|
16
|
+
setItem(key: string, value: TItem): Promisable<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists
|
|
19
|
+
*/
|
|
20
|
+
removeItem(key: string): Promisable<void>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* TODO: [🧠][🛫] Constrain `TItem` to JSON-serializable objects only
|
|
24
|
+
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
import type { FilesStorageOptions } from './FilesStorageOptions';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*/
|
|
6
|
+
export declare class FilesStorage<TItem> implements PromptbookStorage<TItem> {
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(options: FilesStorageOptions);
|
|
9
|
+
/**
|
|
10
|
+
* @@@
|
|
11
|
+
*/
|
|
12
|
+
private getFilenameForKey;
|
|
13
|
+
/**
|
|
14
|
+
* @@@ Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
15
|
+
*/
|
|
16
|
+
getItem(key: string): Promise<TItem | null>;
|
|
17
|
+
/**
|
|
18
|
+
* @@@ Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
19
|
+
*/
|
|
20
|
+
setItem(key: string, value: TItem): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @@@ Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
23
|
+
*/
|
|
24
|
+
removeItem(key: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
|
|
28
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* Gets wrapper around `localStorage` object which can be used as `PromptbookStorage`
|
|
4
|
+
*/
|
|
5
|
+
export declare function getLocalStorage<TItem>(): PromptbookStorage<TItem>;
|
|
6
|
+
/**
|
|
7
|
+
* Export through `@promptbook/browser`
|
|
8
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* Gets wrapper around `sessionStorage` object which can be used as `PromptbookStorage`
|
|
4
|
+
*/
|
|
5
|
+
export declare function getSessionStorage<TItem>(): PromptbookStorage<TItem>;
|
|
6
|
+
/**
|
|
7
|
+
* Export through `@promptbook/browser`
|
|
8
|
+
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* Stores
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemoryStorage<TItem> implements PromptbookStorage<TItem> {
|
|
6
|
+
private storage;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
9
|
+
*/
|
|
10
|
+
get length(): number;
|
|
11
|
+
/**
|
|
12
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
13
|
+
*/
|
|
14
|
+
clear(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
17
|
+
*/
|
|
18
|
+
getItem(key: string): TItem | null;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
|
|
21
|
+
*/
|
|
22
|
+
key(index: number): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
25
|
+
*/
|
|
26
|
+
setItem(key: string, value: TItem): void;
|
|
27
|
+
/**
|
|
28
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
29
|
+
*/
|
|
30
|
+
removeItem(key: string): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Promisable } from 'type-fest';
|
|
2
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
3
|
+
/**
|
|
4
|
+
* This class behaves like LocalStorage but separates keys by prefix
|
|
5
|
+
*/
|
|
6
|
+
export declare class PrefixStorage<TItem> implements PromptbookStorage<TItem> {
|
|
7
|
+
private baseStorage;
|
|
8
|
+
private keyPrefix;
|
|
9
|
+
private separator;
|
|
10
|
+
constructor(baseStorage: PromptbookStorage<TItem>, keyPrefix: string, separator?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
13
|
+
*/
|
|
14
|
+
getItem(key: string): Promisable<TItem | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
17
|
+
*/
|
|
18
|
+
setItem(key: string, value: TItem): Promisable<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
21
|
+
*/
|
|
22
|
+
removeItem(key: string): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* @@@
|
|
4
|
+
*
|
|
5
|
+
* @private for `getLocalStorage` and `getSessionStorage`
|
|
6
|
+
*/
|
|
7
|
+
export declare function makePromptbookStorageFromWebStorage<TValue>(webStorage: Storage): PromptbookStorage<TValue>;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: !!!! Export through `@promptbook/browser`
|
|
10
|
+
* TODO: [🧠] Should this be named `makePromptbookStorageFromWebStorage` vs `createPromptbookStorageFromWebStorage`
|
|
11
|
+
* TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
|
|
12
|
+
*/
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { number_model_temperature } from './typeAliases';
|
|
2
|
+
import type { number_seed } from './typeAliases';
|
|
1
3
|
import type { string_model_name } from './typeAliases';
|
|
4
|
+
import type { string_system_message } from './typeAliases';
|
|
2
5
|
export declare const MODEL_VARIANTS: readonly ["COMPLETION", "CHAT", "EMBEDDING"];
|
|
3
6
|
/**
|
|
4
7
|
* Model variant describes the very general type of the model
|
|
@@ -31,13 +34,30 @@ export type ModelRequirements = {
|
|
|
31
34
|
* @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
|
|
32
35
|
*/
|
|
33
36
|
readonly modelName?: string_model_name;
|
|
37
|
+
/**
|
|
38
|
+
* System message to be used in the model
|
|
39
|
+
*/
|
|
40
|
+
readonly systemMessage?: string_system_message;
|
|
41
|
+
/**
|
|
42
|
+
* The temperature of the model
|
|
43
|
+
*
|
|
44
|
+
* Note: [💱] Promptbook is using just `temperature` (not `top_k` and `top_p`)
|
|
45
|
+
*/
|
|
46
|
+
readonly temperature?: number_model_temperature;
|
|
47
|
+
/**
|
|
48
|
+
* Seed for the model
|
|
49
|
+
*/
|
|
50
|
+
readonly seed?: number_seed;
|
|
34
51
|
/**
|
|
35
52
|
* Maximum number of tokens that can be generated by the model
|
|
36
53
|
*/
|
|
37
54
|
readonly maxTokens?: number;
|
|
38
55
|
};
|
|
39
56
|
/**
|
|
40
|
-
* TODO:
|
|
57
|
+
* TODO: [🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (simmilar that `user` identification is not here)
|
|
58
|
+
* TODO: [🧠][💱] Add more model options: `stop_token`, `logit_bias`, `logprobs` (`top_logprobs`), `top_k`, `top_p`, `presence_penalty`, `frequency_penalty`, `bestOf`, `logitBias`, `logitBiasType`,...
|
|
59
|
+
* [💱] Probbably keep using just `temperature` in Promptbook (not `top_k` and `top_p`)
|
|
60
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
41
61
|
* TODO: Maybe figure out better word than "variant"
|
|
42
62
|
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
43
63
|
* TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
|
|
@@ -79,7 +79,6 @@ export type PipelineJson = {
|
|
|
79
79
|
readonly preparations: Array<PreparationJson>;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* TODO: !!!!! Implement new commands
|
|
83
82
|
* Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
|
|
84
83
|
* But then immediately reverted back to the single type
|
|
85
84
|
* With knowledge as part of the promptbook and collection just as a collection of promptbooks
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { PromptResultUsage } from '../../execution/PromptResult';
|
|
2
2
|
import type { string_promptbook_version } from '../../version';
|
|
3
3
|
import type { number_id } from '../typeAliases';
|
|
4
|
-
import type { string_date_iso8601 } from '../typeAliases';
|
|
5
4
|
export type PreparationJson = {
|
|
6
5
|
/**
|
|
7
6
|
* Incremental ID of the preparation
|
|
8
7
|
*/
|
|
9
8
|
readonly id: number_id;
|
|
10
|
-
/**
|
|
11
|
-
* Date and time of the preparation
|
|
12
|
-
*/
|
|
13
|
-
readonly date: string_date_iso8601;
|
|
14
9
|
/**
|
|
15
10
|
* Version of the promptbook used for the preparation
|
|
16
11
|
*/
|
|
@@ -22,4 +17,5 @@ export type PreparationJson = {
|
|
|
22
17
|
};
|
|
23
18
|
/**
|
|
24
19
|
* TODO: Maybe put here used `modelName`
|
|
20
|
+
* TODO: [🍥] When using `date` it changes all samples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
|
|
25
21
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_markdown_text } from '../typeAliases';
|
|
2
|
-
import type {
|
|
2
|
+
import type { string_parameter_name } from '../typeAliases';
|
|
3
|
+
import type { string_parameter_value } from '../typeAliases';
|
|
3
4
|
/**
|
|
4
5
|
* Describes one parameter of the promptbook
|
|
5
6
|
*/
|
|
@@ -9,7 +10,7 @@ export type PromptTemplateParameterJson = {
|
|
|
9
10
|
* - It must be unique across the pipeline
|
|
10
11
|
* - It should start lowercase and contain letters and numbers
|
|
11
12
|
*/
|
|
12
|
-
readonly name:
|
|
13
|
+
readonly name: string_parameter_name;
|
|
13
14
|
/**
|
|
14
15
|
* The parameter is input of the pipeline
|
|
15
16
|
*/
|
|
@@ -23,4 +24,12 @@ export type PromptTemplateParameterJson = {
|
|
|
23
24
|
* - It can use simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
24
25
|
*/
|
|
25
26
|
readonly description?: string_markdown_text;
|
|
27
|
+
/**
|
|
28
|
+
* Sample values of the parameter
|
|
29
|
+
* Note: This values won't be actually used as some default values, but they are just for better understanding of the parameter
|
|
30
|
+
*/
|
|
31
|
+
readonly sampleValues?: Array<string_parameter_value>;
|
|
26
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
35
|
+
*/
|
|
@@ -2,13 +2,15 @@ import type { ExpectFormatCommand } from '../commands/EXPECT/ExpectFormatCommand
|
|
|
2
2
|
import type { PostprocessingFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
3
3
|
import type { ModelRequirements } from './ModelRequirements';
|
|
4
4
|
import type { Expectations } from './PipelineJson/Expectations';
|
|
5
|
-
import type {
|
|
5
|
+
import type { string_parameter_name } from './typeAliases';
|
|
6
|
+
import type { string_parameter_value } from './typeAliases';
|
|
6
7
|
import type { string_pipeline_url_with_hashtemplate } from './typeAliases';
|
|
7
8
|
import type { string_prompt } from './typeAliases';
|
|
8
9
|
import type { string_title } from './typeAliases';
|
|
9
10
|
/**
|
|
10
11
|
* Prompt in a text along with model requirements, but without any execution or templating logic.
|
|
11
12
|
*
|
|
13
|
+
* Note: [🛫] This is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
12
14
|
* @see https://github.com/webgptorg/promptbook#prompt
|
|
13
15
|
*/
|
|
14
16
|
export type Prompt = {
|
|
@@ -58,8 +60,9 @@ export type Prompt = {
|
|
|
58
60
|
*
|
|
59
61
|
* Note: This is redundant (same information is in pipelineUrl+content) but useful for logging and debugging
|
|
60
62
|
*/
|
|
61
|
-
readonly parameters: Record<
|
|
63
|
+
readonly parameters: Record<string_parameter_name, string_parameter_value>;
|
|
62
64
|
};
|
|
63
65
|
/**
|
|
64
66
|
* TODO: [✔] Check ModelRequirements in runtime
|
|
67
|
+
* TODO: [🏳] Add options for translation - maybe create `TranslationPrompt`
|
|
65
68
|
*/
|
|
@@ -32,6 +32,12 @@ export type string_text_prompt = string_prompt;
|
|
|
32
32
|
* For example `"How many hats does the cat wear?"`
|
|
33
33
|
*/
|
|
34
34
|
export type string_chat_prompt = string_text_prompt;
|
|
35
|
+
/**
|
|
36
|
+
* Semantic helper
|
|
37
|
+
*
|
|
38
|
+
* For example `"You are an AI assistant. You are here to help me with my work."`
|
|
39
|
+
*/
|
|
40
|
+
export type string_system_message = string_text_prompt;
|
|
35
41
|
/**
|
|
36
42
|
* Semantic helper
|
|
37
43
|
*
|
|
@@ -73,6 +79,20 @@ export type string_char = string;
|
|
|
73
79
|
* For example `"ainautes"`
|
|
74
80
|
*/
|
|
75
81
|
export type string_name = string;
|
|
82
|
+
/**
|
|
83
|
+
* Semantic helper
|
|
84
|
+
* Unique identifier of anything
|
|
85
|
+
*
|
|
86
|
+
* For example `"eventName"`
|
|
87
|
+
*/
|
|
88
|
+
export type string_parameter_name = string;
|
|
89
|
+
/**
|
|
90
|
+
* Semantic helper
|
|
91
|
+
* Unique identifier of anything
|
|
92
|
+
*
|
|
93
|
+
* For example `"DevConf 2024"`
|
|
94
|
+
*/
|
|
95
|
+
export type string_parameter_value = string;
|
|
76
96
|
/**
|
|
77
97
|
* Semantic helper
|
|
78
98
|
* Title of anything
|
|
@@ -462,9 +482,22 @@ export type number_negative = number;
|
|
|
462
482
|
export type number_integer = number;
|
|
463
483
|
/**
|
|
464
484
|
* Semantic helper;
|
|
465
|
-
* Percentage from 0 to 1 (100%)
|
|
485
|
+
* Percentage from 0 to 1 (100%) (and bellow and above)
|
|
466
486
|
*/
|
|
467
487
|
export type number_percent = number;
|
|
488
|
+
/**
|
|
489
|
+
* Semantic helper;
|
|
490
|
+
* Model temperature
|
|
491
|
+
*/
|
|
492
|
+
export type number_model_temperature = number_percent;
|
|
493
|
+
/**
|
|
494
|
+
* Semantic helper;
|
|
495
|
+
* Seed for random generator
|
|
496
|
+
*
|
|
497
|
+
* Percentage from 0 to 1 (100%)
|
|
498
|
+
* TODO: Is seed (in OpenAI) number from 0 to 1?
|
|
499
|
+
*/
|
|
500
|
+
export type number_seed = number_percent;
|
|
468
501
|
/**
|
|
469
502
|
* Likeness of the wallpaper
|
|
470
503
|
*
|
|
@@ -491,4 +524,5 @@ export type number_terabytes = number_positive;
|
|
|
491
524
|
* TODO: !!! Change "For example" to @example
|
|
492
525
|
* TODO: !! Cleanup
|
|
493
526
|
* TODO: !! Change to branded types
|
|
527
|
+
* TODO: [📂] Export all this file through `@promptbook/types`
|
|
494
528
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,10 @@ import type { string_markdown } from '../../types/typeAliases';
|
|
|
3
3
|
* Single code block inside markdown.
|
|
4
4
|
*/
|
|
5
5
|
export type CodeBlock = {
|
|
6
|
+
/**
|
|
7
|
+
* Which notation was used to open the code block
|
|
8
|
+
*/
|
|
9
|
+
readonly blockNotation: '```' | '>';
|
|
6
10
|
/**
|
|
7
11
|
* Language of the code block OR null if the language is not specified in opening ```
|
|
8
12
|
*/
|
|
@@ -25,3 +29,6 @@ export type CodeBlock = {
|
|
|
25
29
|
*
|
|
26
30
|
*/
|
|
27
31
|
export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): Array<CodeBlock>;
|
|
32
|
+
/**
|
|
33
|
+
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
34
|
+
*/
|
|
@@ -15,5 +15,5 @@ import type { CodeBlock } from './extractAllBlocksFromMarkdown';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractOneBlockFromMarkdown(markdown: string_markdown): CodeBlock;
|
|
17
17
|
/***
|
|
18
|
-
* TODO: [🍓][🌻]
|
|
18
|
+
* TODO: [🍓][🌻] Decide of this is internal util, external util OR validator/postprocessor
|
|
19
19
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { really_any } from './really_any';
|
|
2
|
+
/**
|
|
3
|
+
* Just says that the variable is not used
|
|
4
|
+
* No side effects.
|
|
5
|
+
*
|
|
6
|
+
* Note: It can be usefull suppressing eslint errors of unused variables in the tests
|
|
7
|
+
*
|
|
8
|
+
* @param value any values
|
|
9
|
+
* @returns void
|
|
10
|
+
*/
|
|
11
|
+
export declare function notUsing(...value: Array<really_any>): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-client",
|
|
3
|
-
"version": "0.61.0-
|
|
3
|
+
"version": "0.61.0-11",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.61.0-
|
|
50
|
+
"@promptbook/core": "0.61.0-11"
|
|
51
51
|
},
|
|
52
52
|
"main": "./umd/index.umd.js",
|
|
53
53
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -18,6 +18,22 @@
|
|
|
18
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
if (typeof b !== "function" && b !== null)
|
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33
|
+
extendStatics(d, b);
|
|
34
|
+
function __() { this.constructor = d; }
|
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
36
|
+
}
|
|
21
37
|
|
|
22
38
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
23
39
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -57,6 +73,20 @@
|
|
|
57
73
|
}
|
|
58
74
|
}
|
|
59
75
|
|
|
76
|
+
/**
|
|
77
|
+
* This error indicates errors during the execution of the pipeline
|
|
78
|
+
*/
|
|
79
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
80
|
+
__extends(PipelineExecutionError, _super);
|
|
81
|
+
function PipelineExecutionError(message) {
|
|
82
|
+
var _this = _super.call(this, message) || this;
|
|
83
|
+
_this.name = 'PipelineExecutionError';
|
|
84
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
85
|
+
return _this;
|
|
86
|
+
}
|
|
87
|
+
return PipelineExecutionError;
|
|
88
|
+
}(Error));
|
|
89
|
+
|
|
60
90
|
/**
|
|
61
91
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
62
92
|
*
|
|
@@ -143,15 +173,18 @@
|
|
|
143
173
|
case 0: return [4 /*yield*/, this.makeConnection()];
|
|
144
174
|
case 1:
|
|
145
175
|
socket = _a.sent();
|
|
146
|
-
socket.emit('request', {
|
|
176
|
+
socket.emit('request', {
|
|
177
|
+
clientId: this.options.clientId,
|
|
178
|
+
prompt: prompt,
|
|
179
|
+
// <- TODO: [🛫] `prompt` is NOT fully serializable as JSON, it contains functions which are not serializable
|
|
180
|
+
});
|
|
147
181
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
148
182
|
socket.on('response', function (response) {
|
|
149
183
|
resolve(response.promptResult);
|
|
150
184
|
socket.disconnect();
|
|
151
185
|
});
|
|
152
186
|
socket.on('error', function (error) {
|
|
153
|
-
|
|
154
|
-
reject(new Error(error.errorMessage));
|
|
187
|
+
reject(new PipelineExecutionError(error.errorMessage));
|
|
155
188
|
socket.disconnect();
|
|
156
189
|
});
|
|
157
190
|
})];
|
|
@@ -185,7 +218,7 @@
|
|
|
185
218
|
/**
|
|
186
219
|
* The version of the Promptbook library
|
|
187
220
|
*/
|
|
188
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
221
|
+
var PROMPTBOOK_VERSION = '0.61.0-10';
|
|
189
222
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
190
223
|
|
|
191
224
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|