@promptbook/node 0.77.0-4 → 0.77.0-6
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 +56 -23
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +16 -2
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +6 -3
- package/esm/typings/src/llm-providers/google/GoogleExecutionToolsOptions.d.ts +3 -6
- package/esm/typings/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/src/llm-providers/vercel/createExecutionToolsFromVercelProvider.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +7 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +11 -0
- package/esm/typings/src/utils/serialization/asSerializable.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +56 -23
- package/umd/index.umd.js.map +1 -1
|
@@ -145,6 +145,7 @@ import type { string_reserved_parameter_name } from '../types/typeAliases';
|
|
|
145
145
|
import type { ReservedParameters } from '../types/typeAliases';
|
|
146
146
|
import type { string_title } from '../types/typeAliases';
|
|
147
147
|
import type { string_persona_description } from '../types/typeAliases';
|
|
148
|
+
import type { string_model_description } from '../types/typeAliases';
|
|
148
149
|
import type { string_knowledge_source_content } from '../types/typeAliases';
|
|
149
150
|
import type { string_knowledge_source_link } from '../types/typeAliases';
|
|
150
151
|
import type { string_html } from '../types/typeAliases';
|
|
@@ -402,6 +403,7 @@ export type { string_reserved_parameter_name };
|
|
|
402
403
|
export type { ReservedParameters };
|
|
403
404
|
export type { string_title };
|
|
404
405
|
export type { string_persona_description };
|
|
406
|
+
export type { string_model_description };
|
|
405
407
|
export type { string_knowledge_source_content };
|
|
406
408
|
export type { string_knowledge_source_link };
|
|
407
409
|
export type { string_html };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelVariant } from '../types/ModelVariant';
|
|
2
|
+
import type { string_model_description } from '../types/typeAliases';
|
|
2
3
|
import type { string_model_name } from '../types/typeAliases';
|
|
3
4
|
import type { string_title } from '../types/typeAliases';
|
|
4
5
|
/**
|
|
@@ -6,19 +7,32 @@ import type { string_title } from '../types/typeAliases';
|
|
|
6
7
|
*/
|
|
7
8
|
export type AvailableModel = {
|
|
8
9
|
/**
|
|
9
|
-
* The model title
|
|
10
|
+
* The model title, when not provided, the `modelName` should be used
|
|
11
|
+
*
|
|
12
|
+
* @example "GPT o1"
|
|
10
13
|
*/
|
|
11
14
|
readonly modelTitle?: string_title;
|
|
12
15
|
/**
|
|
13
16
|
* The model name aviailable
|
|
17
|
+
*
|
|
18
|
+
* @example "o1"
|
|
14
19
|
*/
|
|
15
20
|
readonly modelName: string_model_name;
|
|
16
21
|
/**
|
|
17
22
|
* Variant of the model
|
|
23
|
+
*
|
|
24
|
+
* @example "CHAT"
|
|
18
25
|
*/
|
|
19
26
|
readonly modelVariant: ModelVariant;
|
|
27
|
+
/**
|
|
28
|
+
* Unstructured description of the model
|
|
29
|
+
*
|
|
30
|
+
* This will be used to pick the best available model for each task
|
|
31
|
+
*
|
|
32
|
+
* @example "Model with 1 billion parameters and advanced reasoning capabilities"
|
|
33
|
+
*/
|
|
34
|
+
readonly modelDescription?: string_model_description;
|
|
20
35
|
};
|
|
21
36
|
/**
|
|
22
|
-
* TODO: !!!!!! Maybe remove `modelTitle`
|
|
23
37
|
* TODO: !!!!!! Put pricing information here
|
|
24
38
|
*/
|
package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export declare function $provideLlmToolsConfigurationFromEnv(): LlmToolsConfigur
|
|
|
21
21
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
22
22
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
23
23
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
24
|
-
* TODO: [🧠] Maybe pass env as argument
|
|
24
|
+
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
25
25
|
* TODO: [®] DRY Register logic */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
2
1
|
import type { string_name } from '../../../types/typeAliases';
|
|
3
2
|
import type { string_title } from '../../../types/typeAliases';
|
|
4
3
|
import type { Registered } from '../../../utils/$Register';
|
|
4
|
+
import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
5
5
|
import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
|
|
6
6
|
/**
|
|
7
7
|
* @@@
|
|
@@ -14,9 +14,12 @@ export type LlmToolsMetadata = Registered & {
|
|
|
14
14
|
*/
|
|
15
15
|
readonly title: string_title;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* List of environment variables that can be used to configure the provider
|
|
18
|
+
*
|
|
19
|
+
* If `[]`, empty array, it means that the provider is available automatically without any configuration
|
|
20
|
+
* If `null`, it means that the provider can not be configured via environment variables
|
|
18
21
|
*/
|
|
19
|
-
readonly envVariables: ReadonlyArray<string_name & string_SCREAMING_CASE
|
|
22
|
+
readonly envVariables: ReadonlyArray<string_name & string_SCREAMING_CASE> | null;
|
|
20
23
|
/**
|
|
21
24
|
* @@@
|
|
22
25
|
*/
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VercelExecutionToolsOptions } from '../vercel/VercelExecutionToolsOptions';
|
|
3
3
|
/**
|
|
4
4
|
* Options for `GoogleExecutionTools`
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* This combines options for Promptbook, Google and Vercel together
|
|
7
7
|
* @public exported from `@promptbook/google`
|
|
8
8
|
*/
|
|
9
|
-
export type GoogleExecutionToolsOptions =
|
|
10
|
-
/**
|
|
11
|
-
* TODO: [🧠][🤺] Pass `userId`
|
|
12
|
-
*/
|
|
9
|
+
export type GoogleExecutionToolsOptions = Omit<VercelExecutionToolsOptions, 'title' | 'description' | 'vercelProvider' | 'availableModels'> & Parameters<typeof createGoogleGenerativeAI>[0];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
2
2
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
4
|
import type { VercelProvider } from './VercelProvider';
|
|
4
5
|
/**
|
|
5
6
|
* Options for `createExecutionToolsFromVercelProvider`
|
|
6
7
|
*
|
|
7
8
|
* @public exported from `@promptbook/google`
|
|
8
9
|
*/
|
|
9
|
-
export type VercelExecutionToolsOptions = CommonToolsOptions & {
|
|
10
|
+
export type VercelExecutionToolsOptions = CommonToolsOptions & Pick<LlmExecutionTools, 'title' | 'description'> & {
|
|
10
11
|
/**
|
|
11
12
|
* Vercel provider for the execution tools
|
|
12
13
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
2
2
|
import type { VercelExecutionToolsOptions } from './VercelExecutionToolsOptions';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Adapter which creates Promptbook execution tools from Vercel provider
|
|
5
5
|
*
|
|
6
6
|
* @public exported from `@promptbook/vercel`
|
|
7
7
|
*/
|
|
@@ -128,11 +128,17 @@ export type ReservedParameters = Record<string_reserved_parameter_name, string_p
|
|
|
128
128
|
*/
|
|
129
129
|
export type string_title = string;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* Unstructured description of the persona
|
|
132
132
|
*
|
|
133
133
|
* For example `"Skilled copywriter"`
|
|
134
134
|
*/
|
|
135
135
|
export type string_persona_description = string;
|
|
136
|
+
/**
|
|
137
|
+
* Unstructured description of the model
|
|
138
|
+
*
|
|
139
|
+
* For example `"Model with logical reasoning and creative mindset"`
|
|
140
|
+
*/
|
|
141
|
+
export type string_model_description = string;
|
|
136
142
|
/**
|
|
137
143
|
* Source of one knowledge
|
|
138
144
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { really_any } from '../organization/really_any';
|
|
2
|
+
/**
|
|
3
|
+
* Function `asSerializable` will convert values which are not serializable to serializable values
|
|
4
|
+
* It walks deeply through the object and converts all values
|
|
5
|
+
*
|
|
6
|
+
* For example:
|
|
7
|
+
* - `Date` objects will be converted to string
|
|
8
|
+
*
|
|
9
|
+
* @private Internal helper function
|
|
10
|
+
*/
|
|
11
|
+
export declare function asSerializable(value: really_any): really_any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.77.0-
|
|
3
|
+
"version": "0.77.0-6",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.77.0-
|
|
57
|
+
"@promptbook/core": "0.77.0-6"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*
|
|
44
44
|
* @see https://github.com/webgptorg/promptbook
|
|
45
45
|
*/
|
|
46
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-
|
|
46
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-5';
|
|
47
47
|
/**
|
|
48
48
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
49
49
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8964,7 +8964,7 @@
|
|
|
8964
8964
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8965
8965
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
8966
8966
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8967
|
-
* TODO: [🧠] Maybe pass env as argument
|
|
8967
|
+
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
8968
8968
|
* TODO: [®] DRY Register logic */
|
|
8969
8969
|
|
|
8970
8970
|
/**
|
|
@@ -8988,20 +8988,21 @@
|
|
|
8988
8988
|
*/
|
|
8989
8989
|
function $registeredLlmToolsMessage() {
|
|
8990
8990
|
var e_1, _a, e_2, _b;
|
|
8991
|
+
var env = process.env;
|
|
8991
8992
|
/**
|
|
8992
8993
|
* Mixes registered LLM tools from $llmToolsMetadataRegister and $llmToolsRegister
|
|
8993
8994
|
*/
|
|
8994
8995
|
var all = [];
|
|
8995
|
-
var _loop_1 = function (packageName, className, envVariables) {
|
|
8996
|
+
var _loop_1 = function (title, packageName, className, envVariables) {
|
|
8996
8997
|
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
8997
8998
|
return "continue";
|
|
8998
8999
|
}
|
|
8999
|
-
all.push({ packageName: packageName, className: className, envVariables: envVariables });
|
|
9000
|
+
all.push({ title: title, packageName: packageName, className: className, envVariables: envVariables });
|
|
9000
9001
|
};
|
|
9001
9002
|
try {
|
|
9002
9003
|
for (var _c = __values($llmToolsMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9003
|
-
var _e = _d.value, packageName = _e.packageName, className = _e.className, envVariables = _e.envVariables;
|
|
9004
|
-
_loop_1(packageName, className, envVariables);
|
|
9004
|
+
var _e = _d.value, title = _e.title, packageName = _e.packageName, className = _e.className, envVariables = _e.envVariables;
|
|
9005
|
+
_loop_1(title, packageName, className, envVariables);
|
|
9005
9006
|
}
|
|
9006
9007
|
}
|
|
9007
9008
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -9031,6 +9032,7 @@
|
|
|
9031
9032
|
finally { if (e_2) throw e_2.error; }
|
|
9032
9033
|
}
|
|
9033
9034
|
var metadata = all.map(function (metadata) {
|
|
9035
|
+
var _a, _b;
|
|
9034
9036
|
var isMetadataAviailable = $llmToolsMetadataRegister
|
|
9035
9037
|
.list()
|
|
9036
9038
|
.find(function (_a) {
|
|
@@ -9043,46 +9045,77 @@
|
|
|
9043
9045
|
var packageName = _a.packageName, className = _a.className;
|
|
9044
9046
|
return metadata.packageName === packageName && metadata.className === className;
|
|
9045
9047
|
});
|
|
9046
|
-
|
|
9048
|
+
var isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every(function (envVariableName) { return env[envVariableName] !== undefined; })) || false;
|
|
9049
|
+
var isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some(function (envVariableName) { return env[envVariableName] !== undefined; })) || false;
|
|
9050
|
+
// <- Note: [🗨]
|
|
9051
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isFullyConfigured: isFullyConfigured, isPartiallyConfigured: isPartiallyConfigured });
|
|
9047
9052
|
});
|
|
9048
9053
|
if (metadata.length === 0) {
|
|
9049
9054
|
return "No LLM providers are available.";
|
|
9050
9055
|
}
|
|
9051
|
-
return spaceTrim__default["default"](function (block) { return "\n
|
|
9056
|
+
return spaceTrim__default["default"](function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
9057
|
+
.filter(function (envVariableName) {
|
|
9058
|
+
return metadata.some(function (_a) {
|
|
9059
|
+
var envVariables = _a.envVariables;
|
|
9060
|
+
return envVariables === null || envVariables === void 0 ? void 0 : envVariables.includes(envVariableName);
|
|
9061
|
+
});
|
|
9062
|
+
})
|
|
9063
|
+
.map(function (envVariableName) { return "- `".concat(envVariableName, "`"); })
|
|
9064
|
+
.join('\n')), "\n\n Available LLM providers are:\n ").concat(block(metadata
|
|
9052
9065
|
.map(function (_a, i) {
|
|
9053
|
-
var packageName = _a.packageName, className = _a.className, envVariables = _a.envVariables, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
|
|
9054
|
-
var
|
|
9055
|
-
if (just(false))
|
|
9056
|
-
more = '';
|
|
9057
|
-
}
|
|
9066
|
+
var title = _a.title, packageName = _a.packageName, className = _a.className, envVariables = _a.envVariables, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, isFullyConfigured = _a.isFullyConfigured, isPartiallyConfigured = _a.isPartiallyConfigured;
|
|
9067
|
+
var morePieces = [];
|
|
9068
|
+
if (just(false)) ;
|
|
9058
9069
|
else if (!isMetadataAviailable && !isInstalled) {
|
|
9059
9070
|
// TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
|
|
9060
|
-
|
|
9071
|
+
morePieces.push("Not installed and no metadata, looks like a unexpected behavior");
|
|
9061
9072
|
}
|
|
9062
9073
|
else if (isMetadataAviailable && !isInstalled) {
|
|
9063
9074
|
// TODO: [�][�]
|
|
9064
|
-
|
|
9075
|
+
morePieces.push("Not installed");
|
|
9065
9076
|
}
|
|
9066
9077
|
else if (!isMetadataAviailable && isInstalled) {
|
|
9067
|
-
|
|
9078
|
+
morePieces.push("No metadata but installed, looks like a unexpected behavior");
|
|
9068
9079
|
}
|
|
9069
9080
|
else if (isMetadataAviailable && isInstalled) {
|
|
9070
|
-
|
|
9081
|
+
morePieces.push("Installed");
|
|
9071
9082
|
}
|
|
9072
9083
|
else {
|
|
9073
|
-
|
|
9084
|
+
morePieces.push("unknown state, looks like a unexpected behavior");
|
|
9085
|
+
} /* not else */
|
|
9086
|
+
if (isFullyConfigured) {
|
|
9087
|
+
morePieces.push("Configured");
|
|
9088
|
+
}
|
|
9089
|
+
else if (isPartiallyConfigured) {
|
|
9090
|
+
morePieces.push("Partially confugured, missing ".concat(envVariables === null || envVariables === void 0 ? void 0 : envVariables.filter(function (envVariable) { return env[envVariable] === undefined; }).join(' + ')));
|
|
9074
9091
|
}
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9092
|
+
else {
|
|
9093
|
+
if (envVariables !== null) {
|
|
9094
|
+
morePieces.push("Not configured, to configure set env ".concat(envVariables === null || envVariables === void 0 ? void 0 : envVariables.join(' + ')));
|
|
9095
|
+
}
|
|
9096
|
+
else {
|
|
9097
|
+
morePieces.push("Not configured"); // <- Note: Can not be configured via environment variables
|
|
9098
|
+
}
|
|
9099
|
+
}
|
|
9100
|
+
var providerMessage = spaceTrim__default["default"]("\n ".concat(i + 1, ") **").concat(title, "** `").concat(className, "` from `").concat(packageName, "`\n ").concat(morePieces.join('; '), "\n "));
|
|
9101
|
+
if ($isRunningInNode) {
|
|
9102
|
+
if (isInstalled && isFullyConfigured) {
|
|
9103
|
+
providerMessage = colors__default["default"].green(providerMessage);
|
|
9104
|
+
}
|
|
9105
|
+
else if (isInstalled && isPartiallyConfigured) {
|
|
9106
|
+
providerMessage = colors__default["default"].yellow(providerMessage);
|
|
9107
|
+
}
|
|
9108
|
+
else {
|
|
9109
|
+
providerMessage = colors__default["default"].gray(providerMessage);
|
|
9110
|
+
}
|
|
9078
9111
|
}
|
|
9079
|
-
return
|
|
9080
|
-
// <- TODO: !!!!!! Is this indented correctly?
|
|
9112
|
+
return providerMessage;
|
|
9081
9113
|
})
|
|
9082
9114
|
.join('\n')), "\n "); });
|
|
9083
9115
|
}
|
|
9084
9116
|
/**
|
|
9085
9117
|
* TODO: [®] DRY Register logic
|
|
9118
|
+
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
9086
9119
|
*/
|
|
9087
9120
|
|
|
9088
9121
|
/**
|