@promptbook/core 0.101.0-0 → 0.101.0-1
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 +240 -3
- package/esm/index.es.js +28 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
- package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -0
- package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -0
- package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
- package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
- package/esm/typings/src/utils/parseNumber.d.ts +1 -0
- package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
- package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
- package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
- package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +33 -9
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -48,9 +48,246 @@ npm i ptbk
|
|
|
48
48
|
npm install @promptbook/core
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
The core package contains the fundamental logic and infrastructure for Promptbook. It provides the essential building blocks for creating, parsing, validating, and executing promptbooks, along with comprehensive error handling, LLM provider integrations, and execution utilities.
|
|
52
|
+
|
|
53
|
+
## 🎯 Purpose and Motivation
|
|
54
|
+
|
|
55
|
+
The core package serves as the foundation of the Promptbook ecosystem. It abstracts away the complexity of working with different LLM providers, provides a unified interface for prompt execution, and handles all the intricate details of pipeline management, parameter validation, and result processing.
|
|
56
|
+
|
|
57
|
+
## 🔧 High-Level Functionality
|
|
58
|
+
|
|
59
|
+
This package orchestrates the entire promptbook execution lifecycle:
|
|
60
|
+
- **Pipeline Management**: Parse, validate, and compile promptbook definitions
|
|
61
|
+
- **Execution Engine**: Create and manage pipeline executors with comprehensive error handling
|
|
62
|
+
- **LLM Integration**: Unified interface for multiple LLM providers (OpenAI, Anthropic, Google, etc.)
|
|
63
|
+
- **Parameter Processing**: Template parameter substitution and validation
|
|
64
|
+
- **Knowledge Management**: Handle knowledge sources and scraping
|
|
65
|
+
- **Storage Abstraction**: Flexible storage backends for caching and persistence
|
|
66
|
+
- **Format Support**: Parse and validate various data formats (JSON, CSV, XML)
|
|
67
|
+
|
|
68
|
+
## ✨ Key Features
|
|
69
|
+
|
|
70
|
+
- 🚀 **Universal Pipeline Executor** - Execute promptbooks with any supported LLM provider
|
|
71
|
+
- 🔄 **Multi-Provider Support** - Seamlessly switch between OpenAI, Anthropic, Google, and other providers
|
|
72
|
+
- 📊 **Comprehensive Validation** - Validate promptbooks, parameters, and execution results
|
|
73
|
+
- 🎯 **Expectation Checking** - Built-in validation for output format, length, and content expectations
|
|
74
|
+
- 🧠 **Knowledge Integration** - Scrape and process knowledge from various sources
|
|
75
|
+
- 💾 **Flexible Storage** - Memory, filesystem, and custom storage backends
|
|
76
|
+
- 🔧 **Error Handling** - Detailed error types for debugging and monitoring
|
|
77
|
+
- 📈 **Usage Tracking** - Monitor token usage, costs, and performance metrics
|
|
78
|
+
- 🎨 **Format Parsers** - Support for JSON, CSV, XML, and text formats
|
|
79
|
+
- 🔀 **Pipeline Migration** - Upgrade and migrate pipeline definitions
|
|
80
|
+
|
|
81
|
+
## 📦 Exported Entities
|
|
82
|
+
|
|
83
|
+
### Version Information
|
|
84
|
+
- `BOOK_LANGUAGE_VERSION` - Current book language version
|
|
85
|
+
- `PROMPTBOOK_ENGINE_VERSION` - Current engine version
|
|
86
|
+
|
|
87
|
+
### Agent and Book Management
|
|
88
|
+
- `createAgentModelRequirements` - Create model requirements for agents
|
|
89
|
+
- `parseAgentSource` - Parse agent source code
|
|
90
|
+
- `isValidBook` - Validate book format
|
|
91
|
+
- `validateBook` - Comprehensive book validation
|
|
92
|
+
- `DEFAULT_BOOK` - Default book template
|
|
93
|
+
|
|
94
|
+
### Commitment System
|
|
95
|
+
- `createEmptyAgentModelRequirements` - Create empty model requirements
|
|
96
|
+
- `createBasicAgentModelRequirements` - Create basic model requirements
|
|
97
|
+
- `NotYetImplementedCommitmentDefinition` - Placeholder for future commitments
|
|
98
|
+
- `getCommitmentDefinition` - Get specific commitment definition
|
|
99
|
+
- `getAllCommitmentDefinitions` - Get all available commitment definitions
|
|
100
|
+
- `getAllCommitmentTypes` - Get all commitment types
|
|
101
|
+
- `isCommitmentSupported` - Check if commitment is supported
|
|
102
|
+
|
|
103
|
+
### Collection Management
|
|
104
|
+
- `collectionToJson` - Convert collection to JSON
|
|
105
|
+
- `createCollectionFromJson` - Create collection from JSON data
|
|
106
|
+
- `createCollectionFromPromise` - Create collection from async source
|
|
107
|
+
- `createCollectionFromUrl` - Create collection from URL
|
|
108
|
+
- `createSubcollection` - Create filtered subcollection
|
|
109
|
+
|
|
110
|
+
### Configuration Constants
|
|
111
|
+
- `NAME` - Project name
|
|
112
|
+
- `ADMIN_EMAIL` - Administrator email
|
|
113
|
+
- `ADMIN_GITHUB_NAME` - GitHub username
|
|
114
|
+
- `CLAIM` - Project claim/tagline
|
|
115
|
+
- `DEFAULT_BOOK_TITLE` - Default book title
|
|
116
|
+
- `DEFAULT_TASK_TITLE` - Default task title
|
|
117
|
+
- `DEFAULT_PROMPT_TASK_TITLE` - Default prompt task title
|
|
118
|
+
- `DEFAULT_BOOK_OUTPUT_PARAMETER_NAME` - Default output parameter name
|
|
119
|
+
- `DEFAULT_MAX_FILE_SIZE` - Maximum file size limit
|
|
120
|
+
- `BIG_DATASET_TRESHOLD` - Threshold for large datasets
|
|
121
|
+
- `FAILED_VALUE_PLACEHOLDER` - Placeholder for failed values
|
|
122
|
+
- `PENDING_VALUE_PLACEHOLDER` - Placeholder for pending values
|
|
123
|
+
- `MAX_FILENAME_LENGTH` - Maximum filename length
|
|
124
|
+
- `DEFAULT_INTERMEDIATE_FILES_STRATEGY` - Strategy for intermediate files
|
|
125
|
+
- `DEFAULT_MAX_PARALLEL_COUNT` - Maximum parallel executions
|
|
126
|
+
- `DEFAULT_MAX_EXECUTION_ATTEMPTS` - Maximum execution attempts
|
|
127
|
+
- `DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH` - Knowledge scraping depth limit
|
|
128
|
+
- `DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL` - Knowledge scraping total limit
|
|
129
|
+
- `DEFAULT_BOOKS_DIRNAME` - Default books directory name
|
|
130
|
+
- `DEFAULT_DOWNLOAD_CACHE_DIRNAME` - Default download cache directory
|
|
131
|
+
- `DEFAULT_EXECUTION_CACHE_DIRNAME` - Default execution cache directory
|
|
132
|
+
- `DEFAULT_SCRAPE_CACHE_DIRNAME` - Default scrape cache directory
|
|
133
|
+
- `CLI_APP_ID` - CLI application identifier
|
|
134
|
+
- `PLAYGROUND_APP_ID` - Playground application identifier
|
|
135
|
+
- `DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME` - Default collection filename
|
|
136
|
+
- `DEFAULT_REMOTE_SERVER_URL` - Default remote server URL
|
|
137
|
+
- `DEFAULT_CSV_SETTINGS` - Default CSV parsing settings
|
|
138
|
+
- `DEFAULT_IS_VERBOSE` - Default verbosity setting
|
|
139
|
+
- `SET_IS_VERBOSE` - Verbosity setter
|
|
140
|
+
- `DEFAULT_IS_AUTO_INSTALLED` - Default auto-install setting
|
|
141
|
+
- `DEFAULT_TASK_SIMULATED_DURATION_MS` - Default task simulation duration
|
|
142
|
+
- `DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME` - Default collection function name
|
|
143
|
+
- `DEFAULT_MAX_REQUESTS_PER_MINUTE` - Rate limiting configuration
|
|
144
|
+
- `API_REQUEST_TIMEOUT` - API request timeout
|
|
145
|
+
- `PROMPTBOOK_LOGO_URL` - Official logo URL
|
|
146
|
+
|
|
147
|
+
### Model and Provider Constants
|
|
148
|
+
- `MODEL_TRUST_LEVELS` - Trust levels for different models
|
|
149
|
+
- `MODEL_ORDERS` - Ordering preferences for models
|
|
150
|
+
- `ORDER_OF_PIPELINE_JSON` - JSON property ordering
|
|
151
|
+
- `RESERVED_PARAMETER_NAMES` - Reserved parameter names
|
|
152
|
+
|
|
153
|
+
### Pipeline Processing
|
|
154
|
+
- `compilePipeline` - Compile pipeline from source
|
|
155
|
+
- `parsePipeline` - Parse pipeline definition
|
|
156
|
+
- `pipelineJsonToString` - Convert pipeline JSON to string
|
|
157
|
+
- `prettifyPipelineString` - Format pipeline string
|
|
158
|
+
- `extractParameterNamesFromTask` - Extract parameter names
|
|
159
|
+
- `validatePipeline` - Validate pipeline structure
|
|
160
|
+
|
|
161
|
+
### Dialog and Interface Tools
|
|
162
|
+
- `CallbackInterfaceTools` - Callback-based interface tools
|
|
163
|
+
- `CallbackInterfaceToolsOptions` - Options for callback tools (type)
|
|
164
|
+
|
|
165
|
+
### Error Handling
|
|
166
|
+
- `BoilerplateError` - Base error class
|
|
167
|
+
- `PROMPTBOOK_ERRORS` - All error types registry
|
|
168
|
+
- `AbstractFormatError` - Abstract format validation error
|
|
169
|
+
- `AuthenticationError` - Authentication failure error
|
|
170
|
+
- `CollectionError` - Collection-related error
|
|
171
|
+
- `EnvironmentMismatchError` - Environment compatibility error
|
|
172
|
+
- `ExpectError` - Expectation validation error
|
|
173
|
+
- `KnowledgeScrapeError` - Knowledge scraping error
|
|
174
|
+
- `LimitReachedError` - Resource limit error
|
|
175
|
+
- `MissingToolsError` - Missing tools error
|
|
176
|
+
- `NotFoundError` - Resource not found error
|
|
177
|
+
- `NotYetImplementedError` - Feature not implemented error
|
|
178
|
+
- `ParseError` - Parsing error
|
|
179
|
+
- `PipelineExecutionError` - Pipeline execution error
|
|
180
|
+
- `PipelineLogicError` - Pipeline logic error
|
|
181
|
+
- `PipelineUrlError` - Pipeline URL error
|
|
182
|
+
- `PromptbookFetchError` - Fetch operation error
|
|
183
|
+
- `UnexpectedError` - Unexpected error
|
|
184
|
+
- `WrappedError` - Wrapped error container
|
|
185
|
+
|
|
186
|
+
### Execution Engine
|
|
187
|
+
- `createPipelineExecutor` - Create pipeline executor
|
|
188
|
+
- `computeCosineSimilarity` - Compute cosine similarity for embeddings
|
|
189
|
+
- `embeddingVectorToString` - Convert embedding vector to string
|
|
190
|
+
- `executionReportJsonToString` - Convert execution report to string
|
|
191
|
+
- `ExecutionReportStringOptions` - Report formatting options (type)
|
|
192
|
+
- `ExecutionReportStringOptionsDefaults` - Default report options
|
|
193
|
+
|
|
194
|
+
### Usage and Metrics
|
|
195
|
+
- `addUsage` - Add usage metrics
|
|
196
|
+
- `isPassingExpectations` - Check if expectations are met
|
|
197
|
+
- `ZERO_VALUE` - Zero usage value constant
|
|
198
|
+
- `UNCERTAIN_ZERO_VALUE` - Uncertain zero value constant
|
|
199
|
+
- `ZERO_USAGE` - Zero usage object
|
|
200
|
+
- `UNCERTAIN_USAGE` - Uncertain usage object
|
|
201
|
+
- `usageToHuman` - Convert usage to human-readable format
|
|
202
|
+
- `usageToWorktime` - Convert usage to work time estimate
|
|
203
|
+
|
|
204
|
+
### Format Parsers
|
|
205
|
+
- `CsvFormatError` - CSV format error
|
|
206
|
+
- `CsvFormatParser` - CSV format parser
|
|
207
|
+
- `MANDATORY_CSV_SETTINGS` - Required CSV settings
|
|
208
|
+
- `TextFormatParser` - Text format parser
|
|
209
|
+
|
|
210
|
+
### Form Factor Definitions
|
|
211
|
+
- `BoilerplateFormfactorDefinition` - Boilerplate form factor
|
|
212
|
+
- `ChatbotFormfactorDefinition` - Chatbot form factor
|
|
213
|
+
- `CompletionFormfactorDefinition` - Completion form factor
|
|
214
|
+
- `GeneratorFormfactorDefinition` - Generator form factor
|
|
215
|
+
- `GenericFormfactorDefinition` - Generic form factor
|
|
216
|
+
- `ImageGeneratorFormfactorDefinition` - Image generator form factor
|
|
217
|
+
- `FORMFACTOR_DEFINITIONS` - All form factor definitions
|
|
218
|
+
- `MatcherFormfactorDefinition` - Matcher form factor
|
|
219
|
+
- `SheetsFormfactorDefinition` - Sheets form factor
|
|
220
|
+
- `TranslatorFormfactorDefinition` - Translator form factor
|
|
221
|
+
|
|
222
|
+
### LLM Provider Integration
|
|
223
|
+
- `filterModels` - Filter available models
|
|
224
|
+
- `$llmToolsMetadataRegister` - LLM tools metadata registry
|
|
225
|
+
- `$llmToolsRegister` - LLM tools registry
|
|
226
|
+
- `createLlmToolsFromConfiguration` - Create tools from config
|
|
227
|
+
- `cacheLlmTools` - Cache LLM tools
|
|
228
|
+
- `countUsage` - Count total usage
|
|
229
|
+
- `limitTotalUsage` - Limit total usage
|
|
230
|
+
- `joinLlmExecutionTools` - Join multiple LLM tools
|
|
231
|
+
- `MultipleLlmExecutionTools` - Multiple LLM tools container
|
|
232
|
+
|
|
233
|
+
### Provider Registrations
|
|
234
|
+
- `_AnthropicClaudeMetadataRegistration` - Anthropic Claude registration
|
|
235
|
+
- `_AzureOpenAiMetadataRegistration` - Azure OpenAI registration
|
|
236
|
+
- `_DeepseekMetadataRegistration` - Deepseek registration
|
|
237
|
+
- `_GoogleMetadataRegistration` - Google registration
|
|
238
|
+
- `_OllamaMetadataRegistration` - Ollama registration
|
|
239
|
+
- `_OpenAiMetadataRegistration` - OpenAI registration
|
|
240
|
+
- `_OpenAiAssistantMetadataRegistration` - OpenAI Assistant registration
|
|
241
|
+
- `_OpenAiCompatibleMetadataRegistration` - OpenAI Compatible registration
|
|
242
|
+
|
|
243
|
+
### Pipeline Management
|
|
244
|
+
- `migratePipeline` - Migrate pipeline to newer version
|
|
245
|
+
- `preparePersona` - Prepare persona for execution
|
|
246
|
+
- `book` - Book notation utilities
|
|
247
|
+
- `isValidPipelineString` - Validate pipeline string
|
|
248
|
+
- `GENERIC_PIPELINE_INTERFACE` - Generic pipeline interface
|
|
249
|
+
- `getPipelineInterface` - Get pipeline interface
|
|
250
|
+
- `isPipelineImplementingInterface` - Check interface implementation
|
|
251
|
+
- `isPipelineInterfacesEqual` - Compare pipeline interfaces
|
|
252
|
+
- `EXPECTATION_UNITS` - Units for expectations
|
|
253
|
+
- `validatePipelineString` - Validate pipeline string format
|
|
254
|
+
|
|
255
|
+
### Pipeline Preparation
|
|
256
|
+
- `isPipelinePrepared` - Check if pipeline is prepared
|
|
257
|
+
- `preparePipeline` - Prepare pipeline for execution
|
|
258
|
+
- `unpreparePipeline` - Unprepare pipeline
|
|
259
|
+
|
|
260
|
+
### Remote Server Integration
|
|
261
|
+
- `identificationToPromptbookToken` - Convert ID to token
|
|
262
|
+
- `promptbookTokenToIdentification` - Convert token to ID
|
|
263
|
+
|
|
264
|
+
### Knowledge Scraping
|
|
265
|
+
- `_BoilerplateScraperMetadataRegistration` - Boilerplate scraper registration
|
|
266
|
+
- `prepareKnowledgePieces` - Prepare knowledge pieces
|
|
267
|
+
- `$scrapersMetadataRegister` - Scrapers metadata registry
|
|
268
|
+
- `$scrapersRegister` - Scrapers registry
|
|
269
|
+
- `makeKnowledgeSourceHandler` - Create knowledge source handler
|
|
270
|
+
- `promptbookFetch` - Fetch with promptbook context
|
|
271
|
+
- `_LegacyDocumentScraperMetadataRegistration` - Legacy document scraper
|
|
272
|
+
- `_DocumentScraperMetadataRegistration` - Document scraper registration
|
|
273
|
+
- `_MarkdownScraperMetadataRegistration` - Markdown scraper registration
|
|
274
|
+
- `_MarkitdownScraperMetadataRegistration` - Markitdown scraper registration
|
|
275
|
+
- `_PdfScraperMetadataRegistration` - PDF scraper registration
|
|
276
|
+
- `_WebsiteScraperMetadataRegistration` - Website scraper registration
|
|
277
|
+
|
|
278
|
+
### Storage Backends
|
|
279
|
+
- `BlackholeStorage` - Blackhole storage (discards data)
|
|
280
|
+
- `MemoryStorage` - In-memory storage
|
|
281
|
+
- `PrefixStorage` - Prefixed storage wrapper
|
|
282
|
+
|
|
283
|
+
### Type Definitions
|
|
284
|
+
- `MODEL_VARIANTS` - Available model variants
|
|
285
|
+
- `NonTaskSectionTypes` - Non-task section types
|
|
286
|
+
- `SectionTypes` - All section types
|
|
287
|
+
- `TaskTypes` - Task types
|
|
288
|
+
|
|
289
|
+
### Server Configuration
|
|
290
|
+
- `REMOTE_SERVER_URLS` - Remote server URLs
|
|
54
291
|
|
|
55
292
|
> 💡 This package does not make sense on its own, look at [all promptbook packages](#-packages) or just install all by `npm i ptbk`
|
|
56
293
|
|
package/esm/index.es.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
|
-
import parserHtml from 'prettier/parser-html';
|
|
3
|
-
import parserMarkdown from 'prettier/parser-markdown';
|
|
4
|
-
import { format } from 'prettier/standalone';
|
|
5
2
|
import { randomBytes } from 'crypto';
|
|
6
3
|
import { Subject } from 'rxjs';
|
|
7
4
|
import { forTime } from 'waitasecond';
|
|
@@ -28,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
25
|
* @generated
|
|
29
26
|
* @see https://github.com/webgptorg/promptbook
|
|
30
27
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-1';
|
|
32
29
|
/**
|
|
33
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1895,6 +1892,7 @@ function isValidFilePath(filename) {
|
|
|
1895
1892
|
/**
|
|
1896
1893
|
* Tests if given string is valid URL.
|
|
1897
1894
|
*
|
|
1895
|
+
* Note: [🔂] This function is idempotent.
|
|
1898
1896
|
* Note: Dataurl are considered perfectly valid.
|
|
1899
1897
|
* Note: There are two similar functions:
|
|
1900
1898
|
* - `isValidUrl` which tests any URL
|
|
@@ -2481,8 +2479,18 @@ function validatePipelineString(pipelineString) {
|
|
|
2481
2479
|
* @private withing the package because of HUGE size of prettier dependency
|
|
2482
2480
|
*/
|
|
2483
2481
|
function prettifyMarkdown(content) {
|
|
2482
|
+
// In browser/Next.js environments, just return the original content
|
|
2483
|
+
// since prettier parsers are not available and would cause bundling issues
|
|
2484
|
+
if (typeof window !== 'undefined') {
|
|
2485
|
+
return content;
|
|
2486
|
+
}
|
|
2484
2487
|
try {
|
|
2485
|
-
|
|
2488
|
+
// Use dynamic require to avoid static imports that cause bundling issues
|
|
2489
|
+
// This will only work in Node.js environments
|
|
2490
|
+
const prettierStandalone = eval('require')('prettier/standalone');
|
|
2491
|
+
const parserMarkdown = eval('require')('prettier/parser-markdown');
|
|
2492
|
+
const parserHtml = eval('require')('prettier/parser-html');
|
|
2493
|
+
return prettierStandalone.format(content, {
|
|
2486
2494
|
parser: 'markdown',
|
|
2487
2495
|
plugins: [parserMarkdown, parserHtml],
|
|
2488
2496
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
@@ -2510,6 +2518,8 @@ function prettifyMarkdown(content) {
|
|
|
2510
2518
|
/**
|
|
2511
2519
|
* Makes first letter of a string uppercase
|
|
2512
2520
|
*
|
|
2521
|
+
* Note: [🔂] This function is idempotent.
|
|
2522
|
+
*
|
|
2513
2523
|
* @public exported from `@promptbook/utils`
|
|
2514
2524
|
*/
|
|
2515
2525
|
function capitalize(word) {
|
|
@@ -2812,6 +2822,7 @@ function checkSerializableAsJson(options) {
|
|
|
2812
2822
|
/**
|
|
2813
2823
|
* Creates a deep clone of the given object
|
|
2814
2824
|
*
|
|
2825
|
+
* Note: [🔂] This function is idempotent.
|
|
2815
2826
|
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
2816
2827
|
*
|
|
2817
2828
|
* @param objectValue The object to clone.
|
|
@@ -5863,6 +5874,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
5863
5874
|
/**
|
|
5864
5875
|
* Removes diacritic marks (accents) from characters in a string.
|
|
5865
5876
|
*
|
|
5877
|
+
* Note: [🔂] This function is idempotent.
|
|
5878
|
+
*
|
|
5866
5879
|
* @param input The string containing diacritics to be normalized.
|
|
5867
5880
|
* @returns The string with diacritics removed or normalized.
|
|
5868
5881
|
* @public exported from `@promptbook/utils`
|
|
@@ -7414,6 +7427,8 @@ function $getGlobalScope() {
|
|
|
7414
7427
|
/**
|
|
7415
7428
|
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
7416
7429
|
*
|
|
7430
|
+
* Note: [🔂] This function is idempotent.
|
|
7431
|
+
*
|
|
7417
7432
|
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
7418
7433
|
* @returns The normalized text in SCREAMING_CASE format.
|
|
7419
7434
|
* @example 'HELLO_WORLD'
|
|
@@ -7469,6 +7484,8 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
7469
7484
|
/**
|
|
7470
7485
|
* Normalizes a text string to snake_case format.
|
|
7471
7486
|
*
|
|
7487
|
+
* Note: [🔂] This function is idempotent.
|
|
7488
|
+
*
|
|
7472
7489
|
* @param text The text string to be converted to snake_case format.
|
|
7473
7490
|
* @returns The normalized text in snake_case format.
|
|
7474
7491
|
* @example 'hello_world'
|
|
@@ -7785,6 +7802,8 @@ function mimeTypeToExtension(value) {
|
|
|
7785
7802
|
/**
|
|
7786
7803
|
* Removes emojis from a string and fix whitespaces
|
|
7787
7804
|
*
|
|
7805
|
+
* Note: [🔂] This function is idempotent.
|
|
7806
|
+
*
|
|
7788
7807
|
* @param text with emojis
|
|
7789
7808
|
* @returns text without emojis
|
|
7790
7809
|
* @public exported from `@promptbook/utils`
|
|
@@ -8874,6 +8893,7 @@ const EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRA
|
|
|
8874
8893
|
/**
|
|
8875
8894
|
* Function parseNumber will parse number from string
|
|
8876
8895
|
*
|
|
8896
|
+
* Note: [🔂] This function is idempotent.
|
|
8877
8897
|
* Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
|
|
8878
8898
|
* Note: it also works only with decimal numbers
|
|
8879
8899
|
*
|
|
@@ -9136,6 +9156,7 @@ function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
|
|
|
9136
9156
|
/**
|
|
9137
9157
|
* Removes quotes from a string
|
|
9138
9158
|
*
|
|
9159
|
+
* Note: [🔂] This function is idempotent.
|
|
9139
9160
|
* Tip: This is very useful for post-processing of the result of the LLM model
|
|
9140
9161
|
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
9141
9162
|
* Note: There are two similar functions:
|
|
@@ -12174,6 +12195,8 @@ function createMarkdownChart(options) {
|
|
|
12174
12195
|
* Function escapeMarkdownBlock will escape markdown block if needed
|
|
12175
12196
|
* It is useful when you want have block in block
|
|
12176
12197
|
*
|
|
12198
|
+
* Note: [🔂] This function is idempotent.
|
|
12199
|
+
*
|
|
12177
12200
|
* @public exported from `@promptbook/markdown-utils`
|
|
12178
12201
|
*/
|
|
12179
12202
|
function escapeMarkdownBlock(value) {
|