Socket
Socket
Sign inDemoInstall

@promptbook/remote-client

Package Overview
Dependencies
Maintainers
0
Versions
401
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@promptbook/remote-client - npm Package Compare versions

Comparing version 0.67.0-2 to 0.67.0-3

277

esm/index.es.js
import { io } from 'socket.io-client';
import { spaceTrim } from 'spacetrim';
import spaceTrim$1, { spaceTrim } from 'spacetrim';

@@ -8,3 +8,3 @@ // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten

*/
var PROMPTBOOK_VERSION = '0.67.0-1';
var PROMPTBOOK_VERSION = '0.67.0-2';
// TODO: !!!! List here all the versions and annotate + put into script

@@ -81,3 +81,256 @@

function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
/**
* @@@
*
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
*
* @returns The same object as the input, but deeply frozen
* @public exported from `@promptbook/utils`
*/
function $deepFreeze(objectValue) {
var e_1, _a;
var propertyNames = Object.getOwnPropertyNames(objectValue);
try {
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
var propertyName = propertyNames_1_1.value;
var value = objectValue[propertyName];
if (value && typeof value === 'object') {
$deepFreeze(value);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
}
finally { if (e_1) throw e_1.error; }
}
return Object.freeze(objectValue);
}
/**
* TODO: [🧠] Is there a way how to meaningfully test this utility
*/
/**
* This error type indicates that the error should not happen and its last check before crashing with some other error
*
* @public exported from `@promptbook/core`
*/
var UnexpectedError = /** @class */ (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(message) {
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
_this.name = 'UnexpectedError';
Object.setPrototypeOf(_this, UnexpectedError.prototype);
return _this;
}
return UnexpectedError;
}(Error));
/**
* Checks if the value is [🚉] serializable as JSON
* If not, throws an UnexpectedError with a rich error message and tracking
*
* - Almost all primitives are serializable BUT:
* - `undefined` is not serializable
* - `NaN` is not serializable
* - Objects and arrays are serializable if all their properties are serializable
* - Functions are not serializable
* - Circular references are not serializable
* - `Date` objects are not serializable
* - `Map` and `Set` objects are not serializable
* - `RegExp` objects are not serializable
* - `Error` objects are not serializable
* - `Symbol` objects are not serializable
* - And much more...
*
* @throws UnexpectedError if the value is not serializable as JSON
* @public exported from `@promptbook/utils`
*/
function checkSerializableAsJson(name, value) {
var e_1, _a;
if (value === undefined) {
throw new UnexpectedError("".concat(name, " is undefined"));
}
else if (value === null) {
return;
}
else if (typeof value === 'boolean') {
return;
}
else if (typeof value === 'number' && !isNaN(value)) {
return;
}
else if (typeof value === 'string') {
return;
}
else if (typeof value === 'symbol') {
throw new UnexpectedError("".concat(name, " is symbol"));
}
else if (typeof value === 'function') {
throw new UnexpectedError("".concat(name, " is function"));
}
else if (typeof value === 'object' && Array.isArray(value)) {
for (var i = 0; i < value.length; i++) {
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
}
}
else if (typeof value === 'object') {
if (value instanceof Date) {
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
}
else if (value instanceof Map) {
throw new UnexpectedError("".concat(name, " is Map"));
}
else if (value instanceof Set) {
throw new UnexpectedError("".concat(name, " is Set"));
}
else if (value instanceof RegExp) {
throw new UnexpectedError("".concat(name, " is RegExp"));
}
else if (value instanceof Error) {
throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
}
else {
try {
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
if (subValue === undefined) {
// Note: undefined in object is serializable - it is just omited
continue;
}
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
try {
JSON.stringify(value); // <- TODO: [0]
}
catch (error) {
if (!(error instanceof Error)) {
throw error;
}
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
}
/*
TODO: [0] Is there some more elegant way to check circular references?
const seen = new Set();
const stack = [{ value }];
while (stack.length > 0) {
const { value } = stack.pop()!;
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
throw new UnexpectedError(`${name} has circular reference`);
}
seen.add(value);
if (Array.isArray(value)) {
stack.push(...value.map((value) => ({ value })));
} else {
stack.push(...Object.values(value).map((value) => ({ value })));
}
}
}
*/
return;
}
}
else {
throw new UnexpectedError("".concat(name, " is unknown"));
}
}
/**
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
* TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
*/
/**
* @@@
* @@@
*
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
*
* @param name - Name of the object for debugging purposes
* @param objectValue - Object to be deeply frozen
* @returns The same object as the input, but deeply frozen
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
*/
function $asDeeplyFrozenSerializableJson(name, objectValue) {
checkSerializableAsJson(name, objectValue);
return $deepFreeze(objectValue);
}
/**
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
* TODO: [🧠] Is there a way how to meaningfully test this utility
*/
/**
* Timeout for the connections in milliseconds
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
var CONNECTION_TIMEOUT_MS = 7 * 1000;
/**
* How many times to retry the connections
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
var CONNECTION_RETRIES_LIMIT = 5;
/**
* The names of the parameters that are reserved for special purposes
*
* @public exported from `@promptbook/core`
*/
$asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
'content',
'context',
'knowledge',
'samples',
'modelName',
'currentDate',
// <- TODO: Add more like 'date', 'modelName',...
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
]);
/**
* TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
*/
/**
* This error indicates that the pipeline collection cannot be propperly loaded

@@ -227,18 +480,2 @@ *

/**
* This error type indicates that the error should not happen and its last check before crashing with some other error
*
* @public exported from `@promptbook/core`
*/
var UnexpectedError = /** @class */ (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(message) {
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
_this.name = 'UnexpectedError';
Object.setPrototypeOf(_this, UnexpectedError.prototype);
return _this;
}
return UnexpectedError;
}(Error));
/**
* Index of all custom errors

@@ -370,2 +607,4 @@ *

var socket = io(_this.options.remoteUrl, {
retries: CONNECTION_RETRIES_LIMIT,
timeout: CONNECTION_TIMEOUT_MS,
path: _this.options.path,

@@ -382,3 +621,3 @@ // path: `${this.remoteUrl.pathname}/socket.io`,

reject(new Error("Timeout while connecting to ".concat(_this.options.remoteUrl)));
}, 60000 /* <- TODO: Timeout to config */);
}, CONNECTION_TIMEOUT_MS);
});

@@ -385,0 +624,0 @@ };

@@ -34,2 +34,14 @@ /**

/**
* Timeout for the connections in milliseconds
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
export declare const CONNECTION_TIMEOUT_MS: number;
/**
* How many times to retry the connections
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
export declare const CONNECTION_RETRIES_LIMIT = 5;
/**
* The maximum number of (LLM) tasks running in parallel

@@ -36,0 +48,0 @@ *

4

package.json
{
"name": "@promptbook/remote-client",
"version": "0.67.0-2",
"version": "0.67.0-3",
"description": "Supercharge your use of large language models",

@@ -50,3 +50,3 @@ "private": false,

"peerDependencies": {
"@promptbook/core": "0.67.0-2"
"@promptbook/core": "0.67.0-3"
},

@@ -53,0 +53,0 @@ "dependencies": {

@@ -42,34 +42,20 @@ <!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->

When you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, or whatever, it doesn't matter how it is integrated. Whether it's the direct calling of a REST API, using the SDK, hardcoding the prompt in the source code, or importing a text file, the process remains the same.
If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
If you need something more advanced or want to extend the capabilities of LLMs, you generally have three ways to proceed:
But often you will struggle with the limitations of LLMs, such as hallucinations, off-topic responses, poor quality output, language drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd responses. When this happens, you generally have three options:
1. **Fine-tune** the model to your specifications or even train your own.
2. **Prompt-engineer** the prompt to the best shape you can achieve.
3. Use **multiple prompts** in a pipeline to get the best result.
3. Use **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
In any of these situations, but especially in (3), the Promptbook library can make your life easier and make **orchestraror for your prompts**.
In all of these situations, but especially in 3., the Promptbook library can make your life easier.
- **Separation of concerns** between prompt engineer and programmer; between code files and prompt files; and between prompts and their execution logic.
- Set up a **common format** for prompts that is interchangeable between projects and language/technology stacks.
- **Preprocessing** and cleaning the input data from the user.
- Use default values - **Jokers** to bypass some parts of the pipeline.
- **Expect** some specific output from the model.
- **Retry** mismatched outputs.
- **Combine** multiple models together.
- Interactive **User interaction** with the model and the user.
- Leverage **external** sources (like ChatGPT plugins or OpenAI's GPTs).
- Simplify your code to be **DRY** and not repeat all the boilerplate code for each prompt.
- **Versioning** of promptbooks
- **Reuse** parts of promptbooks in/between projects.
- Run the LLM **optimally** in parallel, with the best _cost/quality_ ratio or _speed/quality_ ratio.
- **Execution report** to see what happened during the execution.
- **Logging** the results of the promptbooks.
- _(Not ready yet)_ **Caching** calls to LLMs to save money and time.
- _(Not ready yet)_ Extend one prompt book from another one.
- _(Not ready yet)_ Leverage the **streaming** to make super cool UI/UX.
- _(Not ready yet)_ **A/B testing** to determine which prompt works best for the job.
- [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic.
- Establishes a [**common format `.ptbk.md`**](https://github.com/webgptorg/promptbook/discussions/85) that can be used to describe your prompt business logic without having to write code or deal with the technicalities of LLMs.
- **Forget** about **low-level details** like choosing the right model, tokens, context size, temperature, top-k, top-p, or kernel sampling. **Just write your intent** and [**persona**](https://github.com/webgptorg/promptbook/discussions/22) who should be responsible for the task and let the library do the rest.
- Has built-in **orchestration** of [pipeline](https://github.com/webgptorg/promptbook/discussions/64) execution and many tools to make the process easier, more reliable, and more efficient, such as caching, [compilation+preparation](https://github.com/webgptorg/promptbook/discussions/78), [just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33), [expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37), [agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39), and more.
- Sometimes even the best prompts with the best framework like Promptbook `:)` can't avoid the problems. In this case, the library has built-in **[anomaly detection](https://github.com/webgptorg/promptbook/discussions/40) and logging** to help you find and fix the problems.
- Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.
- Promptbook is designed to do [**RAG** (Retrieval-Augmented Generation)](https://github.com/webgptorg/promptbook/discussions/41) and other advanced techniques. You can use **knowledge** to improve the quality of the output.
## 🧔 Promptbook _(for prompt-engeneers)_

@@ -117,5 +103,3 @@

>
> - MODEL VARIANT Chat
> - MODEL NAME `gpt-4`
> - POSTPROCESSING `unwrapResult`
> - PERSONA Jane, Copywriter and Marketing Specialist.
>

@@ -154,5 +138,3 @@ > ```

>
> - MODEL VARIANT Chat
> - MODEL NAME `gpt-4`
> - POSTPROCESSING `unwrapResult`
> - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
>

@@ -177,4 +159,3 @@ > ```

>
> - MODEL VARIANT Chat
> - MODEL NAME `gpt-4`
> - PERSONA Paul, extremely creative SEO specialist.
>

@@ -223,4 +204,3 @@ > ```

>
> - MODEL VARIANT Completion
> - MODEL NAME `gpt-3.5-turbo-instruct`
> - PERSONA Jane
>

@@ -404,3 +384,8 @@ > ```

- When you are writing just a simple chatbot without any extra logic, just system messages
- When you have already implemented single simple prompt and it works fine for your job
- When [OpenAI Assistant (GPTs)](https://help.openai.com/en/articles/8673914-gpts-vs-assistants) is enough for you
- When you need streaming _(this may be implemented in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/102))_.
- When you need to use something other than JavaScript or TypeScript _(other languages are on the way, [see the discussion](https://github.com/webgptorg/promptbook/discussions/101))_
- When your main focus is on something other than text - like images, audio, video, spreadsheets _(other media types may be added in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/103))_
- When you need to use recursion _([see the discussion](https://github.com/webgptorg/promptbook/discussions/38))_

@@ -414,3 +399,2 @@ ## 🐜 Known issues

- [➿ No recursion](https://github.com/webgptorg/promptbook/discussions/38)

@@ -417,0 +401,0 @@ - [🏳 There are no types, just strings](https://github.com/webgptorg/promptbook/discussions/52)

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('socket.io-client'), require('spacetrim')) :
typeof define === 'function' && define.amd ? define(['exports', 'socket.io-client', 'spacetrim'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.socket_ioClient, global.spacetrim));
})(this, (function (exports, socket_ioClient, spacetrim) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.socket_ioClient, global.spaceTrim));
})(this, (function (exports, socket_ioClient, spaceTrim) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten

@@ -11,3 +15,3 @@ /**

*/
var PROMPTBOOK_VERSION = '0.67.0-1';
var PROMPTBOOK_VERSION = '0.67.0-2';
// TODO: !!!! List here all the versions and annotate + put into script

@@ -84,3 +88,256 @@

function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
/**
* @@@
*
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
*
* @returns The same object as the input, but deeply frozen
* @public exported from `@promptbook/utils`
*/
function $deepFreeze(objectValue) {
var e_1, _a;
var propertyNames = Object.getOwnPropertyNames(objectValue);
try {
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
var propertyName = propertyNames_1_1.value;
var value = objectValue[propertyName];
if (value && typeof value === 'object') {
$deepFreeze(value);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
}
finally { if (e_1) throw e_1.error; }
}
return Object.freeze(objectValue);
}
/**
* TODO: [🧠] Is there a way how to meaningfully test this utility
*/
/**
* This error type indicates that the error should not happen and its last check before crashing with some other error
*
* @public exported from `@promptbook/core`
*/
var UnexpectedError = /** @class */ (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(message) {
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
_this.name = 'UnexpectedError';
Object.setPrototypeOf(_this, UnexpectedError.prototype);
return _this;
}
return UnexpectedError;
}(Error));
/**
* Checks if the value is [🚉] serializable as JSON
* If not, throws an UnexpectedError with a rich error message and tracking
*
* - Almost all primitives are serializable BUT:
* - `undefined` is not serializable
* - `NaN` is not serializable
* - Objects and arrays are serializable if all their properties are serializable
* - Functions are not serializable
* - Circular references are not serializable
* - `Date` objects are not serializable
* - `Map` and `Set` objects are not serializable
* - `RegExp` objects are not serializable
* - `Error` objects are not serializable
* - `Symbol` objects are not serializable
* - And much more...
*
* @throws UnexpectedError if the value is not serializable as JSON
* @public exported from `@promptbook/utils`
*/
function checkSerializableAsJson(name, value) {
var e_1, _a;
if (value === undefined) {
throw new UnexpectedError("".concat(name, " is undefined"));
}
else if (value === null) {
return;
}
else if (typeof value === 'boolean') {
return;
}
else if (typeof value === 'number' && !isNaN(value)) {
return;
}
else if (typeof value === 'string') {
return;
}
else if (typeof value === 'symbol') {
throw new UnexpectedError("".concat(name, " is symbol"));
}
else if (typeof value === 'function') {
throw new UnexpectedError("".concat(name, " is function"));
}
else if (typeof value === 'object' && Array.isArray(value)) {
for (var i = 0; i < value.length; i++) {
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
}
}
else if (typeof value === 'object') {
if (value instanceof Date) {
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
}
else if (value instanceof Map) {
throw new UnexpectedError("".concat(name, " is Map"));
}
else if (value instanceof Set) {
throw new UnexpectedError("".concat(name, " is Set"));
}
else if (value instanceof RegExp) {
throw new UnexpectedError("".concat(name, " is RegExp"));
}
else if (value instanceof Error) {
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
}
else {
try {
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
if (subValue === undefined) {
// Note: undefined in object is serializable - it is just omited
continue;
}
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
try {
JSON.stringify(value); // <- TODO: [0]
}
catch (error) {
if (!(error instanceof Error)) {
throw error;
}
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
}
/*
TODO: [0] Is there some more elegant way to check circular references?
const seen = new Set();
const stack = [{ value }];
while (stack.length > 0) {
const { value } = stack.pop()!;
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
throw new UnexpectedError(`${name} has circular reference`);
}
seen.add(value);
if (Array.isArray(value)) {
stack.push(...value.map((value) => ({ value })));
} else {
stack.push(...Object.values(value).map((value) => ({ value })));
}
}
}
*/
return;
}
}
else {
throw new UnexpectedError("".concat(name, " is unknown"));
}
}
/**
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
* TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
*/
/**
* @@@
* @@@
*
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
*
* @param name - Name of the object for debugging purposes
* @param objectValue - Object to be deeply frozen
* @returns The same object as the input, but deeply frozen
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
*/
function $asDeeplyFrozenSerializableJson(name, objectValue) {
checkSerializableAsJson(name, objectValue);
return $deepFreeze(objectValue);
}
/**
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
* TODO: [🧠] Is there a way how to meaningfully test this utility
*/
/**
* Timeout for the connections in milliseconds
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
var CONNECTION_TIMEOUT_MS = 7 * 1000;
/**
* How many times to retry the connections
*
* @private within the repository - too low-level in comparison with other `MAX_...`
*/
var CONNECTION_RETRIES_LIMIT = 5;
/**
* The names of the parameters that are reserved for special purposes
*
* @public exported from `@promptbook/core`
*/
$asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
'content',
'context',
'knowledge',
'samples',
'modelName',
'currentDate',
// <- TODO: Add more like 'date', 'modelName',...
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
]);
/**
* TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
*/
/**
* This error indicates that the pipeline collection cannot be propperly loaded

@@ -157,3 +414,3 @@ *

function NotYetImplementedError(message) {
var _this = _super.call(this, spacetrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
_this.name = 'NotYetImplementedError';

@@ -231,18 +488,2 @@ Object.setPrototypeOf(_this, NotYetImplementedError.prototype);

/**
* This error type indicates that the error should not happen and its last check before crashing with some other error
*
* @public exported from `@promptbook/core`
*/
var UnexpectedError = /** @class */ (function (_super) {
__extends(UnexpectedError, _super);
function UnexpectedError(message) {
var _this = _super.call(this, spacetrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
_this.name = 'UnexpectedError';
Object.setPrototypeOf(_this, UnexpectedError.prototype);
return _this;
}
return UnexpectedError;
}(Error));
/**
* Index of all custom errors

@@ -374,2 +615,4 @@ *

var socket = socket_ioClient.io(_this.options.remoteUrl, {
retries: CONNECTION_RETRIES_LIMIT,
timeout: CONNECTION_TIMEOUT_MS,
path: _this.options.path,

@@ -386,3 +629,3 @@ // path: `${this.remoteUrl.pathname}/socket.io`,

reject(new Error("Timeout while connecting to ".concat(_this.options.remoteUrl)));
}, 60000 /* <- TODO: Timeout to config */);
}, CONNECTION_TIMEOUT_MS);
});

@@ -389,0 +632,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc