@promptbook/openai 0.69.0-8 → 0.69.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.
- package/README.md +4 -1
- package/esm/index.es.js +88 -10
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +0 -3
- package/esm/typings/src/_packages/core.index.d.ts +12 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -5
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -2
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +11 -4
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +6 -5
- package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +5 -6
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +24 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +7 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +4 -1
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/{30-executeFormatCells.d.ts → 30-executeFormatSubvalues.d.ts} +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +2 -8
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +1 -1
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +2 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +3 -4
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +14 -15
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +31 -0
- package/esm/typings/src/formats/csv/{ListFormatDefinition.d.ts → CsvFormatDefinition.d.ts} +6 -3
- package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +13 -0
- package/esm/typings/src/formats/index.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +4 -3
- package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +19 -0
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +4 -3
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +8 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -0
- package/esm/typings/src/utils/organization/{f.d.ts → empty_object.d.ts} +5 -1
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +12 -0
- package/esm/typings/src/utils/{extractParameterNames.d.ts → parameters/extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +27 -0
- package/esm/typings/src/utils/{replaceParameters.d.ts → parameters/replaceParameters.d.ts} +2 -2
- package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +10 -0
- package/package.json +17 -13
- package/umd/index.umd.js +88 -10
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +0 -16
- /package/esm/typings/src/utils/{extractParameterNames.test.d.ts → parameters/extractParameterNames.test.d.ts} +0 -0
- /package/esm/typings/src/{execution/utils/usageToHuman.test.d.ts → utils/parameters/mapAvailableToExpectedParameters.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{replaceParameters.test.d.ts → parameters/replaceParameters.test.d.ts} +0 -0
- /package/esm/typings/src/{personas/preparePersona.test.d.ts → utils/validators/parameterName/validateParameterName.test.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
1
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
@@ -26,7 +27,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
|
|
|
26
27
|
constructor(options?: AnthropicClaudeExecutionToolsDirectOptions);
|
|
27
28
|
get title(): string_title & string_markdown_text;
|
|
28
29
|
get description(): string_markdown;
|
|
29
|
-
|
|
30
|
+
getClient(): Promise<Anthropic>;
|
|
30
31
|
/**
|
|
31
32
|
* Check the `options` passed to `constructor`
|
|
32
33
|
*/
|
|
@@ -16,7 +16,7 @@ export declare const ANTHROPIC_CLAUDE_MODELS: Array<AvailableModel & {
|
|
|
16
16
|
}>;
|
|
17
17
|
/**
|
|
18
18
|
* Note: [🤖] Add models of new variant
|
|
19
|
-
* TODO: [🧠] !!! Add embedding models OR Anthropic has only chat+completion models?
|
|
19
|
+
* TODO: [🧠][main] !!! Add embedding models OR Anthropic has only chat+completion models?
|
|
20
20
|
* TODO: [🧠] Some mechanism to propagate unsureness
|
|
21
21
|
* TODO: [🧠][👮♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
|
|
22
22
|
* TODO: [🎰] Some mechanism to auto-update available models
|
package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare const createAnthropicClaudeExecutionTools: ((options: AnthropicCl
|
|
|
11
11
|
className: string;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* TODO: [🧠] !!!! Make anonymous this with all LLM providers
|
|
15
|
-
* TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
14
|
+
* TODO: [🧠][main] !!!! Make anonymous this with all LLM providers
|
|
15
|
+
* TODO: [🧠][🧱][main] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
|
|
16
16
|
* TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
|
|
17
17
|
* TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
18
18
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
2
|
export {};
|
|
3
3
|
/**
|
|
4
|
-
* TODO: !!! Playground with WebGPT / Promptbook.studio anonymous server
|
|
5
|
-
* TODO: !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
|
|
4
|
+
* TODO: [main] !!! Playground with WebGPT / Promptbook.studio anonymous server
|
|
5
|
+
* TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
|
|
6
6
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OpenAIClient } from '@azure/openai';
|
|
1
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
@@ -26,7 +27,7 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
|
26
27
|
constructor(options: AzureOpenAiExecutionToolsOptions);
|
|
27
28
|
get title(): string_title & string_markdown_text;
|
|
28
29
|
get description(): string_markdown;
|
|
29
|
-
|
|
30
|
+
getClient(): Promise<OpenAIClient>;
|
|
30
31
|
/**
|
|
31
32
|
* Check the `options` passed to `constructor`
|
|
32
33
|
*/
|
|
@@ -43,6 +44,12 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
|
43
44
|
* Calls Azure OpenAI API to use a complete model.
|
|
44
45
|
*/
|
|
45
46
|
callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Library `@azure/openai` has bug/weird behavior that it does not throw error but hangs forever
|
|
49
|
+
*
|
|
50
|
+
* This method wraps the promise with timeout
|
|
51
|
+
*/
|
|
52
|
+
private withTimeout;
|
|
46
53
|
/**
|
|
47
54
|
* Changes Azure error (which is not propper Error but object) to propper Error
|
|
48
55
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
1
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
@@ -27,7 +28,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
|
27
28
|
constructor(options?: OpenAiExecutionToolsOptions);
|
|
28
29
|
get title(): string_title & string_markdown_text;
|
|
29
30
|
get description(): string_markdown;
|
|
30
|
-
|
|
31
|
+
getClient(): Promise<OpenAI>;
|
|
31
32
|
/**
|
|
32
33
|
* Check the `options` passed to `constructor`
|
|
33
34
|
*/
|
|
@@ -9,7 +9,7 @@ import type { string_persona_description } from '../types/typeAliases';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
|
|
11
11
|
/**
|
|
12
|
-
* TODO: [🔃] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
|
|
12
|
+
* TODO: [🔃][main] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
|
|
13
13
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
14
14
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
15
15
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -6,7 +6,7 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* TODO: [🔃] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
9
|
+
* TODO: [🔃][main] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
10
10
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
11
11
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
12
12
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -23,7 +23,7 @@ export {};
|
|
|
23
23
|
/**
|
|
24
24
|
* TODO: [🧠] Add context to each template (if missing)
|
|
25
25
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
26
|
-
* TODO: [♨] !!! Prepare index the samples and maybe templates
|
|
26
|
+
* TODO: [♨][main] !!! Prepare index the samples and maybe templates
|
|
27
27
|
* TODO: Write tests for `preparePipeline`
|
|
28
28
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
29
29
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -33,7 +33,7 @@ export type ParameterJson = {
|
|
|
33
33
|
readonly sampleValues?: Array<string_parameter_value>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
* TODO: [🧠]
|
|
36
|
+
* TODO: [🧠] Should be here registered subparameters from foreach or not?
|
|
37
37
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
38
38
|
* TODO: [🍙] Make some standard order of json properties
|
|
39
39
|
*/
|
|
@@ -42,7 +42,7 @@ export type PipelineJson = {
|
|
|
42
42
|
/**
|
|
43
43
|
* Version of the .ptbk.json file
|
|
44
44
|
*/
|
|
45
|
-
readonly promptbookVersion
|
|
45
|
+
readonly promptbookVersion?: string_semantic_version;
|
|
46
46
|
/**
|
|
47
47
|
* Description of the promptbook
|
|
48
48
|
* It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
1
2
|
import type { ExecutionReportJson } from './ExecutionReportJson';
|
|
2
3
|
import type { ExecutionReportString } from './ExecutionReportString';
|
|
3
4
|
import type { ExecutionReportStringOptions } from './ExecutionReportStringOptions';
|
|
@@ -6,7 +7,7 @@ import type { ExecutionReportStringOptions } from './ExecutionReportStringOption
|
|
|
6
7
|
*
|
|
7
8
|
* @public exported from `@promptbook/core`
|
|
8
9
|
*/
|
|
9
|
-
export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson
|
|
10
|
+
export declare function executionReportJsonToString(executionReportJson: ReadonlyDeep<ExecutionReportJson>, options?: Partial<ExecutionReportStringOptions>): ExecutionReportString;
|
|
10
11
|
/**
|
|
11
12
|
* TODO: Add mermaid chart for every report
|
|
12
13
|
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
@@ -592,7 +592,7 @@ export type number_megabytes = number_positive;
|
|
|
592
592
|
export type number_gigabytes = number_positive;
|
|
593
593
|
export type number_terabytes = number_positive;
|
|
594
594
|
/**.
|
|
595
|
-
* TODO: !!! Change "For example" to @example
|
|
595
|
+
* TODO: [main] !!! Change "For example" to @example
|
|
596
596
|
* TODO: !! Change to branded types
|
|
597
597
|
* TODO: Delete type aliases that are not exported or used internally
|
|
598
598
|
*/
|
|
@@ -6,3 +6,6 @@ import type { ExpectationUnit } from '../../types/PipelineJson/Expectations';
|
|
|
6
6
|
* @public exported from `@promptbook/utils`
|
|
7
7
|
*/
|
|
8
8
|
export declare const CountUtils: Record<ExpectationUnit, (text: string) => ExpectationAmount>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
|
|
11
|
+
*/
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Organizational helper to better mark the place where to really use empty object `{}`
|
|
3
3
|
*
|
|
4
|
+
* Note: There are 2 similar types>
|
|
5
|
+
* - `empty_object` @@@
|
|
6
|
+
* - `just_empty_object` @@@
|
|
7
|
+
*
|
|
4
8
|
* @private within the repository
|
|
5
9
|
*/
|
|
6
|
-
export type
|
|
10
|
+
export type empty_object = {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organizational helper to better @@@@
|
|
3
|
+
*
|
|
4
|
+
* Note: There are 2 similar types>
|
|
5
|
+
* - `empty_object` @@@
|
|
6
|
+
* - `just_empty_object` @@@
|
|
7
|
+
*
|
|
8
|
+
* Note: In most cases, you should use `empty_object`
|
|
9
|
+
*
|
|
10
|
+
* @private within the repository
|
|
11
|
+
*/
|
|
12
|
+
export type just_empty_object = Record<string, never>;
|
package/esm/typings/src/utils/{extractParameterNames.d.ts → parameters/extractParameterNames.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { string_parameter_name } from '
|
|
2
|
-
import type { string_template } from '
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
|
+
import type { string_template } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
4
|
* Parses the template and returns the list of all parameter names
|
|
5
5
|
*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
|
+
import type { string_parameter_value } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*/
|
|
6
|
+
type MakeapAvailableToExpectedParametersOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* @@@
|
|
9
|
+
*/
|
|
10
|
+
readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
|
|
11
|
+
/**
|
|
12
|
+
* @@@
|
|
13
|
+
*/
|
|
14
|
+
readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Maps available parameters to expected parameters
|
|
18
|
+
*
|
|
19
|
+
* The strategy is:
|
|
20
|
+
* 1) @@@
|
|
21
|
+
* 2) @@@
|
|
22
|
+
*
|
|
23
|
+
* @throws {PipelineExecutionError} @@@
|
|
24
|
+
* @private within the repository used in `createPipelineExecutor`
|
|
25
|
+
*/
|
|
26
|
+
export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
27
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Parameters } from '
|
|
2
|
-
import type { string_template } from '
|
|
1
|
+
import type { Parameters } from '../../types/typeAliases';
|
|
2
|
+
import type { string_template } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
4
|
* Replaces parameters in template with values from parameters object
|
|
5
5
|
*
|
|
@@ -22,6 +22,6 @@ import type { string_name } from '../../types/typeAliases';
|
|
|
22
22
|
export declare function checkSerializableAsJson(name: string_name, value: unknown): void;
|
|
23
23
|
/**
|
|
24
24
|
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
25
|
-
* TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
|
|
25
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
26
26
|
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
27
27
|
*/
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function isSerializableAsJson(value: unknown): boolean;
|
|
21
21
|
/**
|
|
22
|
-
* TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
|
|
22
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
23
23
|
* TODO: [🧠][💺] Can be done this on type-level?
|
|
24
24
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { string_parameter_name } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Function `validateParameterName` will @@@
|
|
4
|
+
*
|
|
5
|
+
* @param parameterName @@@
|
|
6
|
+
* @returns @@@
|
|
7
|
+
* @throws {ParseError} @@@
|
|
8
|
+
* @private within the repository
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateParameterName(parameterName: string): string_parameter_name;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.69.
|
|
3
|
+
"version": "0.69.1",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -12,21 +12,25 @@
|
|
|
12
12
|
"Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
|
|
13
13
|
],
|
|
14
14
|
"keywords": [
|
|
15
|
-
"autogpt",
|
|
16
|
-
"openai",
|
|
17
|
-
"gpt-3",
|
|
18
|
-
"gpt-4",
|
|
19
|
-
"chatgpt",
|
|
20
15
|
"ai",
|
|
16
|
+
"llm",
|
|
17
|
+
"prompt",
|
|
18
|
+
"template",
|
|
19
|
+
"language-model",
|
|
20
|
+
"chatgpt",
|
|
21
|
+
"autogpt",
|
|
21
22
|
"machine-learning",
|
|
22
23
|
"natural-language-processing",
|
|
23
24
|
"nlp",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
25
|
+
"openai",
|
|
26
|
+
"gpt-3",
|
|
27
|
+
"gpt-4",
|
|
28
|
+
"gpt-4o",
|
|
29
|
+
"gpt-4o-mini",
|
|
30
|
+
"o1",
|
|
31
|
+
"o1-mini",
|
|
32
|
+
"o1-preview",
|
|
33
|
+
"anthropic"
|
|
30
34
|
],
|
|
31
35
|
"license": "CC-BY-4.0",
|
|
32
36
|
"bugs": {
|
|
@@ -47,7 +51,7 @@
|
|
|
47
51
|
"module": "./esm/index.es.js",
|
|
48
52
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
49
53
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.69.
|
|
54
|
+
"@promptbook/core": "0.69.1"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
57
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Promptbook library
|
|
16
16
|
*/
|
|
17
|
-
var PROMPTBOOK_VERSION = '0.69.0
|
|
18
|
-
// TODO: !!!! List here all the versions and annotate + put into script
|
|
17
|
+
var PROMPTBOOK_VERSION = '0.69.0';
|
|
18
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
19
19
|
|
|
20
20
|
/*! *****************************************************************************
|
|
21
21
|
Copyright (c) Microsoft Corporation.
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
350
|
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
351
|
-
* TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
|
|
351
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
352
352
|
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
353
353
|
*/
|
|
354
354
|
|
|
@@ -413,6 +413,18 @@
|
|
|
413
413
|
* @private within the repository
|
|
414
414
|
*/
|
|
415
415
|
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
416
|
+
// <- TODO: [🧜♂️]
|
|
417
|
+
/**
|
|
418
|
+
* @@@
|
|
419
|
+
*
|
|
420
|
+
* @public exported from `@promptbook/core`
|
|
421
|
+
*/
|
|
422
|
+
Object.freeze({
|
|
423
|
+
delimiter: ',',
|
|
424
|
+
quoteChar: '"',
|
|
425
|
+
newline: '\n',
|
|
426
|
+
skipEmptyLines: true,
|
|
427
|
+
});
|
|
416
428
|
/**
|
|
417
429
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
418
430
|
*/
|
|
@@ -1205,6 +1217,7 @@
|
|
|
1205
1217
|
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
1206
1218
|
output: computeUsage("$15.00 / 1M tokens"),
|
|
1207
1219
|
},
|
|
1220
|
+
//TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
|
|
1208
1221
|
},
|
|
1209
1222
|
/**/
|
|
1210
1223
|
/**/
|
|
@@ -1219,6 +1232,51 @@
|
|
|
1219
1232
|
},
|
|
1220
1233
|
/**/
|
|
1221
1234
|
/**/
|
|
1235
|
+
{
|
|
1236
|
+
modelVariant: 'CHAT',
|
|
1237
|
+
modelTitle: 'o1-preview',
|
|
1238
|
+
modelName: 'o1-preview',
|
|
1239
|
+
pricing: {
|
|
1240
|
+
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
1241
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
1242
|
+
},
|
|
1243
|
+
},
|
|
1244
|
+
/**/
|
|
1245
|
+
/**/
|
|
1246
|
+
{
|
|
1247
|
+
modelVariant: 'CHAT',
|
|
1248
|
+
modelTitle: 'o1-preview-2024-09-12',
|
|
1249
|
+
modelName: 'o1-preview-2024-09-12',
|
|
1250
|
+
// <- TODO: [main] !!! Some better system to organize theese date suffixes and versions
|
|
1251
|
+
pricing: {
|
|
1252
|
+
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
1253
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
1254
|
+
},
|
|
1255
|
+
},
|
|
1256
|
+
/**/
|
|
1257
|
+
/**/
|
|
1258
|
+
{
|
|
1259
|
+
modelVariant: 'CHAT',
|
|
1260
|
+
modelTitle: 'o1-mini',
|
|
1261
|
+
modelName: 'o1-mini',
|
|
1262
|
+
pricing: {
|
|
1263
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
1264
|
+
output: computeUsage("$12.00 / 1M tokens"),
|
|
1265
|
+
},
|
|
1266
|
+
},
|
|
1267
|
+
/**/
|
|
1268
|
+
/**/
|
|
1269
|
+
{
|
|
1270
|
+
modelVariant: 'CHAT',
|
|
1271
|
+
modelTitle: 'o1-mini-2024-09-12',
|
|
1272
|
+
modelName: 'o1-mini-2024-09-12',
|
|
1273
|
+
pricing: {
|
|
1274
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
1275
|
+
output: computeUsage("$12.00 / 1M tokens"),
|
|
1276
|
+
},
|
|
1277
|
+
},
|
|
1278
|
+
/**/
|
|
1279
|
+
/**/
|
|
1222
1280
|
{
|
|
1223
1281
|
modelVariant: 'CHAT',
|
|
1224
1282
|
modelTitle: 'gpt-3.5-turbo-16k-0613',
|
|
@@ -1363,6 +1421,7 @@
|
|
|
1363
1421
|
OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
1364
1422
|
return __awaiter(this, void 0, void 0, function () {
|
|
1365
1423
|
var content, parameters, modelRequirements, format, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1424
|
+
var _this = this;
|
|
1366
1425
|
return __generator(this, function (_a) {
|
|
1367
1426
|
switch (_a.label) {
|
|
1368
1427
|
case 0:
|
|
@@ -1409,7 +1468,12 @@
|
|
|
1409
1468
|
if (this.options.isVerbose) {
|
|
1410
1469
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1411
1470
|
}
|
|
1412
|
-
return [4 /*yield*/, client.chat.completions.create(rawRequest)
|
|
1471
|
+
return [4 /*yield*/, client.chat.completions.create(rawRequest).catch(function (error) {
|
|
1472
|
+
if (_this.options.isVerbose) {
|
|
1473
|
+
console.info(colors__default["default"].bgRed('error'), error);
|
|
1474
|
+
}
|
|
1475
|
+
throw error;
|
|
1476
|
+
})];
|
|
1413
1477
|
case 2:
|
|
1414
1478
|
rawResponse = _a.sent();
|
|
1415
1479
|
if (this.options.isVerbose) {
|
|
@@ -1425,7 +1489,7 @@
|
|
|
1425
1489
|
resultContent = rawResponse.choices[0].message.content;
|
|
1426
1490
|
// eslint-disable-next-line prefer-const
|
|
1427
1491
|
complete = getCurrentIsoDate();
|
|
1428
|
-
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1492
|
+
usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
|
|
1429
1493
|
if (resultContent === null) {
|
|
1430
1494
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
1431
1495
|
}
|
|
@@ -1452,6 +1516,7 @@
|
|
|
1452
1516
|
OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
1453
1517
|
return __awaiter(this, void 0, void 0, function () {
|
|
1454
1518
|
var content, parameters, modelRequirements, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1519
|
+
var _this = this;
|
|
1455
1520
|
return __generator(this, function (_a) {
|
|
1456
1521
|
switch (_a.label) {
|
|
1457
1522
|
case 0:
|
|
@@ -1481,7 +1546,12 @@
|
|
|
1481
1546
|
if (this.options.isVerbose) {
|
|
1482
1547
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1483
1548
|
}
|
|
1484
|
-
return [4 /*yield*/, client.completions.create(rawRequest)
|
|
1549
|
+
return [4 /*yield*/, client.completions.create(rawRequest).catch(function (error) {
|
|
1550
|
+
if (_this.options.isVerbose) {
|
|
1551
|
+
console.info(colors__default["default"].bgRed('error'), error);
|
|
1552
|
+
}
|
|
1553
|
+
throw error;
|
|
1554
|
+
})];
|
|
1485
1555
|
case 2:
|
|
1486
1556
|
rawResponse = _a.sent();
|
|
1487
1557
|
if (this.options.isVerbose) {
|
|
@@ -1497,7 +1567,7 @@
|
|
|
1497
1567
|
resultContent = rawResponse.choices[0].text;
|
|
1498
1568
|
// eslint-disable-next-line prefer-const
|
|
1499
1569
|
complete = getCurrentIsoDate();
|
|
1500
|
-
usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
|
|
1570
|
+
usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
|
|
1501
1571
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools CompletionPromptResult', {
|
|
1502
1572
|
content: resultContent,
|
|
1503
1573
|
modelName: rawResponse.model || modelName,
|
|
@@ -1521,6 +1591,7 @@
|
|
|
1521
1591
|
OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
|
|
1522
1592
|
return __awaiter(this, void 0, void 0, function () {
|
|
1523
1593
|
var content, parameters, modelRequirements, client, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1594
|
+
var _this = this;
|
|
1524
1595
|
return __generator(this, function (_a) {
|
|
1525
1596
|
switch (_a.label) {
|
|
1526
1597
|
case 0:
|
|
@@ -1545,7 +1616,12 @@
|
|
|
1545
1616
|
if (this.options.isVerbose) {
|
|
1546
1617
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
1547
1618
|
}
|
|
1548
|
-
return [4 /*yield*/, client.embeddings.create(rawRequest)
|
|
1619
|
+
return [4 /*yield*/, client.embeddings.create(rawRequest).catch(function (error) {
|
|
1620
|
+
if (_this.options.isVerbose) {
|
|
1621
|
+
console.info(colors__default["default"].bgRed('error'), error);
|
|
1622
|
+
}
|
|
1623
|
+
throw error;
|
|
1624
|
+
})];
|
|
1549
1625
|
case 2:
|
|
1550
1626
|
rawResponse = _a.sent();
|
|
1551
1627
|
if (this.options.isVerbose) {
|
|
@@ -1557,7 +1633,9 @@
|
|
|
1557
1633
|
resultContent = rawResponse.data[0].embedding;
|
|
1558
1634
|
// eslint-disable-next-line prefer-const
|
|
1559
1635
|
complete = getCurrentIsoDate();
|
|
1560
|
-
usage = computeOpenAiUsage(content, '',
|
|
1636
|
+
usage = computeOpenAiUsage(content || '', '',
|
|
1637
|
+
// <- Note: Embedding does not have result content
|
|
1638
|
+
rawResponse);
|
|
1561
1639
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools EmbeddingPromptResult', {
|
|
1562
1640
|
content: resultContent,
|
|
1563
1641
|
modelName: rawResponse.model || modelName,
|
|
@@ -1628,7 +1706,7 @@
|
|
|
1628
1706
|
* @public exported from `@promptbook/openai`
|
|
1629
1707
|
*/
|
|
1630
1708
|
var createOpenAiExecutionTools = Object.assign(function (options) {
|
|
1631
|
-
// TODO: [🧠] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1709
|
+
// TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
|
|
1632
1710
|
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
1633
1711
|
options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
|
|
1634
1712
|
}
|