@promptbook/openai 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 +4 -1
- 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 +4 -1
- 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
|
@@ -41,10 +41,12 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
|
|
|
41
41
|
private callModelCommon;
|
|
42
42
|
/**
|
|
43
43
|
* List all available models that can be used
|
|
44
|
-
* This
|
|
44
|
+
* This lists is a combination of all available models from all execution tools
|
|
45
45
|
*/
|
|
46
46
|
listModels(): Promise<Array<AvailableModel>>;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first aviable model BUT all of them
|
|
50
|
+
* TODO: [🏖] If no llmTools have for example not defined `callCompletionModel` this will still return object with defined `callCompletionModel` which just throws `PipelineExecutionError`, make it undefined instead
|
|
51
|
+
* Look how `countTotalUsage` (and `cacheLlmTools`) implements it
|
|
50
52
|
*/
|
|
@@ -24,4 +24,5 @@ export declare const OPENAI_MODELS: Array<AvailableModel & {
|
|
|
24
24
|
* @see /other/playground/playground.ts
|
|
25
25
|
* TODO: [🍓] Make better
|
|
26
26
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
27
|
+
* TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
|
|
27
28
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PromptResult } from '../../../execution/PromptResult';
|
|
2
|
+
import type { Prompt } from '../../../types/Prompt';
|
|
3
|
+
import type { string_date_iso8601 } from '../../../types/typeAliases';
|
|
4
|
+
import type { string_promptbook_version } from '../../../version';
|
|
5
|
+
/**
|
|
6
|
+
* @@@
|
|
7
|
+
*/
|
|
8
|
+
export type CacheItem = {
|
|
9
|
+
/**
|
|
10
|
+
* @@@
|
|
11
|
+
*/
|
|
12
|
+
date: string_date_iso8601;
|
|
13
|
+
/**
|
|
14
|
+
* @@@
|
|
15
|
+
*/
|
|
16
|
+
promptbookVersion: string_promptbook_version;
|
|
17
|
+
/**
|
|
18
|
+
* @@@
|
|
19
|
+
*/
|
|
20
|
+
prompt: Prompt;
|
|
21
|
+
/**
|
|
22
|
+
* @@@
|
|
23
|
+
*/
|
|
24
|
+
promptResult: PromptResult;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* TODO: [🧠] Should be this exported alongsite `cacheLlmTools` through `@promptbook/utils` OR through `@promptbook/types`
|
|
28
|
+
* TODO: [🛫] `prompt` is NOT fully serializable as JSON, it contains functions which are not serializable, fix it
|
|
29
|
+
*/
|
|
@@ -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/openai",
|
|
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,
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@promptbook/core": "0.61.0-
|
|
52
|
+
"@promptbook/core": "0.61.0-11"
|
|
53
53
|
},
|
|
54
54
|
"main": "./umd/index.umd.js",
|
|
55
55
|
"module": "./esm/index.es.js",
|