@promptbook/openai 0.71.0-0 → 0.72.0-0
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 +6 -5
- package/esm/index.es.js +244 -20
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +5 -11
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -12
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +2 -3
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -16
- package/esm/typings/src/config.d.ts +1 -14
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +0 -3
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -2
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +0 -5
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +8 -9
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +72 -0
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +0 -2
- package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +4 -3
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +15 -14
- package/esm/typings/src/formats/csv/{CsvFormatDefinition.d.ts → ListFormatDefinition.d.ts} +3 -6
- package/esm/typings/src/formats/index.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +3 -4
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +16 -0
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +3 -4
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +2 -9
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -1
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +0 -5
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
- package/esm/typings/src/utils/expectation-counters/index.d.ts +0 -3
- package/esm/typings/src/utils/{parameters/extractParameterNames.d.ts → extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/organization/{empty_object.d.ts → f.d.ts} +1 -5
- package/esm/typings/src/utils/{parameters/replaceParameters.d.ts → replaceParameters.d.ts} +2 -2
- package/package.json +13 -17
- package/umd/index.umd.js +244 -19
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +0 -23
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +0 -45
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +0 -20
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -40
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -10
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +0 -55
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +0 -62
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatCells.d.ts +0 -19
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +0 -74
- package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +0 -34
- package/esm/typings/src/execution/createPipelineExecutor/getContextForTemplate.d.ts +0 -10
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
- package/esm/typings/src/execution/createPipelineExecutor/getSamplesForTemplate.d.ts +0 -10
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +0 -30
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +0 -13
- package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +0 -19
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +0 -12
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +0 -27
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +0 -10
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.test.d.ts +0 -1
- /package/esm/typings/src/{utils/parameters/extractParameterNames.test.d.ts → execution/utils/usageToHuman.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{parameters/mapAvailableToExpectedParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{parameters/replaceParameters.test.d.ts → replaceParameters.test.d.ts} +0 -0
|
@@ -7,10 +7,11 @@ import type { PromptResultUsage } from '../PromptResultUsage';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function usageToHuman(usage: PromptResultUsage): string_markdown;
|
|
9
9
|
/**
|
|
10
|
-
* TODO:
|
|
11
|
-
* TODO:
|
|
12
|
-
* TODO:
|
|
10
|
+
* TODO: Use "$1" not "1 USD"
|
|
11
|
+
* TODO: Use markdown formatting like "Cost approximately **$1**"
|
|
12
|
+
* TODO: Report in minutes, seconds, days NOT 0.1 hours
|
|
13
13
|
* TODO: [🧠] Maybe make from `uncertainNumberToHuman` separate exported utility
|
|
14
|
+
* TODO: When negligible usage, report "Negligible" or just don't report it
|
|
14
15
|
* TODO: [🧠] Maybe use "~" instead of "approximately"
|
|
15
16
|
* TODO: [🏛] Maybe make some markdown builder
|
|
16
17
|
*/
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import type { string_mime_type } from '../../types/typeAliases';
|
|
2
2
|
import type { string_name } from '../../types/typeAliases';
|
|
3
|
-
import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
4
|
-
import type { empty_object } from '../../utils/organization/empty_object';
|
|
5
|
-
import type { FormatSubvalueDefinition } from './FormatSubvalueDefinition';
|
|
6
3
|
/**
|
|
7
4
|
* A format definition is a set of functions that define how to validate, heal and convert response from LLM
|
|
8
5
|
*
|
|
9
|
-
* @@@ Describe setting vs schema
|
|
10
|
-
*
|
|
11
6
|
* @see https://github.com/webgptorg/promptbook/discussions/36
|
|
12
7
|
* @private still in development [🏢]
|
|
13
8
|
*/
|
|
14
|
-
export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string,
|
|
9
|
+
export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSchema extends object> = {
|
|
15
10
|
/**
|
|
16
11
|
* The name of the format used in .ptbk.md files
|
|
17
12
|
*
|
|
18
13
|
* @sample "JSON"
|
|
19
14
|
*/
|
|
20
|
-
readonly
|
|
15
|
+
readonly name: string_name;
|
|
21
16
|
/**
|
|
22
|
-
* Aliases for the
|
|
17
|
+
* Aliases for the name
|
|
23
18
|
*/
|
|
24
|
-
readonly aliases?: Array<string_name
|
|
19
|
+
readonly aliases?: Array<string_name>;
|
|
25
20
|
/**
|
|
26
21
|
* The mime type of the format (if any)
|
|
27
22
|
*
|
|
@@ -34,7 +29,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
34
29
|
* @param value The value to check, for example "{\"foo\": true}"
|
|
35
30
|
* @param schema Optional schema to do extra validation
|
|
36
31
|
*/
|
|
37
|
-
isValid(value: string,
|
|
32
|
+
isValid(value: string, schema?: TSchema): value is TValue;
|
|
38
33
|
/**
|
|
39
34
|
* Check if a first part of a value is valid
|
|
40
35
|
*
|
|
@@ -43,7 +38,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
43
38
|
* @param partialValue Partial value to check, for example "{\"foo\": t"
|
|
44
39
|
* @param schema Optional schema to do extra validation
|
|
45
40
|
*/
|
|
46
|
-
canBeValid(partialValue: string,
|
|
41
|
+
canBeValid(partialValue: string, schema?: TSchema): partialValue is TPartialValue;
|
|
47
42
|
/**
|
|
48
43
|
* Heal a value to make it valid if possible
|
|
49
44
|
*
|
|
@@ -54,11 +49,17 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
|
|
|
54
49
|
* @param scheme
|
|
55
50
|
* @throws {Error} If the value cannot be healed
|
|
56
51
|
*/
|
|
57
|
-
heal(value: string,
|
|
52
|
+
heal(value: string, scheme?: TSchema): TValue;
|
|
58
53
|
/**
|
|
59
|
-
*
|
|
54
|
+
* Parses just the values and removes structural information
|
|
55
|
+
*
|
|
56
|
+
* Note: This is useful when you want to combine format expectations with counting words, characters,...
|
|
57
|
+
*
|
|
58
|
+
* @param value The value to check, for example "{\"name\": "John Smith"}"
|
|
59
|
+
* @param schema Optional schema
|
|
60
|
+
* @example "{\"name\": "John Smith"}" -> ["John Smith"]
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
extractValues(value: string, schema?: TSchema): Array<string>;
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
65
|
* TODO: [♏] Add some prepare hook to modify prompt according to the format
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
|
-
import type { CsvSettings } from './CsvSettings';
|
|
4
2
|
/**
|
|
5
3
|
* Definition for CSV spreadsheet
|
|
6
4
|
*
|
|
7
|
-
* @
|
|
8
|
-
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
5
|
+
* @private still in development [🏢]
|
|
9
6
|
*/
|
|
10
|
-
export declare const CsvFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const CsvFormatDefinition: FormatDefinition<string, string, object>;
|
|
11
8
|
/**
|
|
12
9
|
* TODO: [🍓] In `CsvFormatDefinition` implement simple `isValid`
|
|
13
10
|
* TODO: [🍓] In `CsvFormatDefinition` implement partial `canBeValid`
|
|
14
11
|
* TODO: [🍓] In `CsvFormatDefinition` implement `heal
|
|
15
|
-
* TODO: [🍓] In `CsvFormatDefinition` implement `
|
|
12
|
+
* TODO: [🍓] In `CsvFormatDefinition` implement `extractValues`
|
|
16
13
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
17
14
|
*/
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @private internal index of `...` <- TODO [🏢]
|
|
5
5
|
*/
|
|
6
|
-
export declare const FORMAT_DEFINITIONS:
|
|
6
|
+
export declare const FORMAT_DEFINITIONS: import("./_common/FormatDefinition").FormatDefinition<string, string, object>[];
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
2
|
/**
|
|
4
3
|
* Definition for JSON format
|
|
5
4
|
*
|
|
6
5
|
* @private still in development [🏢]
|
|
7
6
|
*/
|
|
8
|
-
export declare const JsonFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const JsonFormatDefinition: FormatDefinition<string, string, object>;
|
|
9
8
|
/**
|
|
10
9
|
* TODO: [🧠] Maybe propper instance of object
|
|
11
10
|
* TODO: [0] Make string_serialized_json
|
|
12
|
-
* TODO: [1] Make type for JSON
|
|
11
|
+
* TODO: [1] Make type for JSON Schema
|
|
13
12
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
14
13
|
* TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
|
|
15
14
|
* TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
|
|
16
15
|
* TODO: [🍓] In `JsonFormatDefinition` implement `heal
|
|
17
|
-
* TODO: [🍓] In `JsonFormatDefinition` implement `
|
|
16
|
+
* TODO: [🍓] In `JsonFormatDefinition` implement `extractValues`
|
|
18
17
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
19
18
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Definition for list of multiple items
|
|
4
|
+
*
|
|
5
|
+
* Note: list is just a string with multiple lines or multiple items separated by comma
|
|
6
|
+
*
|
|
7
|
+
* @private still in development [🏢]
|
|
8
|
+
*/
|
|
9
|
+
export declare const ListFormatDefinition: FormatDefinition<string, string, object>;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🍓] In `ListFormatDefinition` implement simple `isValid`
|
|
12
|
+
* TODO: [🍓] In `ListFormatDefinition` implement partial `canBeValid`
|
|
13
|
+
* TODO: [🍓] In `ListFormatDefinition` implement `heal
|
|
14
|
+
* TODO: [🍓] In `ListFormatDefinition` implement `extractValues`
|
|
15
|
+
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
16
|
+
*/
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
1
|
import type { FormatDefinition } from '../_common/FormatDefinition';
|
|
3
2
|
/**
|
|
4
3
|
* Definition for XML format
|
|
5
4
|
*
|
|
6
5
|
* @private still in development [🏢]
|
|
7
6
|
*/
|
|
8
|
-
export declare const XmlFormatDefinition: FormatDefinition<string, string,
|
|
7
|
+
export declare const XmlFormatDefinition: FormatDefinition<string, string, object>;
|
|
9
8
|
/**
|
|
10
9
|
* TODO: [🧠] Maybe propper instance of object
|
|
11
10
|
* TODO: [0] Make string_serialized_xml
|
|
12
|
-
* TODO: [1] Make type for XML
|
|
11
|
+
* TODO: [1] Make type for XML Schema
|
|
13
12
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
14
13
|
* TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
|
|
15
14
|
* TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
|
|
16
15
|
* TODO: [🍓] In `XmlFormatDefinition` implement `heal
|
|
17
|
-
* TODO: [🍓] In `XmlFormatDefinition` implement `
|
|
16
|
+
* TODO: [🍓] In `XmlFormatDefinition` implement `extractValues`
|
|
18
17
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
19
18
|
*/
|
|
@@ -8,7 +8,7 @@ import type { CallbackInterfaceToolsOptions } from './CallbackInterfaceToolsOpti
|
|
|
8
8
|
* @public exported from `@promptbook/core`
|
|
9
9
|
*/
|
|
10
10
|
export declare class CallbackInterfaceTools implements UserInterfaceTools {
|
|
11
|
-
|
|
11
|
+
protected readonly options: CallbackInterfaceToolsOptions;
|
|
12
12
|
constructor(options: CallbackInterfaceToolsOptions);
|
|
13
13
|
/**
|
|
14
14
|
* Trigger the custom callback function
|
|
@@ -10,7 +10,7 @@ import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/U
|
|
|
10
10
|
* @public exported from `@promptbook/browser`
|
|
11
11
|
*/
|
|
12
12
|
export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
|
|
13
|
-
|
|
13
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
14
14
|
constructor(options?: CommonExecutionToolsOptions);
|
|
15
15
|
/**
|
|
16
16
|
* Trigger window.DIALOG TEMPLATE
|
|
@@ -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';
|
|
@@ -13,7 +14,7 @@ import type { AnthropicClaudeExecutionToolsDirectOptions } from './AnthropicClau
|
|
|
13
14
|
* @deprecated use `createAnthropicClaudeExecutionTools` instead
|
|
14
15
|
*/
|
|
15
16
|
export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
17
|
+
protected readonly options: AnthropicClaudeExecutionToolsDirectOptions;
|
|
17
18
|
/**
|
|
18
19
|
* Anthropic Claude API client.
|
|
19
20
|
*/
|
|
@@ -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
|
*/
|
|
@@ -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';
|
|
@@ -13,7 +14,7 @@ import type { AzureOpenAiExecutionToolsOptions } from './AzureOpenAiExecutionToo
|
|
|
13
14
|
* @public exported from `@promptbook/azure-openai`
|
|
14
15
|
*/
|
|
15
16
|
export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
17
|
+
protected readonly options: AzureOpenAiExecutionToolsOptions;
|
|
17
18
|
/**
|
|
18
19
|
* OpenAI Azure API client.
|
|
19
20
|
*/
|
|
@@ -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
|
*/
|
|
@@ -13,7 +13,7 @@ import type { string_title } from '../../types/typeAliases';
|
|
|
13
13
|
* @public exported from `@promptbook/fake-llm`
|
|
14
14
|
*/
|
|
15
15
|
export declare class MockedEchoLlmExecutionTools implements LlmExecutionTools {
|
|
16
|
-
|
|
16
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
17
17
|
constructor(options?: CommonExecutionToolsOptions);
|
|
18
18
|
get title(): string_title & string_markdown_text;
|
|
19
19
|
get description(): string_markdown;
|
|
@@ -14,7 +14,7 @@ import type { string_title } from '../../types/typeAliases';
|
|
|
14
14
|
* @public exported from `@promptbook/fake-llm`
|
|
15
15
|
*/
|
|
16
16
|
export declare class MockedFackedLlmExecutionTools implements LlmExecutionTools {
|
|
17
|
-
|
|
17
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
18
18
|
constructor(options?: CommonExecutionToolsOptions);
|
|
19
19
|
get title(): string_title & string_markdown_text;
|
|
20
20
|
get description(): string_markdown;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
2
|
+
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
3
|
+
import type { Prompt } from '../../types/Prompt';
|
|
4
|
+
import type { string_markdown } from '../../types/typeAliases';
|
|
5
|
+
import type { string_markdown_text } from '../../types/typeAliases';
|
|
6
|
+
import type { string_title } from '../../types/typeAliases';
|
|
7
|
+
import type { OpenAiAssistantExecutionToolsOptions } from './OpenAiAssistantExecutionToolsOptions';
|
|
8
|
+
import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
9
|
+
/**
|
|
10
|
+
* Execution Tools for calling OpenAI API Assistants
|
|
11
|
+
*
|
|
12
|
+
* This is usefull for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
13
|
+
*
|
|
14
|
+
* @public exported from `@promptbook/openai`
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
|
|
17
|
+
private readonly assistantId?;
|
|
18
|
+
/**
|
|
19
|
+
* Creates OpenAI Execution Tools.
|
|
20
|
+
*
|
|
21
|
+
* @param options which are relevant are directly passed to the OpenAI client
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: OpenAiAssistantExecutionToolsOptions);
|
|
24
|
+
get title(): string_title & string_markdown_text;
|
|
25
|
+
get description(): string_markdown;
|
|
26
|
+
/**
|
|
27
|
+
* Calls OpenAI API to use a chat model.
|
|
28
|
+
*/
|
|
29
|
+
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* TODO: !!!!!! DO not use colors - can be used in browser
|
|
33
|
+
* TODO: [🧠][🧙♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
34
|
+
* TODO: Maybe make custom OpenAiError
|
|
35
|
+
* TODO: [🧠][🈁] Maybe use `isDeterministic` from options
|
|
36
|
+
* TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
|
|
37
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClientOptions } from 'openai';
|
|
2
|
+
import type { string_token } from '../../types/typeAliases';
|
|
3
|
+
import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Options for `OpenAiAssistantExecutionTools`
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/openai`
|
|
8
|
+
*/
|
|
9
|
+
export type OpenAiAssistantExecutionToolsOptions = OpenAiExecutionToolsOptions & ClientOptions & {
|
|
10
|
+
/**
|
|
11
|
+
* Which assistant to use
|
|
12
|
+
*/
|
|
13
|
+
assistantId?: string_token;
|
|
14
|
+
};
|
|
@@ -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';
|
|
@@ -14,7 +15,7 @@ import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions'
|
|
|
14
15
|
* @public exported from `@promptbook/openai`
|
|
15
16
|
*/
|
|
16
17
|
export declare class OpenAiExecutionTools implements LlmExecutionTools {
|
|
17
|
-
|
|
18
|
+
protected readonly options: OpenAiExecutionToolsOptions;
|
|
18
19
|
/**
|
|
19
20
|
* OpenAI API client.
|
|
20
21
|
*/
|
|
@@ -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
|
*/
|
|
@@ -20,7 +20,7 @@ import type { RemoteLlmExecutionToolsOptions } from './interfaces/RemoteLlmExecu
|
|
|
20
20
|
* @public exported from `@promptbook/remote-client`
|
|
21
21
|
*/
|
|
22
22
|
export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
|
|
23
|
-
|
|
23
|
+
protected readonly options: RemoteLlmExecutionToolsOptions;
|
|
24
24
|
constructor(options: RemoteLlmExecutionToolsOptions);
|
|
25
25
|
get title(): string_title & string_markdown_text;
|
|
26
26
|
get description(): string_markdown;
|
|
@@ -9,7 +9,7 @@ import type { JavascriptExecutionToolsOptions } from './JavascriptExecutionTools
|
|
|
9
9
|
* @public exported from `@promptbook/execute-javascript`
|
|
10
10
|
*/
|
|
11
11
|
export declare class JavascriptEvalExecutionTools implements ScriptExecutionTools {
|
|
12
|
-
|
|
12
|
+
protected readonly options: JavascriptExecutionToolsOptions;
|
|
13
13
|
constructor(options?: JavascriptExecutionToolsOptions);
|
|
14
14
|
/**
|
|
15
15
|
* Executes a JavaScript
|
|
@@ -9,7 +9,7 @@ import type { ScriptExecutionToolsExecuteOptions } from '../../execution/ScriptE
|
|
|
9
9
|
* @private still in development
|
|
10
10
|
*/
|
|
11
11
|
export declare class PythonExecutionTools implements ScriptExecutionTools {
|
|
12
|
-
|
|
12
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
13
13
|
constructor(options?: CommonExecutionToolsOptions);
|
|
14
14
|
/**
|
|
15
15
|
* Executes a Python
|
|
@@ -9,7 +9,7 @@ import type { ScriptExecutionToolsExecuteOptions } from '../../execution/ScriptE
|
|
|
9
9
|
* @private still in development
|
|
10
10
|
*/
|
|
11
11
|
export declare class TypescriptExecutionTools implements ScriptExecutionTools {
|
|
12
|
-
|
|
12
|
+
protected readonly options: CommonExecutionToolsOptions;
|
|
13
13
|
constructor(options?: CommonExecutionToolsOptions);
|
|
14
14
|
/**
|
|
15
15
|
* Executes a TypeScript
|
|
@@ -6,7 +6,7 @@ import type { FilesStorageOptions } from './FilesStorageOptions';
|
|
|
6
6
|
* @public exported from `@promptbook/node`
|
|
7
7
|
*/
|
|
8
8
|
export declare class FilesStorage<TItem> implements PromptbookStorage<TItem> {
|
|
9
|
-
|
|
9
|
+
protected readonly options: FilesStorageOptions;
|
|
10
10
|
constructor(options: FilesStorageOptions);
|
|
11
11
|
/**
|
|
12
12
|
* @@@
|
|
@@ -11,18 +11,11 @@ import type { string_name } from '../typeAliases';
|
|
|
11
11
|
*/
|
|
12
12
|
export type KnowledgeSourceJson = {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* @@@
|
|
15
15
|
*/
|
|
16
16
|
readonly name: string_name;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* It can be a link, a relative path to file or direct text or combination of those
|
|
21
|
-
*
|
|
22
|
-
* For example `"https://pavolhejny.com/"`
|
|
23
|
-
* For example `"./pavol-hejny-cv.pdf"`
|
|
24
|
-
* For example `"Pavol Hejný has web https://pavolhejny.com/"`
|
|
25
|
-
* For example `"Pavol Hejný is web developer and creator of Promptbook and Collboard"`
|
|
18
|
+
* @@@
|
|
26
19
|
*/
|
|
27
20
|
readonly sourceContent: string_knowledge_source_content;
|
|
28
21
|
};
|
|
@@ -33,7 +33,6 @@ export type ParameterJson = {
|
|
|
33
33
|
readonly sampleValues?: Array<string_parameter_value>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
* TODO: [🧠] !!!!!! Should be here registered subparameter from foreach or not?
|
|
37
36
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
38
37
|
* TODO: [🍙] Make some standard order of json properties
|
|
39
38
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ForeachJson } from '../../commands/FOREACH/ForeachJson';
|
|
2
1
|
import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
|
|
3
2
|
import type { TemplateType } from '../../commands/TEMPLATE/TemplateTypes';
|
|
4
3
|
import type { string_javascript } from '../typeAliases';
|
|
@@ -43,10 +42,6 @@ export interface TemplateJsonCommon {
|
|
|
43
42
|
* @see https://github.com/webgptorg/promptbook/discussions/66
|
|
44
43
|
*/
|
|
45
44
|
readonly jokerParameterNames?: Array<string_parameter_name>;
|
|
46
|
-
/**
|
|
47
|
-
* @@@
|
|
48
|
-
*/
|
|
49
|
-
readonly foreach?: ForeachJson;
|
|
50
45
|
/**
|
|
51
46
|
* Type of the execution
|
|
52
47
|
* This determines if the template is send to LLM, user or some scripting evaluation
|
|
@@ -6,6 +6,3 @@ 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
|
-
*/
|
package/esm/typings/src/utils/{parameters/extractParameterNames.d.ts → 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
|
*
|
|
@@ -1,10 +1,6 @@
|
|
|
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
|
-
*
|
|
8
4
|
* @private within the repository
|
|
9
5
|
*/
|
|
10
|
-
export type
|
|
6
|
+
export type really_empty_object = Record<string, never>;
|
|
@@ -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
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0-0",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -12,25 +12,21 @@
|
|
|
12
12
|
"Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
|
|
13
13
|
],
|
|
14
14
|
"keywords": [
|
|
15
|
-
"ai",
|
|
16
|
-
"llm",
|
|
17
|
-
"prompt",
|
|
18
|
-
"template",
|
|
19
|
-
"language-model",
|
|
20
|
-
"chatgpt",
|
|
21
15
|
"autogpt",
|
|
22
|
-
"machine-learning",
|
|
23
|
-
"natural-language-processing",
|
|
24
|
-
"nlp",
|
|
25
16
|
"openai",
|
|
26
17
|
"gpt-3",
|
|
27
18
|
"gpt-4",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
19
|
+
"chatgpt",
|
|
20
|
+
"ai",
|
|
21
|
+
"machine-learning",
|
|
22
|
+
"natural-language-processing",
|
|
23
|
+
"nlp",
|
|
24
|
+
"prompt",
|
|
25
|
+
"template",
|
|
26
|
+
"pipeline",
|
|
27
|
+
"automation",
|
|
28
|
+
"text-generation",
|
|
29
|
+
"language-model"
|
|
34
30
|
],
|
|
35
31
|
"license": "CC-BY-4.0",
|
|
36
32
|
"bugs": {
|
|
@@ -51,7 +47,7 @@
|
|
|
51
47
|
"module": "./esm/index.es.js",
|
|
52
48
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
53
49
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.
|
|
50
|
+
"@promptbook/core": "0.72.0-0"
|
|
55
51
|
},
|
|
56
52
|
"dependencies": {
|
|
57
53
|
"colors": "1.4.0",
|