@promptbook/remote-server 0.47.0 โ†’ 0.48.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.
Files changed (44) hide show
  1. package/README.md +12 -1
  2. package/esm/index.es.js +1 -1
  3. package/esm/typings/_packages/core.index.d.ts +2 -1
  4. package/esm/typings/_packages/utils.index.d.ts +2 -1
  5. package/esm/typings/conversion/prettify/prettifyPromptbookStringCli.d.ts +1 -1
  6. package/esm/typings/conversion/promptbookJsonToString.d.ts +8 -0
  7. package/esm/typings/conversion/utils/titleToName.d.ts +4 -0
  8. package/esm/typings/conversion/utils/titleToName.test.d.ts +1 -0
  9. package/esm/typings/execution/ExecutionTools.d.ts +1 -1
  10. package/esm/typings/execution/LlmExecutionTools.d.ts +1 -0
  11. package/esm/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +1 -1
  12. package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +1 -1
  13. package/esm/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +4 -1
  14. package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +1 -0
  15. package/esm/typings/library/SimplePromptbookLibrary.d.ts +2 -1
  16. package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +10 -1
  17. package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +20 -1
  18. package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +5 -6
  19. package/esm/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +13 -0
  20. package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +10 -1
  21. package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  22. package/package.json +2 -2
  23. package/umd/index.umd.js +1 -1
  24. package/umd/typings/_packages/core.index.d.ts +2 -1
  25. package/umd/typings/_packages/utils.index.d.ts +2 -1
  26. package/umd/typings/conversion/prettify/prettifyPromptbookStringCli.d.ts +1 -1
  27. package/umd/typings/conversion/promptbookJsonToString.d.ts +8 -0
  28. package/umd/typings/conversion/utils/titleToName.d.ts +4 -0
  29. package/umd/typings/conversion/utils/titleToName.test.d.ts +1 -0
  30. package/umd/typings/execution/ExecutionTools.d.ts +1 -1
  31. package/umd/typings/execution/LlmExecutionTools.d.ts +1 -0
  32. package/umd/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +1 -1
  33. package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +1 -1
  34. package/umd/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +4 -1
  35. package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +1 -0
  36. package/umd/typings/library/SimplePromptbookLibrary.d.ts +2 -1
  37. package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +10 -1
  38. package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +20 -1
  39. package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +5 -6
  40. package/umd/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +13 -0
  41. package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +10 -1
  42. package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
  43. package/esm/typings/library/constructors/createPromptbookLibraryFromList.d.ts +0 -5
  44. package/umd/typings/library/constructors/createPromptbookLibraryFromList.d.ts +0 -5
package/README.md CHANGED
@@ -5,13 +5,13 @@ Library to supercharge your use of large language models
5
5
 
6
6
 
7
7
 
8
-
9
8
  [![NPM Version of ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
10
9
  [![Quality of package ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
11
10
  [![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)
12
11
  [![Issues](https://img.shields.io/github/issues/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/issues)
13
12
  [![Socket](https://socket.dev/api/badge/npm/package/promptbook)](https://socket.dev/npm/package/promptbook)
14
13
 
14
+
15
15
  [![Socket Badge](https://socket.dev/api/badge/npm/package/@promptbook/remote-server)](https://socket.dev/npm/package/@promptbook/remote-server)
16
16
 
17
17
 
@@ -651,6 +651,17 @@ GPTs are chat assistants that can be assigned to specific tasks and materials. B
651
651
 
652
652
 
653
653
 
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
654
665
  ### Where should I store my promptbooks?
655
666
 
656
667
  If you use raw SDKs, you just put prompts in the sourcecode, mixed in with typescript, javascript, python or whatever programming language you use.
package/esm/index.es.js CHANGED
@@ -89,7 +89,7 @@ var PromptbookExecutionError = /** @class */ (function (_super) {
89
89
  /**
90
90
  * The version of the Promptbook library
91
91
  */
92
- var PROMPTBOOK_VERSION = '0.47.0-0';
92
+ var PROMPTBOOK_VERSION = '0.48.0-0';
93
93
 
94
94
  /**
95
95
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -1,4 +1,5 @@
1
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
+ import { promptbookJsonToString } from '../conversion/promptbookJsonToString';
2
3
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
4
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
5
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
@@ -13,6 +14,6 @@ import { PROMPTBOOK_VERSION } from '../version';
13
14
  export { ExecutionTypes, PROMPTBOOK_VERSION };
14
15
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
15
16
  export { SimplePromptInterfaceTools };
16
- export { promptbookStringToJson, validatePromptbookJson };
17
+ export { promptbookStringToJson, promptbookJsonToString, validatePromptbookJson };
17
18
  export { createPromptbookExecutor };
18
19
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -2,6 +2,7 @@ import { spaceTrim } from 'spacetrim';
2
2
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
3
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
4
  import { parseNumber } from '../conversion/utils/parseNumber';
5
+ import { titleToName } from '../conversion/utils/titleToName';
5
6
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
6
7
  import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
7
8
  import { replaceParameters } from '../execution/utils/replaceParameters';
@@ -56,7 +57,7 @@ export declare const normalizeTo: {
56
57
  snake_case: typeof normalizeTo_snake_case;
57
58
  'kebab-case': typeof normalizeToKebabCase;
58
59
  };
59
- export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
60
+ export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, titleToName, };
60
61
  export { renderPromptbookMermaid };
61
62
  /**
62
63
  * TODO: [๐Ÿง ] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
@@ -1,5 +1,5 @@
1
1
  /**
2
- * !!! Initialize
2
+ * Runs CLI script for prettifying promptbooks
3
3
  */
4
4
  export declare function prettifyPromptbookStringCli(): Promise<void>;
5
5
  /**
@@ -0,0 +1,8 @@
1
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
2
+ import type { PromptbookString } from '../types/PromptbookString';
3
+ export declare function promptbookJsonToString(promptbookJson: PromptbookJson): PromptbookString;
4
+ /**
5
+ * TODO: !!!!! Implement
6
+ * TODO: !!!!! Annotate and warn
7
+ * TODO: !!!!! Test + test together with promptbookStringToJson
8
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Function normalizes title to name which can be used as identifier
3
+ */
4
+ export declare function titleToName(value: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -24,5 +24,5 @@ export type ExecutionTools = {
24
24
  userInterface: UserInterfaceTools;
25
25
  };
26
26
  /**
27
- * TODO: !!!! Allow more
27
+ * TODO: [๐Ÿ“] !!!! Allow to have more LlmExecutionTools
28
28
  */
@@ -18,6 +18,7 @@ export type LlmExecutionTools = {
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  };
20
20
  /**
21
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
21
22
  * TODO: [๐Ÿณ] gptChat -> chat, gptComplete -> complete, translate
22
23
  * TODO: [๐Ÿง ] Should or should not there be a word "GPT" in both gptComplete and gptChat
23
24
  */
@@ -6,5 +6,5 @@ import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
6
6
  export declare class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
7
7
  }
8
8
  /**
9
- * TODO: !!! Make lib which exports this
9
+ * TODO: [๐Ÿ“][โ™] Allow to list the aviable prompts in Langtail
10
10
  */
@@ -27,7 +27,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
27
27
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
28
28
  }
29
29
  /**
30
-
30
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
31
31
  * TODO: Maybe Create some common util for gptChat and gptComplete
32
32
  * TODO: Maybe make custom OpenaiError
33
33
  */
@@ -1,8 +1,11 @@
1
1
  import type OpenAI from 'openai';
2
2
  import type { PromptResult } from '../../../PromptResult';
3
3
  /**
4
- * !!!
4
+ * Computes the usage of the OpenAI API based on the response from OpenAI
5
5
  *
6
6
  * @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
7
7
  */
8
8
  export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage'];
9
+ /**
10
+ * TODO: [๐Ÿ“] Make better
11
+ */
@@ -31,5 +31,6 @@ export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
31
31
  private gptCommon;
32
32
  }
33
33
  /**
34
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
34
35
  * TODO: [๐Ÿคนโ€โ™‚๏ธ] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
35
36
  */
@@ -10,7 +10,8 @@ import { PromptbookLibrary } from './PromptbookLibrary';
10
10
  */
11
11
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
12
12
  private library;
13
- /**!!!
13
+ /**
14
+ * Constructs a promptbook library from promptbooks
14
15
  *
15
16
  * @param promptbooks !!!
16
17
  *
@@ -1,5 +1,14 @@
1
1
  import { PromptbookLibrary } from '../PromptbookLibrary';
2
+ /**
3
+ * Constructs Promptbook from given directory
4
+ *
5
+ * Note: Works only in Node.js environment because it reads the file system
6
+ * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
7
+ * SO during the construction syntax and logic sources IS NOT validated
8
+ *
9
+ * @returns PromptbookLibrary
10
+ */
2
11
  export declare function createPromptbookLibraryFromDirectory(): PromptbookLibrary;
3
12
  /***
4
- * TODO: !!! Annotate all + all to README and samples
13
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
5
14
  */
@@ -1,7 +1,26 @@
1
1
  import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
2
  import { PromptbookString } from '../../types/PromptbookString';
3
3
  import { PromptbookLibrary } from '../PromptbookLibrary';
4
+ /**
5
+ * Constructs Promptbook from async sources
6
+ * It can be one of the following:
7
+ * - Promise of array of PromptbookJson or PromptbookString
8
+ * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
9
+ *
10
+ * Note: This is useful as internal tool for other constructor functions like
11
+ * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
12
+ * Consider using those functions instead of this one
13
+ *
14
+ * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
+ * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
+ *
17
+ *
18
+ * @param promptbookSourcesPromiseOrFactory
19
+ * @returns PromptbookLibrary
20
+ *
21
+ * @deprecated Consider using `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
22
+ */
4
23
  export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
5
24
  /***
6
- * TODO: !!! Annotate all + all to README and samples
25
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
7
26
  */
@@ -1,16 +1,15 @@
1
1
  import { PromptbookJson, PromptbookString } from '../../_packages/types.index';
2
2
  import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
- export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
4
3
  /**
5
- * Constructs Promptbook from any sources
4
+ * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
6
5
  *
6
+ * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
7
7
  * Note: During the construction syntax and logic of all sources are validated
8
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
9
8
  *
10
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
11
- * @param settings settings for creating executor functions
9
+ * @param promptbookSources
12
10
  * @returns PromptbookLibrary
13
11
  */
12
+ export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
14
13
  /***
15
- * TODO: !!! Annotate all + all to README and samples
14
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
16
15
  */
@@ -0,0 +1,13 @@
1
+ import { PromptbookLibrary } from '../PromptbookLibrary';
2
+ /**
3
+ * Constructs Promptbook from remote Promptbase URL
4
+ *
5
+ * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
6
+ * SO during the construction syntax and logic sources IS NOT validated
7
+ *
8
+ * @returns PromptbookLibrary
9
+ */
10
+ export declare function createPromptbookLibraryFromUrl(): PromptbookLibrary;
11
+ /***
12
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
13
+ */
@@ -1,6 +1,15 @@
1
1
  import type { string_promptbook_url } from '../../types/typeAliases';
2
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Creates PromptbookLibrary as a subset of another PromptbookLibrary
5
+ *
6
+ * Note: You can use any type of library as a parent library - local, remote, etc.
7
+ * Note: This is just a thin wrapper / proxy around the parent library
8
+ *
9
+ * @param promptbookSources
10
+ * @returns PromptbookLibrary
11
+ */
3
12
  export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
4
13
  /***
5
- * TODO: !!! Annotate all + all to README and samples
14
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
6
15
  */
@@ -15,5 +15,5 @@ import { CodeBlock } from './extractAllBlocksFromMarkdown';
15
15
  */
16
16
  export declare function extractOneBlockFromMarkdown(markdown: string_markdown): CodeBlock;
17
17
  /***
18
- * TODO: [๐ŸŒป] !!! Decide of this is internal util, external util OR validator/postprocessor
18
+ * TODO: [๐Ÿ“][๐ŸŒป] !!! Decide of this is internal util, external util OR validator/postprocessor
19
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.47.0",
3
+ "version": "0.48.0-1",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -49,7 +49,7 @@
49
49
  }
50
50
  ],
51
51
  "peerDependencies": {
52
- "@promptbook/core": "0.47.0"
52
+ "@promptbook/core": "0.48.0-1"
53
53
  },
54
54
  "main": "./umd/index.umd.js",
55
55
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -95,7 +95,7 @@
95
95
  /**
96
96
  * The version of the Promptbook library
97
97
  */
98
- var PROMPTBOOK_VERSION = '0.47.0-0';
98
+ var PROMPTBOOK_VERSION = '0.48.0-0';
99
99
 
100
100
  /**
101
101
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -1,4 +1,5 @@
1
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
2
+ import { promptbookJsonToString } from '../conversion/promptbookJsonToString';
2
3
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
3
4
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
4
5
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
@@ -13,6 +14,6 @@ import { PROMPTBOOK_VERSION } from '../version';
13
14
  export { ExecutionTypes, PROMPTBOOK_VERSION };
14
15
  export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
15
16
  export { SimplePromptInterfaceTools };
16
- export { promptbookStringToJson, validatePromptbookJson };
17
+ export { promptbookStringToJson, promptbookJsonToString, validatePromptbookJson };
17
18
  export { createPromptbookExecutor };
18
19
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -2,6 +2,7 @@ import { spaceTrim } from 'spacetrim';
2
2
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
3
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
4
  import { parseNumber } from '../conversion/utils/parseNumber';
5
+ import { titleToName } from '../conversion/utils/titleToName';
5
6
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
6
7
  import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
7
8
  import { replaceParameters } from '../execution/utils/replaceParameters';
@@ -56,7 +57,7 @@ export declare const normalizeTo: {
56
57
  snake_case: typeof normalizeTo_snake_case;
57
58
  'kebab-case': typeof normalizeToKebabCase;
58
59
  };
59
- export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
60
+ export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, titleToName, };
60
61
  export { renderPromptbookMermaid };
61
62
  /**
62
63
  * TODO: [๐Ÿง ] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
@@ -1,5 +1,5 @@
1
1
  /**
2
- * !!! Initialize
2
+ * Runs CLI script for prettifying promptbooks
3
3
  */
4
4
  export declare function prettifyPromptbookStringCli(): Promise<void>;
5
5
  /**
@@ -0,0 +1,8 @@
1
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
2
+ import type { PromptbookString } from '../types/PromptbookString';
3
+ export declare function promptbookJsonToString(promptbookJson: PromptbookJson): PromptbookString;
4
+ /**
5
+ * TODO: !!!!! Implement
6
+ * TODO: !!!!! Annotate and warn
7
+ * TODO: !!!!! Test + test together with promptbookStringToJson
8
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Function normalizes title to name which can be used as identifier
3
+ */
4
+ export declare function titleToName(value: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -24,5 +24,5 @@ export type ExecutionTools = {
24
24
  userInterface: UserInterfaceTools;
25
25
  };
26
26
  /**
27
- * TODO: !!!! Allow more
27
+ * TODO: [๐Ÿ“] !!!! Allow to have more LlmExecutionTools
28
28
  */
@@ -18,6 +18,7 @@ export type LlmExecutionTools = {
18
18
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
19
19
  };
20
20
  /**
21
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
21
22
  * TODO: [๐Ÿณ] gptChat -> chat, gptComplete -> complete, translate
22
23
  * TODO: [๐Ÿง ] Should or should not there be a word "GPT" in both gptComplete and gptChat
23
24
  */
@@ -6,5 +6,5 @@ import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
6
6
  export declare class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
7
7
  }
8
8
  /**
9
- * TODO: !!! Make lib which exports this
9
+ * TODO: [๐Ÿ“][โ™] Allow to list the aviable prompts in Langtail
10
10
  */
@@ -27,7 +27,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
27
27
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
28
28
  }
29
29
  /**
30
-
30
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
31
31
  * TODO: Maybe Create some common util for gptChat and gptComplete
32
32
  * TODO: Maybe make custom OpenaiError
33
33
  */
@@ -1,8 +1,11 @@
1
1
  import type OpenAI from 'openai';
2
2
  import type { PromptResult } from '../../../PromptResult';
3
3
  /**
4
- * !!!
4
+ * Computes the usage of the OpenAI API based on the response from OpenAI
5
5
  *
6
6
  * @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
7
7
  */
8
8
  export declare function computeOpenaiUsage(rawResponse: Pick<OpenAI.Chat.Completions.ChatCompletion | OpenAI.Completions.Completion, 'model' | 'usage'>): PromptResult['usage'];
9
+ /**
10
+ * TODO: [๐Ÿ“] Make better
11
+ */
@@ -31,5 +31,6 @@ export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
31
31
  private gptCommon;
32
32
  }
33
33
  /**
34
+ * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
34
35
  * TODO: [๐Ÿคนโ€โ™‚๏ธ] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
35
36
  */
@@ -10,7 +10,8 @@ import { PromptbookLibrary } from './PromptbookLibrary';
10
10
  */
11
11
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
12
12
  private library;
13
- /**!!!
13
+ /**
14
+ * Constructs a promptbook library from promptbooks
14
15
  *
15
16
  * @param promptbooks !!!
16
17
  *
@@ -1,5 +1,14 @@
1
1
  import { PromptbookLibrary } from '../PromptbookLibrary';
2
+ /**
3
+ * Constructs Promptbook from given directory
4
+ *
5
+ * Note: Works only in Node.js environment because it reads the file system
6
+ * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
7
+ * SO during the construction syntax and logic sources IS NOT validated
8
+ *
9
+ * @returns PromptbookLibrary
10
+ */
2
11
  export declare function createPromptbookLibraryFromDirectory(): PromptbookLibrary;
3
12
  /***
4
- * TODO: !!! Annotate all + all to README and samples
13
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
5
14
  */
@@ -1,7 +1,26 @@
1
1
  import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
2
  import { PromptbookString } from '../../types/PromptbookString';
3
3
  import { PromptbookLibrary } from '../PromptbookLibrary';
4
+ /**
5
+ * Constructs Promptbook from async sources
6
+ * It can be one of the following:
7
+ * - Promise of array of PromptbookJson or PromptbookString
8
+ * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
9
+ *
10
+ * Note: This is useful as internal tool for other constructor functions like
11
+ * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
12
+ * Consider using those functions instead of this one
13
+ *
14
+ * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
+ * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
+ *
17
+ *
18
+ * @param promptbookSourcesPromiseOrFactory
19
+ * @returns PromptbookLibrary
20
+ *
21
+ * @deprecated Consider using `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
22
+ */
4
23
  export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
5
24
  /***
6
- * TODO: !!! Annotate all + all to README and samples
25
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
7
26
  */
@@ -1,16 +1,15 @@
1
1
  import { PromptbookJson, PromptbookString } from '../../_packages/types.index';
2
2
  import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
- export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
4
3
  /**
5
- * Constructs Promptbook from any sources
4
+ * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
6
5
  *
6
+ * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
7
7
  * Note: During the construction syntax and logic of all sources are validated
8
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
9
8
  *
10
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
11
- * @param settings settings for creating executor functions
9
+ * @param promptbookSources
12
10
  * @returns PromptbookLibrary
13
11
  */
12
+ export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
14
13
  /***
15
- * TODO: !!! Annotate all + all to README and samples
14
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
16
15
  */
@@ -0,0 +1,13 @@
1
+ import { PromptbookLibrary } from '../PromptbookLibrary';
2
+ /**
3
+ * Constructs Promptbook from remote Promptbase URL
4
+ *
5
+ * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
6
+ * SO during the construction syntax and logic sources IS NOT validated
7
+ *
8
+ * @returns PromptbookLibrary
9
+ */
10
+ export declare function createPromptbookLibraryFromUrl(): PromptbookLibrary;
11
+ /***
12
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
13
+ */
@@ -1,6 +1,15 @@
1
1
  import type { string_promptbook_url } from '../../types/typeAliases';
2
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Creates PromptbookLibrary as a subset of another PromptbookLibrary
5
+ *
6
+ * Note: You can use any type of library as a parent library - local, remote, etc.
7
+ * Note: This is just a thin wrapper / proxy around the parent library
8
+ *
9
+ * @param promptbookSources
10
+ * @returns PromptbookLibrary
11
+ */
3
12
  export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
4
13
  /***
5
- * TODO: !!! Annotate all + all to README and samples
14
+ * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
6
15
  */
@@ -15,5 +15,5 @@ import { CodeBlock } from './extractAllBlocksFromMarkdown';
15
15
  */
16
16
  export declare function extractOneBlockFromMarkdown(markdown: string_markdown): CodeBlock;
17
17
  /***
18
- * TODO: [๐ŸŒป] !!! Decide of this is internal util, external util OR validator/postprocessor
18
+ * TODO: [๐Ÿ“][๐ŸŒป] !!! Decide of this is internal util, external util OR validator/postprocessor
19
19
  */
@@ -1,5 +0,0 @@
1
- import { PromptbookLibrary } from '../PromptbookLibrary';
2
- export declare function createPromptbookLibraryFromList(): PromptbookLibrary;
3
- /***
4
- * TODO: !!! Annotate all + all to README and samples
5
- */
@@ -1,5 +0,0 @@
1
- import { PromptbookLibrary } from '../PromptbookLibrary';
2
- export declare function createPromptbookLibraryFromList(): PromptbookLibrary;
3
- /***
4
- * TODO: !!! Annotate all + all to README and samples
5
- */