@promptbook/openai 0.45.0 → 0.46.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 CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Library to supercharge your use of large language models
4
4
 
5
- <!--Badges-->
6
- <!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src/workflows/800-badges/badges.ts so every manual change will be overwritten.-->
5
+
6
+
7
7
 
8
8
  [![License of 📖 Prompt book](https://img.shields.io/github/license/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/blob/main/LICENSE)
9
9
  [![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)
10
10
  [![Issues](https://img.shields.io/github/issues/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/issues)
11
11
  [![Socket Badge](https://socket.dev/api/badge/npm/package/@promptbook/openai)](https://socket.dev/npm/package/@promptbook/openai)
12
12
 
13
- <!--/Badges-->
13
+
14
14
 
15
15
  ## 📦 Package `@promptbook/openai`
16
16
 
@@ -25,17 +25,14 @@ npm i @promptbook/openai
25
25
 
26
26
  Wrapper around [OpenAI's SDK](https://www.npmjs.com/package/openai) to make it easier to use inside Promptbooks.
27
27
 
28
- <!-- Link Simillar wrappers -->
28
+
29
29
 
30
30
 
31
31
  ---
32
32
 
33
33
  Rest of the documentation is common for **entire promptbook ecosystem**:
34
34
 
35
- <!--
36
- TODO: Probbably remove this section only in packages
37
- > ⚠ Warning: This library is still in early development.
38
- -->
35
+
39
36
 
40
37
  ## 🤍 Whitepaper
41
38
 
@@ -78,13 +75,13 @@ In any of these situations, but especially in (3), the Promptbook library can ma
78
75
  - Multiple promptbooks forms a library which will become a **part of your application codebase**.
79
76
  - Theese promptbooks are designed such as they **can be written by non-programmers**.
80
77
 
81
- <!-- TODO: [🧠] Make some more clear escaping -->
78
+
82
79
 
83
80
  ### Sample:
84
81
 
85
82
  File `write-website-content.ptbk.md`:
86
83
 
87
- <!------------------------[ Sample: ]------------------------>
84
+
88
85
 
89
86
  > # 🌍 Create website content
90
87
  >
@@ -255,7 +252,7 @@ File `write-website-content.ptbk.md`:
255
252
  >
256
253
  > `-> {content}`
257
254
 
258
- <!------------------------[ /Sample ]------------------------>
255
+
259
256
 
260
257
  Following is the scheme how the promptbook above is executed:
261
258
 
@@ -308,15 +305,27 @@ _Note: We are using [postprocessing functions](#postprocessing-functions) like `
308
305
 
309
306
  ## 📦 Packages
310
307
 
311
- This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook):
308
+ This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
309
+ You can install all of them at once:
310
+
311
+ ```bash
312
+ npm i ptbk
313
+ ```
312
314
 
313
- <!--[🔠]-->
315
+ Or you can install them separately:
314
316
 
317
+
318
+
319
+
320
+ - ⭐ **[ptbk](https://www.npmjs.com/package/@promptbook/core)** - Bundle of all packages, when you want to install everything and you don't care about the size
321
+ - **[promptbook](https://www.npmjs.com/package/@promptbook/core)** - Just alias for `ptbk`
315
322
  - **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks
316
- - ⭐ **[@promptbook/utils](https://www.npmjs.com/package/@promptbook/utils)** - Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs
323
+ - ⭐ **[@promptbook/utils](https://www.npmjs.com/package/@promptbook/utils)** - Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs
317
324
  - _(Not finished)_ **[@promptbook/wizzard](https://www.npmjs.com/package/@promptbook/wizzard)** - Wizard for creating+running promptbooks in single line
318
325
  - **[@promptbook/execute-javascript](https://www.npmjs.com/package/@promptbook/execute-javascript)** - Execution tools for javascript inside promptbooks
319
326
  - **[@promptbook/openai](https://www.npmjs.com/package/@promptbook/openai)** - Execution tools for OpenAI API, wrapper around OpenAI SDK
327
+ - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
328
+ - **[@promptbook/mock](https://www.npmjs.com/package/@promptbook/mock)** - Mocked execution tools for testing the library and saving the tokens
320
329
  - **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks
321
330
  - **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks
322
331
  - **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
@@ -488,7 +497,7 @@ There are [postprocessing functions](#postprocessing-functions) that can be used
488
497
 
489
498
  - _(Not implemented yet)_ `ConsoleInterfaceTools` is a wrapper around `readline` module that interacts with the user via console.
490
499
  - `SimplePromptInterfaceTools` is a wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt. It is used for testing and mocking **NOT intended to use in the production** due to its synchronous nature.
491
- - `CallbackInterfaceTools` delagates the user interaction to a async callback function. You need to provide your own implementation of this callback function and its bind to UI. <!-- <- TODO: Provide here a way how to do it with some our plugin -->
500
+ - `CallbackInterfaceTools` delagates the user interaction to a async callback function. You need to provide your own implementation of this callback function and its bind to UI.
492
501
 
493
502
  ### Executor
494
503
 
@@ -558,10 +567,7 @@ There are two types of expectations which are not strictly symmetrical:
558
567
 
559
568
  Look at [expectations.ptbk.md](samples/templates/45-expectations.ptbk.md) and [expect-json.ptbk.md](samples/templates/45-expect-json.ptbk.md) samples for more.
560
569
 
561
- <!--
562
- ### New
563
- [🥻] Insert here when making new command
564
- -->
570
+
565
571
 
566
572
  ### Execution report
567
573
 
@@ -569,7 +575,7 @@ Execution report is a simple object or markdown that contains information about
569
575
 
570
576
  [See the example of such a report](/samples/templates/50-advanced.report.md)
571
577
 
572
- <!-- TODO: Write more -->
578
+
573
579
 
574
580
  ### Remote server
575
581
 
@@ -580,23 +586,7 @@ This is useful to make all logic on browser side but not expose your API keys or
580
586
 
581
587
  ## 👨‍💻 Usage and integration _(for developers)_
582
588
 
583
- <!--
584
-
585
- TODO: [🧙‍♂️]
586
-
587
- ### 🧙‍♂️ Using wizzard
588
-
589
- First you need to install this library:
590
-
591
- ```bash
592
- npm install --save @promptbook/wizzard
593
- ```
594
-
595
- > TODO: !! Write the Wizzard sample
596
-
597
- [Usage samples](./samples/usage/)
598
589
 
599
- -->
600
590
 
601
591
  ### 🔌 Usage in Typescript / Javascript
602
592
 
@@ -621,11 +611,11 @@ npm install --save @promptbook/wizzard
621
611
 
622
612
  ## 🐜 Known issues
623
613
 
624
- <!-- TODO: -->
614
+
625
615
 
626
616
  ## 🧼 Intentionally not implemented features
627
617
 
628
- <!-- TODO: -->
618
+
629
619
 
630
620
  ## ❔ FAQ
631
621
 
@@ -641,42 +631,17 @@ Langchain is primarily aimed at ML developers working in Python. This library is
641
631
 
642
632
  We are considering creating a bridge/converter between these two libraries.
643
633
 
644
- <!--
645
634
 
646
- ==========
647
- Include:
648
- - Langchain is the python library and JavaScript is on second place
649
- - Langchain primarily focused on making templates, not on combining templates into larger structures
650
- - at the language level it distinguishes between chat and completion, I need to mix the two into one template pipeline
651
- - for a non-programmer it's quite hard to work with such a thing and write templates - I would much prefer a system that allows non-technical people to write templates (of which there are many more on the market than free pythonists)
652
- - The focus of promptbooks is primarily on building user applications, not the data processing, training or autogpt.
653
- -->
654
635
 
655
636
  ### Promptbooks vs. OpenAI`s GPTs
656
637
 
657
638
  GPTs are chat assistants that can be assigned to specific tasks and materials. But they are still chat assistants. Promptbooks are a way to orchestrate many more predefined tasks to have much tighter control over the process. Promptbooks are not a good technology for creating human-like chatbots, GPTs are not a good technology for creating outputs with specific requirements.
658
639
 
659
- <!--
660
- TODO:
661
- ### Promptbooks vs. Semantic Kernel
662
-
663
640
 
664
- -->
665
641
 
666
- <!--
667
- TODO: !
668
- ### Promptbooks vs. Langtail
669
642
 
670
643
 
671
- -->
672
644
 
673
- <!--
674
- TODO:
675
- ### Promptbooks vs. Evidentally AI
676
-
677
- Logging and monitoring
678
-
679
- -->
680
645
 
681
646
  ### Where should I store my promptbooks?
682
647
 
@@ -698,34 +663,10 @@ In large language models, you will get better results if you have prompts in the
698
663
 
699
664
  The best way to manage this is to have suffixed promptbooks like `write-website-content.en.ptbk.md` and `write-website-content.cs.ptbk.md` for each supported language.
700
665
 
701
- <!--
702
- TODO: (Maybe)
703
- ### Why you need to explicitly specify input and output parameters?
704
- -->
705
-
706
- <!--
707
-
708
-
709
666
 
710
- !
711
667
 
712
668
 
713
669
 
714
- unit testing
715
-
716
- escaping
717
-
718
- how i get block into prompt
719
-
720
-
721
- ## 🚷 Limitations
722
-
723
- function calling
724
- system message
725
- iterations
726
-
727
- -->
728
-
729
670
  ## ⌚ Changelog
730
671
 
731
672
  See [CHANGELOG.md](./CHANGELOG.md)
@@ -734,13 +675,11 @@ See [CHANGELOG.md](./CHANGELOG.md)
734
675
 
735
676
  <p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://github.com/webgptorg/promptbook">Promptbook</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://github.com/hejny/">Pavol Hejný</a> is licensed under <a href="https://creativecommons.org/licenses/by/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">CC BY 4.0</a></p>
736
677
 
737
- <!--Contributing-->
738
- <!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src/workflows/810-contributing/contributing.ts so every manual change will be overwritten.-->
678
+
679
+
739
680
 
740
681
  ## 🖋️ Contributing
741
682
 
742
683
  I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [☕ buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).
743
684
 
744
- You can also ⭐ star the promptbook package, [follow me on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).
745
-
746
- <!--/Contributing-->
685
+ You can also ⭐ star the promptbook package, [follow me on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).
@@ -1,8 +1,6 @@
1
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
2
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
- import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
5
- import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
6
4
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
7
5
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
8
6
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
@@ -16,6 +14,5 @@ export { ExecutionTypes, PROMPTBOOK_VERSION };
16
14
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
17
15
  export { SimplePromptInterfaceTools };
18
16
  export { promptbookStringToJson, validatePromptbookJson };
19
- export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
20
17
  export { createPromptbookExecutor };
21
18
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -0,0 +1,3 @@
1
+ import { LangtailExecutionTools } from '../execution/plugins/natural-execution-tools/langtail/LangtailExecutionTools';
2
+ import { LangtailExecutionToolsOptions } from '../execution/plugins/natural-execution-tools/langtail/LangtailExecutionToolsOptions';
3
+ export { LangtailExecutionTools, LangtailExecutionToolsOptions };
@@ -0,0 +1,6 @@
1
+ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
2
+ import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
3
+ export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
4
+ /**
5
+ * TODO: [🚏] FakeLLM
6
+ */
@@ -0,0 +1,11 @@
1
+ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionToolsOptions';
2
+ /**
3
+ * Options for LangtailExecutionTools
4
+ *
5
+ * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
6
+ * Rest is used by the `OpenAiExecutionTools`.
7
+ */
8
+ export type LangtailExecutionToolsOptions = OpenAiExecutionToolsOptions;
9
+ /**
10
+ * TODO: !!! Use or remove
11
+ */
@@ -10,6 +10,6 @@ import { PostprocessingFunction } from '../../script-execution-tools/javascript/
10
10
  */
11
11
  export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
12
12
  /**
13
- * TODO: Implement better - create FakeLLM from this
13
+ * TODO: [🚏] Implement better - create FakeLLM from this
14
14
  * TODO: [💝] Unite object for expecting amount and format - use here also a format
15
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.45.0",
3
+ "version": "0.46.0-1",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "openai": "4.2.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@promptbook/core": "0.45.0"
41
+ "@promptbook/core": "0.46.0-1"
42
42
  },
43
43
  "main": "./umd/index.umd.js",
44
44
  "module": "./esm/index.es.js",
@@ -1,8 +1,6 @@
1
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
2
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
- import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
5
- import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
6
4
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
7
5
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
8
6
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
@@ -16,6 +14,5 @@ export { ExecutionTypes, PROMPTBOOK_VERSION };
16
14
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
17
15
  export { SimplePromptInterfaceTools };
18
16
  export { promptbookStringToJson, validatePromptbookJson };
19
- export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
20
17
  export { createPromptbookExecutor };
21
18
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -0,0 +1,3 @@
1
+ import { LangtailExecutionTools } from '../execution/plugins/natural-execution-tools/langtail/LangtailExecutionTools';
2
+ import { LangtailExecutionToolsOptions } from '../execution/plugins/natural-execution-tools/langtail/LangtailExecutionToolsOptions';
3
+ export { LangtailExecutionTools, LangtailExecutionToolsOptions };
@@ -0,0 +1,6 @@
1
+ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
2
+ import { MockedFackedNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedFackedNaturalExecutionTools';
3
+ export { MockedEchoNaturalExecutionTools, MockedFackedNaturalExecutionTools };
4
+ /**
5
+ * TODO: [🚏] FakeLLM
6
+ */
@@ -0,0 +1,11 @@
1
+ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionToolsOptions';
2
+ /**
3
+ * Options for LangtailExecutionTools
4
+ *
5
+ * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
6
+ * Rest is used by the `OpenAiExecutionTools`.
7
+ */
8
+ export type LangtailExecutionToolsOptions = OpenAiExecutionToolsOptions;
9
+ /**
10
+ * TODO: !!! Use or remove
11
+ */
@@ -10,6 +10,6 @@ import { PostprocessingFunction } from '../../script-execution-tools/javascript/
10
10
  */
11
11
  export declare function $fakeTextToExpectations(expectations: Expectations, postprocessing?: Array<PostprocessingFunction>): Promise<string>;
12
12
  /**
13
- * TODO: Implement better - create FakeLLM from this
13
+ * TODO: [🚏] Implement better - create FakeLLM from this
14
14
  * TODO: [💝] Unite object for expecting amount and format - use here also a format
15
15
  */