New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@promptbook/execute-javascript

Package Overview
Dependencies
Maintainers
1
Versions
568
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@promptbook/execute-javascript - npm Package Compare versions

Comparing version 0.24.0-0 to 0.24.0-1.0

esm/typings/utils/markdown/prettifyMarkdown.d.ts

44

esm/index.es.js

@@ -179,15 +179,2 @@ import { capitalize, decapitalize, nameToUriPart, nameToUriParts, removeDiacritics, normalizeWhitespaces, normalizeToKebabCase, normalizeTo_camelCase, normalizeTo_snake_case, normalizeTo_PascalCase, parseKeywordsFromString, normalizeTo_SCREAMING_CASE } from 'n12';

/**
* Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
*
* Note: This is usefull for post-processing of the result of the completion LLM model
* if you want to start code block in the prompt but you don't want to end it in the result.
*/
function trimEndOfCodeBlock(value) {
value = spaceTrim(value);
value = value.replace(/```$/g, '');
value = spaceTrim(value);
return value;
}
/**
* Function trimCodeBlock will trim starting and ending code block from the string if it is present.

@@ -211,2 +198,15 @@ *

/**
* Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
*
* Note: This is usefull for post-processing of the result of the completion LLM model
* if you want to start code block in the prompt but you don't want to end it in the result.
*/
function trimEndOfCodeBlock(value) {
value = spaceTrim(value);
value = value.replace(/```$/g, '');
value = spaceTrim(value);
return value;
}
/**
* Removes quotes and optional introduce text from a string

@@ -398,3 +398,19 @@ *

}
result = eval(statementToEvaluate);
try {
result = eval(statementToEvaluate);
}
catch (error) {
if (!(error instanceof Error)) {
throw error;
}
if (error instanceof ReferenceError) {
/*
Note: Remapping error
From: [ReferenceError: thing is not defined],
To: [Error: Parameter {thing} is not defined],
*/
throw new Error("Parameter {".concat(error.message.split(' ')[0], "} is not defined"));
}
throw error;
}
if (typeof result !== 'string') {

@@ -401,0 +417,0 @@ throw new Error("Script must return a string, but returned ".concat(typeof result));

@@ -1,2 +0,2 @@

import { string_name } from '.././types/typeAliases';
import { string_name, string_version } from '.././types/typeAliases';
import { PromptTemplateJson } from '../types/PromptTemplatePipelineJson/PromptTemplateJson';

@@ -19,2 +19,5 @@ import { PromptTemplateParameterJson } from '../types/PromptTemplatePipelineJson/PromptTemplateParameterJson';

readonly ptbkUrl: URL | null;
readonly title: string | null;
readonly ptbkVersion: string_version | null;
readonly description: string | null;
readonly parameters: Record<string_name, PromptTemplateParameterJson>;

@@ -21,0 +24,0 @@ readonly promptTemplates: Array<PromptTemplateJson>;

import { string_name } from '.././types/typeAliases';
import { CreatePtpExecutorSettings } from '../execution/createPtpExecutor';
import { ExecutionTools } from '../execution/ExecutionTools';

@@ -8,2 +9,6 @@ import { PtpExecutor } from '../execution/PtpExecutor';

import { PromptTemplatePipeline } from './PromptTemplatePipeline';
type PromptTemplatePipelineLibraryOptions = {
readonly library: Record<string_name, PromptTemplatePipeline>;
readonly settings: CreatePtpExecutorSettings;
};
/**

@@ -19,3 +24,3 @@ * Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.

export declare class PromptTemplatePipelineLibrary {
readonly promptTemplatePipelines: Record<string_name, PromptTemplatePipeline>;
readonly options: PromptTemplatePipelineLibraryOptions;
/**

@@ -30,3 +35,3 @@ * Constructs PromptTemplatePipeline from any sources

*/
static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>): PromptTemplatePipelineLibrary;
static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>, settings: CreatePtpExecutorSettings): PromptTemplatePipelineLibrary;
private constructor();

@@ -46,2 +51,3 @@ /**

}
export {};
/**

@@ -48,0 +54,0 @@ * TODO: !!! This should be renamed to Promptbook

import { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
import { ExecutionTools } from './ExecutionTools';
import { PtpExecutor } from './PtpExecutor';
export interface CreatePtpExecutorSettings {
/**
* When executor does not satisfy expectations it will be retried this amount of times
*
* !!!!!!! Make default in version 24.1.0
*/
readonly maxNaturalExecutionAttempts: number;
}
interface CreatePtpExecutorOptions {
readonly ptp: PromptTemplatePipeline;
readonly tools: ExecutionTools;
readonly settings: CreatePtpExecutorSettings;
}

@@ -8,0 +17,0 @@ /**

@@ -1,4 +0,5 @@

import { Promisable } from 'type-fest';
import { string_name } from '.././types/typeAliases';
import { TaskProgress } from '../types/TaskProgress';
import type { Promisable } from 'type-fest';
import type { string_name } from '.././types/typeAliases';
import type { TaskProgress } from '../types/TaskProgress';
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
/**

@@ -15,3 +16,22 @@ * Executor is a simple async function that takes input parameters and returns result parameters _(along with all intermediate parameters and input parameters = it extends input object)_.

export interface PtpExecutor {
(inputParameters: Record<string_name, string>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<Record<string_name, string>>;
(inputParameters: Record<string_name, string>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
/**
* Whether the execution was successful
*/
isSuccessful: boolean;
/**
* Errors that occured during the execution
*/
errors: Array<Error>;
/**
* The report of the execution
*/
executionReport: ExecutionReportJson;
/**
* Result parameters of the execution
*
* Note: If the execution was not successful, there are only some of the result parameters
*/
outputParameters: Record<string_name, string>;
}>;
}

@@ -18,0 +38,0 @@ /**

import type { PromptResult } from '../../execution/PromptResult';
import { Prompt } from '../Prompt';
import type { Prompt } from '../Prompt';
import type { string_ptbk_url, string_version } from '../typeAliases';
/**

@@ -13,8 +14,44 @@ * ExecutionReport is result of executing one promptbook

*/
export type ExecutionReportJson = Array<{
prompt: Omit<Prompt, 'ptbkUrl' | 'parameters'>;
result: PromptResult;
}>;
/**
* TODO: [🧠] What is the best shape of ExecutionReportJson
*/
export type ExecutionReportJson = {
/**
* Unique identifier of the ptp from ptp which was executed
*/
readonly ptbkUrl?: string_ptbk_url;
/**
* Title of from ptp which was executed
*/
readonly title?: string;
/**
* Version from ptp which was executed
*/
readonly ptbkUsedVersion: string_version;
/**
* Version from ptp which was requested by promptbook
*/
readonly ptbkRequestedVersion?: string_version;
/**
* Description of the ptp which was executed
*/
readonly description?: string;
/**
* Sequence of prompt templates in order which were executed
*/
readonly promptExecutions: Array<{
/**
* The prompt wich was executed
*/
prompt: Omit<Prompt, 'ptbkUrl' | 'parameters'>;
/**
* Result of the prompt execution (if not failed during LLM execution)
*/
result?: PromptResult;
/**
* The error which occured during LLM execution or during postprocessing or expectation checking
*
* Note: It makes sense to have both error and result defined, for example when the result not pass expectations
*/
error?: {
message: string;
};
}>;
};

@@ -1,3 +0,3 @@

import { string_name, string_prompt, string_ptbk_url_with_hashtemplate } from '.././types/typeAliases';
import { ModelRequirements } from './ModelRequirements';
import type { string_name, string_prompt, string_ptbk_url_with_hashtemplate, string_title } from '.././types/typeAliases';
import type { ModelRequirements } from './ModelRequirements';
/**

@@ -10,2 +10,8 @@ * Prompt in a text along with model requirements, but without any execution or templating logic.

/**
* The title of the prompt
*
* Note: This has no effect on the model, it is just for the reporting
*/
readonly title: string_title;
/**
* The text of the prompt

@@ -12,0 +18,0 @@ *

{
"name": "@promptbook/execute-javascript",
"version": "0.24.0-0",
"version": "0.24.0-1.0",
"description": "Library to supercharge your use of large language models",

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

"peerDependencies": {
"@promptbook/core": "0.24.0-0"
"@promptbook/core": "0.24.0-1.0"
},

@@ -45,0 +45,0 @@ "main": "./umd/index.umd.js",

@@ -185,15 +185,2 @@ (function (global, factory) {

/**
* Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
*
* Note: This is usefull for post-processing of the result of the completion LLM model
* if you want to start code block in the prompt but you don't want to end it in the result.
*/
function trimEndOfCodeBlock(value) {
value = spaceTrim__default["default"](value);
value = value.replace(/```$/g, '');
value = spaceTrim__default["default"](value);
return value;
}
/**
* Function trimCodeBlock will trim starting and ending code block from the string if it is present.

@@ -217,2 +204,15 @@ *

/**
* Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
*
* Note: This is usefull for post-processing of the result of the completion LLM model
* if you want to start code block in the prompt but you don't want to end it in the result.
*/
function trimEndOfCodeBlock(value) {
value = spaceTrim__default["default"](value);
value = value.replace(/```$/g, '');
value = spaceTrim__default["default"](value);
return value;
}
/**
* Removes quotes and optional introduce text from a string

@@ -404,3 +404,19 @@ *

}
result = eval(statementToEvaluate);
try {
result = eval(statementToEvaluate);
}
catch (error) {
if (!(error instanceof Error)) {
throw error;
}
if (error instanceof ReferenceError) {
/*
Note: Remapping error
From: [ReferenceError: thing is not defined],
To: [Error: Parameter {thing} is not defined],
*/
throw new Error("Parameter {".concat(error.message.split(' ')[0], "} is not defined"));
}
throw error;
}
if (typeof result !== 'string') {

@@ -407,0 +423,0 @@ throw new Error("Script must return a string, but returned ".concat(typeof result));

@@ -1,2 +0,2 @@

import { string_name } from '.././types/typeAliases';
import { string_name, string_version } from '.././types/typeAliases';
import { PromptTemplateJson } from '../types/PromptTemplatePipelineJson/PromptTemplateJson';

@@ -19,2 +19,5 @@ import { PromptTemplateParameterJson } from '../types/PromptTemplatePipelineJson/PromptTemplateParameterJson';

readonly ptbkUrl: URL | null;
readonly title: string | null;
readonly ptbkVersion: string_version | null;
readonly description: string | null;
readonly parameters: Record<string_name, PromptTemplateParameterJson>;

@@ -21,0 +24,0 @@ readonly promptTemplates: Array<PromptTemplateJson>;

import { string_name } from '.././types/typeAliases';
import { CreatePtpExecutorSettings } from '../execution/createPtpExecutor';
import { ExecutionTools } from '../execution/ExecutionTools';

@@ -8,2 +9,6 @@ import { PtpExecutor } from '../execution/PtpExecutor';

import { PromptTemplatePipeline } from './PromptTemplatePipeline';
type PromptTemplatePipelineLibraryOptions = {
readonly library: Record<string_name, PromptTemplatePipeline>;
readonly settings: CreatePtpExecutorSettings;
};
/**

@@ -19,3 +24,3 @@ * Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.

export declare class PromptTemplatePipelineLibrary {
readonly promptTemplatePipelines: Record<string_name, PromptTemplatePipeline>;
readonly options: PromptTemplatePipelineLibraryOptions;
/**

@@ -30,3 +35,3 @@ * Constructs PromptTemplatePipeline from any sources

*/
static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>): PromptTemplatePipelineLibrary;
static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>, settings: CreatePtpExecutorSettings): PromptTemplatePipelineLibrary;
private constructor();

@@ -46,2 +51,3 @@ /**

}
export {};
/**

@@ -48,0 +54,0 @@ * TODO: !!! This should be renamed to Promptbook

import { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
import { ExecutionTools } from './ExecutionTools';
import { PtpExecutor } from './PtpExecutor';
export interface CreatePtpExecutorSettings {
/**
* When executor does not satisfy expectations it will be retried this amount of times
*
* !!!!!!! Make default in version 24.1.0
*/
readonly maxNaturalExecutionAttempts: number;
}
interface CreatePtpExecutorOptions {
readonly ptp: PromptTemplatePipeline;
readonly tools: ExecutionTools;
readonly settings: CreatePtpExecutorSettings;
}

@@ -8,0 +17,0 @@ /**

@@ -1,4 +0,5 @@

import { Promisable } from 'type-fest';
import { string_name } from '.././types/typeAliases';
import { TaskProgress } from '../types/TaskProgress';
import type { Promisable } from 'type-fest';
import type { string_name } from '.././types/typeAliases';
import type { TaskProgress } from '../types/TaskProgress';
import type { ExecutionReportJson } from '../types/execution-report/ExecutionReportJson';
/**

@@ -15,3 +16,22 @@ * Executor is a simple async function that takes input parameters and returns result parameters _(along with all intermediate parameters and input parameters = it extends input object)_.

export interface PtpExecutor {
(inputParameters: Record<string_name, string>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<Record<string_name, string>>;
(inputParameters: Record<string_name, string>, onProgress: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
/**
* Whether the execution was successful
*/
isSuccessful: boolean;
/**
* Errors that occured during the execution
*/
errors: Array<Error>;
/**
* The report of the execution
*/
executionReport: ExecutionReportJson;
/**
* Result parameters of the execution
*
* Note: If the execution was not successful, there are only some of the result parameters
*/
outputParameters: Record<string_name, string>;
}>;
}

@@ -18,0 +38,0 @@ /**

import type { PromptResult } from '../../execution/PromptResult';
import { Prompt } from '../Prompt';
import type { Prompt } from '../Prompt';
import type { string_ptbk_url, string_version } from '../typeAliases';
/**

@@ -13,8 +14,44 @@ * ExecutionReport is result of executing one promptbook

*/
export type ExecutionReportJson = Array<{
prompt: Omit<Prompt, 'ptbkUrl' | 'parameters'>;
result: PromptResult;
}>;
/**
* TODO: [🧠] What is the best shape of ExecutionReportJson
*/
export type ExecutionReportJson = {
/**
* Unique identifier of the ptp from ptp which was executed
*/
readonly ptbkUrl?: string_ptbk_url;
/**
* Title of from ptp which was executed
*/
readonly title?: string;
/**
* Version from ptp which was executed
*/
readonly ptbkUsedVersion: string_version;
/**
* Version from ptp which was requested by promptbook
*/
readonly ptbkRequestedVersion?: string_version;
/**
* Description of the ptp which was executed
*/
readonly description?: string;
/**
* Sequence of prompt templates in order which were executed
*/
readonly promptExecutions: Array<{
/**
* The prompt wich was executed
*/
prompt: Omit<Prompt, 'ptbkUrl' | 'parameters'>;
/**
* Result of the prompt execution (if not failed during LLM execution)
*/
result?: PromptResult;
/**
* The error which occured during LLM execution or during postprocessing or expectation checking
*
* Note: It makes sense to have both error and result defined, for example when the result not pass expectations
*/
error?: {
message: string;
};
}>;
};

@@ -1,3 +0,3 @@

import { string_name, string_prompt, string_ptbk_url_with_hashtemplate } from '.././types/typeAliases';
import { ModelRequirements } from './ModelRequirements';
import type { string_name, string_prompt, string_ptbk_url_with_hashtemplate, string_title } from '.././types/typeAliases';
import type { ModelRequirements } from './ModelRequirements';
/**

@@ -10,2 +10,8 @@ * Prompt in a text along with model requirements, but without any execution or templating logic.

/**
* The title of the prompt
*
* Note: This has no effect on the model, it is just for the reporting
*/
readonly title: string_title;
/**
* The text of the prompt

@@ -12,0 +18,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