@promptbook/javascript 0.101.0-2 → 0.101.0-4
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
CHANGED
@@ -48,8 +48,53 @@ npm i ptbk
|
|
48
48
|
npm install @promptbook/javascript
|
49
49
|
```
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
JavaScript execution engine for Promptbook, providing secure JavaScript code execution within promptbook pipelines and script tasks.
|
52
|
+
|
53
|
+
## 🎯 Purpose and Motivation
|
54
|
+
|
55
|
+
This package provides a secure JavaScript execution environment for Promptbook pipelines. It enables the execution of JavaScript code in `SCRIPT` tasks, allowing for complex data transformations, calculations, and logic within promptbook workflows while maintaining security and isolation.
|
56
|
+
|
57
|
+
## 🔧 High-Level Functionality
|
58
|
+
|
59
|
+
The package provides JavaScript execution capabilities:
|
60
|
+
|
61
|
+
- **Script Task Execution**: Execute JavaScript code within promptbook `SCRIPT` tasks
|
62
|
+
- **Variable Extraction**: Analyze JavaScript code to extract variable dependencies
|
63
|
+
- **Postprocessing Functions**: Built-in JavaScript functions for common postprocessing tasks
|
64
|
+
- **Secure Execution**: Safe execution environment with proper isolation
|
65
|
+
- **Multiple Execution Modes**: Support for different JavaScript execution strategies
|
66
|
+
|
67
|
+
## ✨ Key Features
|
68
|
+
|
69
|
+
- 🔒 **Secure Execution** - Safe JavaScript execution with proper sandboxing
|
70
|
+
- 📝 **Script Tasks** - Execute JavaScript code within promptbook pipelines
|
71
|
+
- 🔧 **Variable Analysis** - Extract variable dependencies from JavaScript code
|
72
|
+
- 📊 **Postprocessing Functions** - Built-in functions for common data transformations
|
73
|
+
- ⚡ **Multiple Execution Modes** - Different execution strategies for various use cases
|
74
|
+
- 🛡️ **Error Handling** - Comprehensive error handling for script execution
|
75
|
+
- 🎯 **Pipeline Integration** - Seamless integration with promptbook execution flow
|
76
|
+
|
77
|
+
## 📦 Exported Entities
|
78
|
+
|
79
|
+
### Version Information
|
80
|
+
|
81
|
+
- `BOOK_LANGUAGE_VERSION` - Current book language version
|
82
|
+
- `PROMPTBOOK_ENGINE_VERSION` - Current engine version
|
83
|
+
|
84
|
+
### Execution Tools
|
85
|
+
|
86
|
+
- `JavascriptEvalExecutionTools` - JavaScript execution tools using eval
|
87
|
+
- `JavascriptExecutionTools` - Standard JavaScript execution tools
|
88
|
+
|
89
|
+
### Postprocessing
|
90
|
+
|
91
|
+
- `POSTPROCESSING_FUNCTIONS` - Built-in postprocessing functions for JavaScript
|
92
|
+
|
93
|
+
### Utilities
|
94
|
+
|
95
|
+
- `extractVariablesFromJavascript` - Extract variable dependencies from JavaScript code
|
96
|
+
|
97
|
+
> 💡 This package provides JavaScript execution for promptbook applications. For the core functionality, see [@promptbook/core](#-packages) or install all packages with `npm i ptbk`
|
53
98
|
|
54
99
|
|
55
100
|
---
|
package/esm/index.es.js
CHANGED
@@ -16,7 +16,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
16
16
|
* @generated
|
17
17
|
* @see https://github.com/webgptorg/promptbook
|
18
18
|
*/
|
19
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
19
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-4';
|
20
20
|
/**
|
21
21
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
22
22
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -119,4 +119,24 @@ export type ChatProps = {
|
|
119
119
|
* Keys should match ChatMessage.from values (e.g., 'USER', 'AGENT_{id}', etc.)
|
120
120
|
*/
|
121
121
|
readonly participants?: ReadonlyArray<ChatParticipant>;
|
122
|
+
/**
|
123
|
+
* Optional callback for handling user feedback on messages
|
124
|
+
* When provided, star rating buttons (1-5 stars) will be displayed next to each message
|
125
|
+
*
|
126
|
+
* @param feedback - Object containing the feedback data
|
127
|
+
* @param feedback.message - The message being rated
|
128
|
+
* @param feedback.rating - Star rating from 1 to 5
|
129
|
+
* @param feedback.textRating - Optional text feedback/note from user
|
130
|
+
* @param feedback.chatThread - Complete chat thread as string
|
131
|
+
* @param feedback.expectedAnswer - Optional expected answer provided by user
|
132
|
+
* @param feedback.url - Current page URL where feedback was given
|
133
|
+
*/
|
134
|
+
onFeedback?(feedback: {
|
135
|
+
message: ChatMessage;
|
136
|
+
rating: number;
|
137
|
+
textRating: string;
|
138
|
+
chatThread: string;
|
139
|
+
expectedAnswer: string | null;
|
140
|
+
url: string;
|
141
|
+
}): Promisable<void>;
|
122
142
|
};
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
16
16
|
/**
|
17
17
|
* Represents the version string of the Promptbook engine.
|
18
|
-
* It follows semantic versioning (e.g., `0.101.0-
|
18
|
+
* It follows semantic versioning (e.g., `0.101.0-3`).
|
19
19
|
*
|
20
20
|
* @generated
|
21
21
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@promptbook/javascript",
|
3
|
-
"version": "0.101.0-
|
3
|
+
"version": "0.101.0-4",
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
5
5
|
"private": false,
|
6
6
|
"sideEffects": false,
|
@@ -94,7 +94,7 @@
|
|
94
94
|
"module": "./esm/index.es.js",
|
95
95
|
"typings": "./esm/typings/src/_packages/javascript.index.d.ts",
|
96
96
|
"peerDependencies": {
|
97
|
-
"@promptbook/core": "0.101.0-
|
97
|
+
"@promptbook/core": "0.101.0-4"
|
98
98
|
},
|
99
99
|
"dependencies": {
|
100
100
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
* @generated
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
24
24
|
*/
|
25
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-4';
|
26
26
|
/**
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|