@promptbook/types 0.67.0-2 โ†’ 0.67.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
@@ -65,37 +65,23 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
65
65
 
66
66
  ## ๐Ÿค The Promptbook Whitepaper
67
67
 
68
- When you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, or whatever, it doesn't matter how it is integrated. Whether it's the direct calling of a REST API, using the SDK, hardcoding the prompt in the source code, or importing a text file, the process remains the same.
68
+ If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
69
69
 
70
- If you need something more advanced or want to extend the capabilities of LLMs, you generally have three ways to proceed:
70
+ But often you will struggle with the limitations of LLMs, such as hallucinations, off-topic responses, poor quality output, language drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w๐’†๐ขrd responses. When this happens, you generally have three options:
71
71
 
72
72
  1. **Fine-tune** the model to your specifications or even train your own.
73
73
  2. **Prompt-engineer** the prompt to the best shape you can achieve.
74
- 3. Use **multiple prompts** in a pipeline to get the best result.
75
-
76
- In any of these situations, but especially in (3), the Promptbook library can make your life easier and make **orchestraror for your prompts**.
77
-
78
- - **Separation of concerns** between prompt engineer and programmer; between code files and prompt files; and between prompts and their execution logic.
79
- - Set up a **common format** for prompts that is interchangeable between projects and language/technology stacks.
80
- - **Preprocessing** and cleaning the input data from the user.
81
- - Use default values - **Jokers** to bypass some parts of the pipeline.
82
- - **Expect** some specific output from the model.
83
- - **Retry** mismatched outputs.
84
- - **Combine** multiple models together.
85
- - Interactive **User interaction** with the model and the user.
86
- - Leverage **external** sources (like ChatGPT plugins or OpenAI's GPTs).
87
- - Simplify your code to be **DRY** and not repeat all the boilerplate code for each prompt.
88
- - **Versioning** of promptbooks
89
- - **Reuse** parts of promptbooks in/between projects.
90
- - Run the LLM **optimally** in parallel, with the best _cost/quality_ ratio or _speed/quality_ ratio.
91
- - **Execution report** to see what happened during the execution.
92
- - **Logging** the results of the promptbooks.
93
- - _(Not ready yet)_ **Caching** calls to LLMs to save money and time.
94
- - _(Not ready yet)_ Extend one prompt book from another one.
95
- - _(Not ready yet)_ Leverage the **streaming** to make super cool UI/UX.
96
- - _(Not ready yet)_ **A/B testing** to determine which prompt works best for the job.
74
+ 3. Use **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
97
75
 
76
+ In all of these situations, but especially in 3., the Promptbook library can make your life easier.
98
77
 
78
+ - [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic.
79
+ - Establishes a [**common format `.ptbk.md`**](https://github.com/webgptorg/promptbook/discussions/85) that can be used to describe your prompt business logic without having to write code or deal with the technicalities of LLMs.
80
+ - **Forget** about **low-level details** like choosing the right model, tokens, context size, temperature, top-k, top-p, or kernel sampling. **Just write your intent** and [**persona**](https://github.com/webgptorg/promptbook/discussions/22) who should be responsible for the task and let the library do the rest.
81
+ - Has built-in **orchestration** of [pipeline](https://github.com/webgptorg/promptbook/discussions/64) execution and many tools to make the process easier, more reliable, and more efficient, such as caching, [compilation+preparation](https://github.com/webgptorg/promptbook/discussions/78), [just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33), [expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37), [agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39), and more.
82
+ - Sometimes even the best prompts with the best framework like Promptbook `:)` can't avoid the problems. In this case, the library has built-in **[anomaly detection](https://github.com/webgptorg/promptbook/discussions/40) and logging** to help you find and fix the problems.
83
+ - Promptbook has built in versioning. You can test multiple **A/B versions** of pipelines and see which one works best.
84
+ - Promptbook is designed to do [**RAG** (Retrieval-Augmented Generation)](https://github.com/webgptorg/promptbook/discussions/41) and other advanced techniques. You can use **knowledge** to improve the quality of the output.
99
85
 
100
86
  ## ๐Ÿง” Promptbook _(for prompt-engeneers)_
101
87
 
@@ -139,9 +125,7 @@ File `write-website-content.ptbk.md`:
139
125
  >
140
126
  > ## โœจ Improving the title
141
127
  >
142
- > - MODEL VARIANT Chat
143
- > - MODEL NAME `gpt-4`
144
- > - POSTPROCESSING `unwrapResult`
128
+ > - PERSONA Jane, Copywriter and Marketing Specialist.
145
129
  >
146
130
  > ```
147
131
  > As an experienced marketing specialist, you have been entrusted with improving the name of your client's business.
@@ -175,9 +159,7 @@ File `write-website-content.ptbk.md`:
175
159
  >
176
160
  > ## ๐Ÿฐ Cunning subtitle
177
161
  >
178
- > - MODEL VARIANT Chat
179
- > - MODEL NAME `gpt-4`
180
- > - POSTPROCESSING `unwrapResult`
162
+ > - PERSONA Josh, a copywriter, tasked with creating a claim for the website.
181
163
  >
182
164
  > ```
183
165
  > As an experienced copywriter, you have been entrusted with creating a claim for the "{title}" web page.
@@ -197,8 +179,7 @@ File `write-website-content.ptbk.md`:
197
179
  >
198
180
  > ## ๐Ÿšฆ Keyword analysis
199
181
  >
200
- > - MODEL VARIANT Chat
201
- > - MODEL NAME `gpt-4`
182
+ > - PERSONA Paul, extremely creative SEO specialist.
202
183
  >
203
184
  > ```
204
185
  > As an experienced SEO specialist, you have been entrusted with creating keywords for the website "{title}".
@@ -242,8 +223,7 @@ File `write-website-content.ptbk.md`:
242
223
  >
243
224
  > ## ๐Ÿ–‹ Write the content
244
225
  >
245
- > - MODEL VARIANT Completion
246
- > - MODEL NAME `gpt-3.5-turbo-instruct`
226
+ > - PERSONA Jane
247
227
  >
248
228
  > ```
249
229
  > As an experienced copywriter and web designer, you have been entrusted with creating text for a new website {title}.
@@ -422,7 +402,12 @@ The following glossary is used to clarify certain concepts:
422
402
 
423
403
  ### โž– When not to use
424
404
 
425
- - When you are writing just a simple chatbot without any extra logic, just system messages
405
+ - When you have already implemented single simple prompt and it works fine for your job
406
+ - When [OpenAI Assistant (GPTs)](https://help.openai.com/en/articles/8673914-gpts-vs-assistants) is enough for you
407
+ - When you need streaming _(this may be implemented in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/102))_.
408
+ - When you need to use something other than JavaScript or TypeScript _(other languages are on the way, [see the discussion](https://github.com/webgptorg/promptbook/discussions/101))_
409
+ - When your main focus is on something other than text - like images, audio, video, spreadsheets _(other media types may be added in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/103))_
410
+ - When you need to use recursion _([see the discussion](https://github.com/webgptorg/promptbook/discussions/38))_
426
411
 
427
412
  ## ๐Ÿœ Known issues
428
413
 
@@ -431,7 +416,6 @@ The following glossary is used to clarify certain concepts:
431
416
 
432
417
  ## ๐Ÿงผ Intentionally not implemented features
433
418
 
434
-
435
419
  - [โžฟ No recursion](https://github.com/webgptorg/promptbook/discussions/38)
436
420
  - [๐Ÿณ There are no types, just strings](https://github.com/webgptorg/promptbook/discussions/52)
437
421
 
@@ -157,7 +157,7 @@ import type { string_protocol } from '../types/typeAliases';
157
157
  import type { string_email } from '../types/typeAliases';
158
158
  import type { string_emails } from '../types/typeAliases';
159
159
  import type { string_uuid } from '../types/typeAliases';
160
- import type { client_id } from '../types/typeAliases';
160
+ import type { string_user_id } from '../types/typeAliases';
161
161
  import type { string_sha256 } from '../types/typeAliases';
162
162
  import type { string_semantic_version } from '../types/typeAliases';
163
163
  import type { string_version_dependency } from '../types/typeAliases';
@@ -383,7 +383,7 @@ export type { string_protocol };
383
383
  export type { string_email };
384
384
  export type { string_emails };
385
385
  export type { string_uuid };
386
- export type { client_id };
386
+ export type { string_user_id };
387
387
  export type { string_sha256 };
388
388
  export type { string_semantic_version };
389
389
  export type { string_version_dependency };
@@ -30,6 +30,18 @@ export declare const LOOP_LIMIT = 1000;
30
30
  * @private within the repository - too low-level in comparison with other `MAX_...`
31
31
  */
32
32
  export declare const CHARACTER_LOOP_LIMIT = 100000;
33
+ /**
34
+ * Timeout for the connections in milliseconds
35
+ *
36
+ * @private within the repository - too low-level in comparison with other `MAX_...`
37
+ */
38
+ export declare const CONNECTION_TIMEOUT_MS: number;
39
+ /**
40
+ * How many times to retry the connections
41
+ *
42
+ * @private within the repository - too low-level in comparison with other `MAX_...`
43
+ */
44
+ export declare const CONNECTION_RETRIES_LIMIT = 5;
33
45
  /**
34
46
  * The maximum number of (LLM) tasks running in parallel
35
47
  *
@@ -1,4 +1,3 @@
1
- import type { client_id } from '../../../types/typeAliases';
2
1
  import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
3
2
  /**
4
3
  * Socket.io progress for remote text generation
@@ -11,10 +10,6 @@ export type PromptbookServer_ListModels_CollectionRequest = {
11
10
  * Collection mode
12
11
  */
13
12
  isAnonymous: false;
14
- /**
15
- * Client responsible for the requests
16
- */
17
- readonly clientId: client_id;
18
13
  };
19
14
  export type PromptbookServer_ListModels_AnonymousRequest = {
20
15
  /**
@@ -29,6 +24,6 @@ export type PromptbookServer_ListModels_AnonymousRequest = {
29
24
  /**
30
25
  * TODO: [๐Ÿ‘ก] DRY `PromptbookServer_Prompt_Request` and `PromptbookServer_ListModels_Request`
31
26
  * TODO: [๐Ÿง ][๐Ÿ›] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
32
- * TODO: [๐Ÿง ][๐Ÿคบ] Pass `clientId` in `PromptbookServer_ListModels_Request`
27
+ * TODO: [๐Ÿง ][๐Ÿคบ] Pass `userId` in `PromptbookServer_ListModels_Request`
33
28
  * TODO: [๐Ÿ‘’] Listing models (and checking configuration) probbably should go through REST API not Socket.io
34
29
  */
@@ -1,5 +1,5 @@
1
1
  import type { Prompt } from '../../../types/Prompt';
2
- import type { client_id } from '../../../types/typeAliases';
2
+ import type { string_user_id } from '../../../types/typeAliases';
3
3
  import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
4
4
  /**
5
5
  * Socket.io progress for remote text generation
@@ -11,11 +11,14 @@ export type PromptbookServer_Prompt_CollectionRequest = {
11
11
  /**
12
12
  * Collection mode
13
13
  */
14
- isAnonymous: false;
14
+ readonly isAnonymous: false;
15
15
  /**
16
- * Client responsible for the requests
16
+ * Identifier of the end user
17
+ *
18
+ * Note: this is passed to the certain model providers to identify misuse
19
+ * Note: In anonymous mode it is not required to identify
17
20
  */
18
- readonly clientId: client_id;
21
+ readonly userId: string_user_id;
19
22
  /**
20
23
  * The Prompt to execute
21
24
  */
@@ -25,7 +28,14 @@ export type PromptbookServer_Prompt_AnonymousRequest = {
25
28
  /**
26
29
  * Anonymous mode
27
30
  */
28
- isAnonymous: true;
31
+ readonly isAnonymous: true;
32
+ /**
33
+ * Identifier of the end user
34
+ *
35
+ * Note: this is passed to the certain model providers to identify misuse
36
+ * Note: In anonymous mode it is not required to identify
37
+ */
38
+ readonly userId?: string_user_id;
29
39
  /**
30
40
  * Configuration for the LLM tools
31
41
  */
@@ -38,4 +48,4 @@ export type PromptbookServer_Prompt_AnonymousRequest = {
38
48
  /**
39
49
  * TODO: [๐Ÿ‘ก] DRY `PromptbookServer_Prompt_Request` and `PromptbookServer_ListModels_Request`
40
50
  * TODO: [๐Ÿง ][๐Ÿ›] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
41
- */
51
+ */
@@ -1,7 +1,7 @@
1
1
  import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
2
- import type { client_id } from '../../../types/typeAliases';
3
2
  import type { string_base_url } from '../../../types/typeAliases';
4
3
  import type { string_uri } from '../../../types/typeAliases';
4
+ import type { string_user_id } from '../../../types/typeAliases';
5
5
  import type { LlmToolsConfiguration } from '../../_common/LlmToolsConfiguration';
6
6
  /**
7
7
  * Options for `RemoteLlmExecutionTools`
@@ -34,15 +34,24 @@ export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
34
34
  * Configuration for the LLM tools
35
35
  */
36
36
  readonly llmToolsConfiguration: LlmToolsConfiguration;
37
+ /**
38
+ * Identifier of the end user
39
+ *
40
+ * Note: this is passed to the certain model providers to identify misuse
41
+ * Note: In anonymous mode it is not required to identify
42
+ */
43
+ readonly userId?: string_user_id;
37
44
  } | {
38
45
  /**
39
46
  * Use anonymous server with client identification and fixed collection
40
47
  */
41
48
  isAnonymous: false;
42
49
  /**
43
- * Your client ID
50
+ * Identifier of the end user
51
+ *
52
+ * Note: this is passed to the certain model providers to identify misuse
44
53
  */
45
- readonly clientId: client_id;
54
+ readonly userId: string_user_id;
46
55
  });
47
56
  /**
48
57
  * TODO: [๐Ÿง ][๐Ÿ›] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
@@ -1,8 +1,8 @@
1
1
  import type { PipelineCollection } from '../../../collection/PipelineCollection';
2
2
  import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
3
3
  import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
4
- import type { client_id } from '../../../types/typeAliases';
5
4
  import type { string_uri } from '../../../types/typeAliases';
5
+ import type { string_user_id } from '../../../types/typeAliases';
6
6
  /**
7
7
  * @@@
8
8
  *
@@ -50,7 +50,7 @@ export type CollectionRemoteServerOptions = {
50
50
  /**
51
51
  * Creates llm execution tools for each client
52
52
  */
53
- createLlmExecutionTools(clientId: client_id): LlmExecutionTools;
53
+ createLlmExecutionTools(userId: string_user_id | undefined): LlmExecutionTools;
54
54
  };
55
55
  /**
56
56
  * TODO: Constrain anonymous mode for specific models / providers
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env ts-node
2
- export {};
2
+ import '../../openai/register-constructor';
@@ -391,11 +391,9 @@ export type string_uuid = string & {
391
391
  readonly _type: 'uuid';
392
392
  };
393
393
  /**
394
- * Branded type client id
394
+ * End user identifier;
395
395
  */
396
- export type client_id = string & {
397
- readonly _type: 'client_id';
398
- };
396
+ export type string_user_id = string;
399
397
  /**
400
398
  * Semantic helper
401
399
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/types",
3
- "version": "0.67.0-2",
3
+ "version": "0.67.0-4",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -45,6 +45,6 @@
45
45
  ],
46
46
  "typings": "./esm/typings/src/_packages/types.index.d.ts",
47
47
  "peerDependencies": {
48
- "@promptbook/core": "0.67.0-2"
48
+ "@promptbook/core": "0.67.0-4"
49
49
  }
50
50
  }