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

@promptbook/utils

Package Overview
Dependencies
Maintainers
1
Versions
540
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@promptbook/utils - npm Package Compare versions

Comparing version 0.84.0-10 to 0.84.0-11

2

esm/typings/src/_packages/utils.index.d.ts

@@ -11,2 +11,3 @@ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';

import { prompt } from '../pipeline/prompt-notation';
import { promptTemplate } from '../pipeline/prompt-notation';
import { $getCurrentDate } from '../utils/$getCurrentDate';

@@ -93,2 +94,3 @@ import { $isRunningInBrowser } from '../utils/environment/$isRunningInBrowser';

export { prompt };
export { promptTemplate };
export { $getCurrentDate };

@@ -95,0 +97,0 @@ export { $isRunningInBrowser };

4

esm/typings/src/execution/assertsExecutionSuccessful.d.ts

@@ -5,2 +5,4 @@ import type { PipelineExecutorResult } from './PipelineExecutorResult';

*
* Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
*
* @param executionResult - The partial result of the Promptbook execution

@@ -10,3 +12,3 @@ * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred

*/
export declare function assertsExecutionSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors'>): void;
export declare function assertsExecutionSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors' | 'warnings'>): void;
/**

@@ -13,0 +15,0 @@ * TODO: [๐Ÿš] This function should be removed OR changed OR be completely rewritten

@@ -5,5 +5,6 @@ import type { PipelineString } from './PipelineString';

*
* Note: There are 2 similar functions:
* Note: There are 3 similar functions:
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
* 1) `book` for notating and validating entire books exported from `@promptbook/utils`
* 2) `promptTemplate` alias for `prompt`
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
*

@@ -10,0 +11,0 @@ * @param strings @@@

@@ -5,9 +5,10 @@ import type { string_prompt } from '../types/typeAliases';

*
* Note: There are 2 similar functions:
* Note: There are 3 similar functions:
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
* 1) `book` for notating and validating entire books exported from `@promptbook/utils`
* 2) `promptTemplate` alias for `prompt`
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
*
* @param strings @@@
* @param values @@@
* @returns the pipeline string
* @param strings
* @param values
* @returns the prompt string
* @public exported from `@promptbook/utils`

@@ -17,4 +18,16 @@ */

/**
* Tag function for notating a prompt as template literal
*
* Note: There are 3 similar functions:
* 1) `prompt` for notating single prompt exported from `@promptbook/utils`
* 2) `promptTemplate` alias for `prompt`
* 3) `book` for notating and validating entire books exported from `@promptbook/utils`
*
* @alias prompt
* @public exported from `@promptbook/utils`
*/
export declare const promptTemplate: typeof prompt;
/**
* TODO: [๐Ÿง ][๐Ÿˆด] Where is the best location for this file
* Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
*/
{
"name": "@promptbook/utils",
"version": "0.84.0-10",
"version": "0.84.0-11",
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",

@@ -5,0 +5,0 @@ "--note-0": " <- [๐ŸŠ]",

@@ -45,33 +45,33 @@ <!-- โš ๏ธ WARNING: This code has been generated so that any manual changes will be overwritten -->

Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs
Utility functions used in the library, but also useful for individual use in pre and post-processing of LLM inputs and outputs.
Here is a overview of the functions which are exported from the `@promptbook/utils` package and can be used in your own projects:
Here is an overview of the functions that can be exported from the `@promptbook/utils` package and used in your own projects:
## Postprocessing
## Simple templating
Sometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:
The `prompt` template tag function helps format prompt strings for LLM interactions. It handles string interpolation and maintains consistent formatting for multiline strings and lists and also handles a security to avoid **prompt injection**.
- `spaceTrim`
- `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `extractBlock`
- `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `prettifyPipelineString`
- `removeMarkdownComments`
- `removeEmojis`
- `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `removeQuotes`
- `trimCodeBlock`
- `trimEndOfCodeBlock`
- `unwrapResult`
```typescript
import { prompt } from '@promptbook/utils';
Very often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:
const promptString = prompt`
Correct the following sentence:
> ${unsecureUserInput}
`;
```
The `prompt` name could be overloaded by multiple things in your code. If you want to use the `promptTemplate` which is alias for `prompt`:
```typescript
import { unwrapResult } from '@promptbook/utils';
import { promptTemplate } from '@promptbook/utils';
unwrapResult('Best greeting for the user is "Hi Pavol!"'); // 'Hi Pavol!'
const promptString = promptTemplate`
Correct the following sentence:
> ${unsecureUserInput}
`;
```
## Templating
## Advanced templating

@@ -156,2 +156,28 @@ There is a function `templateParameters` which is used to replace the parameters in given template optimized to LLM prompt templates.

## Postprocessing
Sometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:
- `spaceTrim`
- `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `extractBlock`
- `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `prettifyPipelineString`
- `removeMarkdownComments`
- `removeEmojis`
- `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
- `removeQuotes`
- `trimCodeBlock`
- `trimEndOfCodeBlock`
- `unwrapResult`
Very often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:
```typescript
import { unwrapResult } from '@promptbook/utils';
unwrapResult('Best greeting for the user is "Hi Pavol!"'); // 'Hi Pavol!'
```
## Misc

@@ -158,0 +184,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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