@promptbook/types 0.86.10 → 0.86.22

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
@@ -166,9 +166,7 @@ And **Promptbook.city** branded socials:
166
166
  _/Sub-brand for images and graphics generated via Promptbook prompting/_
167
167
 
168
168
  - [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
169
- - [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
170
-
171
- ##
169
+ - [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
172
170
 
173
171
 
174
172
 
@@ -179,7 +177,9 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
179
177
 
180
178
 
181
179
 
182
- Following is the documentation and blueprint of the Book language.
180
+ Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
181
+
182
+ Book is a language that can be used to write AI applications, agents, workflows, automations, knowledgebases, translators, sheet processors, email automations and more. It allows you to harness the power of AI models in human-like terms, without the need to know the specifics and technicalities of the models.
183
183
 
184
184
  ### Example
185
185
 
@@ -187,35 +187,56 @@ Following is the documentation and blueprint of the Book language.
187
187
  # 🌟 My first Book
188
188
 
189
189
  - BOOK VERSION 1.0.0
190
- - URL https://promptbook.studio/my-first-book/
190
+ - URL https://promptbook.studio/hello.book
191
+ - INPUT PARAMETER {topic}
192
+ - OUTPUT PARAMETER {article}
191
193
 
192
194
  # Write an article
193
195
 
194
196
  - PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
195
- - KNOWLEDGE https://ptbk.io
196
- - KNOWLEDGE ./promptbook.pdf
197
+ - KNOWLEDGE https://wikipedia.org/
198
+ - KNOWLEDGE ./journalist-ethics.pdf
197
199
  - EXPECT MIN 1 Sentence
198
- - EXPECT MAX 1 Paragraph
200
+ - EXPECT MAX 5 Pages
199
201
 
200
- > Write an article about the future of artificial intelligence in the next 10 years and how metalanguages will change the way AI is used in the world.
201
- > Look specifically at the impact of Promptbook on the AI industry.
202
+ > Write an article about {topic}
202
203
 
203
204
  -> {article}
204
205
  ```
205
206
 
207
+ Each part of the book defines one of 3 circles:
208
+
206
209
  ### **What:** Workflows, Tasks and Parameters
207
210
 
211
+ What work needs to be done. Each book defines a workflow, which is one or more tasks. Each workflow has a fixed input and output. For example, you have a book that generates an article from a topic. Once it generates an article about AI, once about marketing, once about cooking. The workflow (= your AI program) is the same, only the input and output change.
212
+
213
+ **Related commands:**
214
+
208
215
  - [PARAMETER](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PARAMETER.md)
209
216
 
210
217
  ### **Who:** Personas
211
218
 
219
+ Who does the work. Each task is performed by a persona. A persona is a description of your virtual employee. It is a higher abstraction than the model, tokens, temperature, top-k, top-p and other model parameters.
220
+
221
+ You can describe what you want in human language like `Jane, creative writer with a sense of sharp humour` instead of `gpt-4-2024-13-31, temperature 1.2, top-k 40, STOP token ".\n",...`.
222
+
223
+ Personas can have access to different knowledge, tools and actions. They can also consult their work with other personas or user, if allowed.
224
+
225
+ **Related commands:**
226
+
212
227
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
213
228
 
229
+
230
+
214
231
  ### **How:** Knowledge, Instruments and Actions
215
232
 
216
- - [KNOWLEDGE](https://github.com/webgptorg/promptbook/blob/main/documents/commands/KNOWLEDGE.md)
217
- - [INSTRUMENT](https://github.com/webgptorg/promptbook/blob/main/documents/commands/INSTRUMENT.md)
218
- - [ACTION](https://github.com/webgptorg/promptbook/blob/main/documents/commands/ACTION.md)
233
+ The resources used by the personas are used to do the work.
234
+
235
+ **Related commands:**
236
+
237
+ - [KNOWLEDGE](https://github.com/webgptorg/promptbook/blob/main/documents/commands/KNOWLEDGE.md) of documents, websites, and other resources
238
+ - [INSTRUMENT](https://github.com/webgptorg/promptbook/blob/main/documents/commands/INSTRUMENT.md) for real-time data like time, location, weather, stock prices, searching the internet, calculations, etc.
239
+ - [ACTION](https://github.com/webgptorg/promptbook/blob/main/documents/commands/ACTION.md) for actions like sending emails, creating files, ending a workflow, etc.
219
240
 
220
241
  ### General principles of book language
221
242
 
@@ -306,35 +327,7 @@ The following glossary is used to clarify certain concepts:
306
327
 
307
328
  _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
308
329
 
309
- #### Promptbook core
310
-
311
- - **Organization** _(legacy name collection)_ group jobs, workforce, knowledge, instruments, and actions into one package. Entities in one organization can share resources (= import resources from each other).
312
- - **Jobs**
313
- - **Task**
314
- - **Subtask**
315
- - **Workforce**
316
- - **Persona**
317
- - **Team**
318
- - **Role**
319
- - **Knowledge**
320
- - **Public**
321
- - **Private**
322
- - **Protected**
323
- - **Instruments**
324
- - **Actions**
325
-
326
- #### Book language
327
-
328
- - **Book file**
329
- - **Section**
330
- - **Heading**
331
- - **Description**
332
- - **Command**
333
- - **Block**
334
- - **Return statement**
335
- - **Comment**
336
- - **Import**
337
- - **Scope**
330
+
338
331
 
339
332
  #### 💯 Core concepts
340
333
 
@@ -178,6 +178,7 @@ import type { string_css } from '../types/typeAliases';
178
178
  import type { string_svg } from '../types/typeAliases';
179
179
  import type { string_script } from '../types/typeAliases';
180
180
  import type { string_javascript } from '../types/typeAliases';
181
+ import type { string_typescript } from '../types/typeAliases';
181
182
  import type { string_json } from '../types/typeAliases';
182
183
  import type { string_css_class } from '../types/typeAliases';
183
184
  import type { string_css_property } from '../types/typeAliases';
@@ -459,6 +460,7 @@ export type { string_css };
459
460
  export type { string_svg };
460
461
  export type { string_script };
461
462
  export type { string_javascript };
463
+ export type { string_typescript };
462
464
  export type { string_json };
463
465
  export type { string_css_class };
464
466
  export type { string_css_property };
@@ -1,14 +1,14 @@
1
1
  import type { string_javascript } from '../../types/typeAliases';
2
- import type { string_javascript_name } from '../../types/typeAliases';
2
+ import type { string_typescript } from '../../types/typeAliases';
3
3
  /**
4
- * Parses the given script and returns the list of all used variables that are not defined in the script
4
+ * Extract all used variable names from ginen JavaScript/TypeScript script
5
5
  *
6
- * @param script from which to extract the variables
7
- * @returns the list of variable names
6
+ * @param script JavaScript/TypeScript script
7
+ * @returns Set of variable names
8
8
  * @throws {ParseError} if the script is invalid
9
9
  * @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
10
10
  */
11
- export declare function extractVariablesFromScript(script: string_javascript): Set<string_javascript_name>;
11
+ export declare function extractVariablesFromScript(script: string_javascript | string_typescript): Set<string>;
12
12
  /**
13
13
  * TODO: [🔣] Support for multiple languages - python, java,...
14
14
  */
@@ -7,15 +7,15 @@ import type { ErrorJson } from '../errors/utils/ErrorJson';
7
7
  */
8
8
  export type AbstractTaskResult = {
9
9
  /**
10
- * Whether the execution was successful, details are aviable in `executionReport`
10
+ * Whether the execution was successful, details are available in `executionReport`
11
11
  */
12
12
  readonly isSuccessful: boolean;
13
13
  /**
14
- * Errors that occured during the execution, details are aviable in `executionReport`
14
+ * Errors that occured during the execution, details are available in `executionReport`
15
15
  */
16
16
  readonly errors: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
17
17
  /**
18
- * Warnings that occured during the execution, details are aviable in `executionReport`
18
+ * Warnings that occured during the execution, details are available in `executionReport`
19
19
  */
20
20
  readonly warnings: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
21
21
  };
@@ -17,7 +17,7 @@ export type PipelineExecutorResult = AbstractTaskResult & {
17
17
  */
18
18
  readonly outputParameters: Readonly<Parameters>;
19
19
  /**
20
- * Added usage of whole execution, detailed usage is aviable in `executionReport`
20
+ * Added usage of whole execution, detailed usage is available in `executionReport`
21
21
  */
22
22
  readonly usage: ReadonlyDeep<PromptResultUsage>;
23
23
  /**
@@ -1,11 +1,21 @@
1
1
  import type { string_markdown } from '../../types/typeAliases';
2
2
  import type { PromptResultUsage } from '../PromptResultUsage';
3
+ import type { UncertainNumber } from '../UncertainNumber';
4
+ /**
5
+ * Minimal usage information required to calculate worktime
6
+ */
7
+ type PartialPromptResultUsage = Partial<PromptResultUsage> & {
8
+ price: UncertainNumber;
9
+ input: Pick<PromptResultUsage['input'], 'wordsCount'>;
10
+ output: Pick<PromptResultUsage['output'], 'wordsCount' | 'charactersCount'>;
11
+ };
3
12
  /**
4
13
  * Function `usageToHuman` will take usage and convert it to human readable report
5
14
  *
6
15
  * @public exported from `@promptbook/core`
7
16
  */
8
- export declare function usageToHuman(usage: PromptResultUsage): string_markdown;
17
+ export declare function usageToHuman(usage: PartialPromptResultUsage): string_markdown;
18
+ export {};
9
19
  /**
10
20
  * TODO: [🍓][🧞‍♂️] Use "$1" not "1 USD"
11
21
  * TODO: [🍓][🧞‍♂️] Use markdown formatting like "Cost approximately **$1**"
@@ -1,5 +1,12 @@
1
1
  import type { PromptResultUsage } from '../PromptResultUsage';
2
2
  import type { UncertainNumber } from '../UncertainNumber';
3
+ /**
4
+ * Minimal usage information required to calculate worktime
5
+ */
6
+ type PartialPromptResultUsage = Pick<PromptResultUsage, 'input' | 'output'> & {
7
+ input: Pick<PromptResultUsage['input'], 'wordsCount'>;
8
+ output: Pick<PromptResultUsage['output'], 'wordsCount'>;
9
+ };
3
10
  /**
4
11
  * Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
5
12
  *
@@ -9,4 +16,5 @@ import type { UncertainNumber } from '../UncertainNumber';
9
16
  *
10
17
  * @public exported from `@promptbook/core`
11
18
  */
12
- export declare function usageToWorktime(usage: PromptResultUsage): UncertainNumber;
19
+ export declare function usageToWorktime(usage: PartialPromptResultUsage): UncertainNumber;
20
+ export {};
@@ -64,7 +64,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
64
64
  * TODO: [♏] Add some prepare hook to modify prompt according to the format
65
65
  * TODO: [🍓]`name` and `aliases` should be UPPERCASE only and interpreted as case-insensitive (via normalization)
66
66
  * TODO: [🍓][👨‍⚖️] Compute TPartialValue dynamically - PartialString<TValue>
67
- * TODO: [🍓][🧠] Should execution tools be aviable to heal, canBeValid and isValid?
67
+ * TODO: [🍓][🧠] Should execution tools be available to heal, canBeValid and isValid?
68
68
  * TODO: [🍓][🧠] llm Provider Bindings
69
69
  * TODO: [🍓][🔼] Export via some package
70
70
  */
@@ -10,7 +10,7 @@ import type { FormatDefinition } from '../_common/FormatDefinition';
10
10
  export declare const TextFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
11
11
  /**
12
12
  * TODO: [1] Make type for XML Text and Schema
13
- * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
13
+ * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
14
14
  * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
15
15
  * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
16
16
  * TODO: [🍓] In `TextFormatDefinition` implement `heal
@@ -57,7 +57,7 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
57
57
  callCommonModel(prompt: Prompt): Promise<PromptResult>;
58
58
  }
59
59
  /**
60
- * TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first aviable model BUT all of them
60
+ * TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first available model BUT all of them
61
61
  * TODO: [🏖] If no llmTools have for example not defined `callCompletionModel` this will still return object with defined `callCompletionModel` which just throws `PipelineExecutionError`, make it undefined instead
62
62
  * Look how `countTotalUsage` (and `cacheLlmTools`) implements it
63
63
  */
@@ -272,6 +272,12 @@ export type string_script = string;
272
272
  * For example `console.info("Hello World!")`
273
273
  */
274
274
  export type string_javascript = string;
275
+ /**
276
+ * Semantic helper
277
+ *
278
+ * For example `console.info("Hello World!" as string)`
279
+ */
280
+ export type string_typescript = string;
275
281
  /**
276
282
  * Semantic helper for JSON strings
277
283
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/types",
3
- "version": "0.86.10",
3
+ "version": "0.86.22",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -45,6 +45,6 @@
45
45
  "homepage": "https://ptbk.io/",
46
46
  "typings": "./esm/typings/src/_packages/types.index.d.ts",
47
47
  "peerDependencies": {
48
- "@promptbook/core": "0.86.10"
48
+ "@promptbook/core": "0.86.22"
49
49
  }
50
50
  }