@promptbook/utils 0.57.2 → 0.58.0

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 (153) hide show
  1. package/esm/index.es.js +20 -20
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/_packages/anthropic-claude.index.d.ts +2 -2
  4. package/esm/typings/_packages/azure-openai.index.d.ts +3 -4
  5. package/esm/typings/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/_packages/execute-javascript.index.d.ts +2 -2
  7. package/esm/typings/_packages/fake-llm.index.d.ts +2 -2
  8. package/esm/typings/_packages/langtail.index.d.ts +3 -4
  9. package/esm/typings/_packages/openai.index.d.ts +4 -5
  10. package/esm/typings/_packages/remote-client.index.d.ts +4 -5
  11. package/esm/typings/_packages/remote-server.index.d.ts +3 -4
  12. package/esm/typings/_packages/types.index.d.ts +69 -8
  13. package/esm/typings/_packages/utils.index.d.ts +6 -4
  14. package/esm/typings/execution/ScriptExecutionTools.d.ts +1 -1
  15. package/esm/typings/formats/_common/FormatDefinition.d.ts +53 -0
  16. package/esm/typings/formats/index.d.ts +4 -0
  17. package/esm/typings/formats/json/JsonFormatDefinition.d.ts +11 -0
  18. package/esm/typings/formats/xml/XmlFormatDefinition.d.ts +11 -0
  19. package/{umd/typings/execution/plugins/user-interface-execution-tools → esm/typings/knowledgebase/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
  20. package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledgebase/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
  21. package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledgebase/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -3
  22. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
  23. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  24. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  25. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
  26. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
  27. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
  28. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +6 -6
  29. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
  30. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
  31. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
  32. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
  33. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +5 -5
  34. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  35. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
  36. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/openai-models.d.ts +2 -2
  37. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
  38. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
  39. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
  40. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
  41. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
  42. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
  43. package/esm/typings/scripting/_test/script-execution-errors.test.d.ts +1 -0
  44. package/esm/typings/scripting/_test/script-execution-tools.test.d.ts +1 -0
  45. package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
  46. package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  47. package/{umd/typings/execution/plugins/script-execution-tools → esm/typings/scripting}/python/PythonExecutionTools.d.ts +3 -3
  48. package/esm/typings/{execution/plugins/script-execution-tools → scripting}/typescript/TypescriptExecutionTools.d.ts +3 -3
  49. package/esm/typings/types/Prompt.d.ts +1 -1
  50. package/package.json +1 -1
  51. package/umd/index.umd.js +20 -20
  52. package/umd/index.umd.js.map +1 -1
  53. package/umd/typings/_packages/anthropic-claude.index.d.ts +2 -2
  54. package/umd/typings/_packages/azure-openai.index.d.ts +3 -4
  55. package/umd/typings/_packages/core.index.d.ts +8 -6
  56. package/umd/typings/_packages/execute-javascript.index.d.ts +2 -2
  57. package/umd/typings/_packages/fake-llm.index.d.ts +2 -2
  58. package/umd/typings/_packages/langtail.index.d.ts +3 -4
  59. package/umd/typings/_packages/openai.index.d.ts +4 -5
  60. package/umd/typings/_packages/remote-client.index.d.ts +4 -5
  61. package/umd/typings/_packages/remote-server.index.d.ts +3 -4
  62. package/umd/typings/_packages/types.index.d.ts +69 -8
  63. package/umd/typings/_packages/utils.index.d.ts +6 -4
  64. package/umd/typings/execution/ScriptExecutionTools.d.ts +1 -1
  65. package/umd/typings/formats/_common/FormatDefinition.d.ts +53 -0
  66. package/umd/typings/formats/index.d.ts +4 -0
  67. package/umd/typings/formats/json/JsonFormatDefinition.d.ts +11 -0
  68. package/umd/typings/formats/json/utils/isValidJsonString.test.d.ts +1 -0
  69. package/umd/typings/formats/xml/XmlFormatDefinition.d.ts +11 -0
  70. package/{esm/typings/execution/plugins/user-interface-execution-tools → umd/typings/knowledgebase/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
  71. package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledgebase/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
  72. package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledgebase/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -3
  73. package/umd/typings/knowledgebase/dialogs/user-interface-execution-tools.test.d.ts +1 -0
  74. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
  75. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  76. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  77. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
  78. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
  79. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
  80. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +6 -6
  81. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
  82. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
  83. package/umd/typings/llm-providers/mocked/fakeTextToExpectations.test.d.ts +1 -0
  84. package/umd/typings/llm-providers/mocked/faked-completion.test.d.ts +1 -0
  85. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
  86. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
  87. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +5 -5
  88. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  89. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
  90. package/umd/typings/llm-providers/openai/computeUsage.test.d.ts +1 -0
  91. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/openai-models.d.ts +2 -2
  92. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
  93. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
  94. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
  95. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
  96. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
  97. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
  98. package/umd/typings/scripting/_test/custom-function-async.test.ts.test.d.ts +1 -0
  99. package/umd/typings/scripting/_test/custom-function-missing.test.d.ts +1 -0
  100. package/umd/typings/scripting/_test/custom-function-with-dependencies.test.d.ts +1 -0
  101. package/umd/typings/scripting/_test/custom-function.test.d.ts +1 -0
  102. package/umd/typings/scripting/_test/postprocessing.test.d.ts +1 -0
  103. package/umd/typings/scripting/_test/script-execution-errors.test.d.ts +1 -0
  104. package/umd/typings/scripting/_test/script-execution-tools.test.d.ts +1 -0
  105. package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
  106. package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  107. package/{esm/typings/execution/plugins/script-execution-tools → umd/typings/scripting}/python/PythonExecutionTools.d.ts +3 -3
  108. package/umd/typings/{execution/plugins/script-execution-tools → scripting}/typescript/TypescriptExecutionTools.d.ts +3 -3
  109. package/umd/typings/types/Prompt.d.ts +1 -1
  110. /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
  111. /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.test.d.ts +0 -0
  112. /package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledgebase/dialogs}/user-interface-execution-tools.test.d.ts +0 -0
  113. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  114. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  115. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  116. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
  117. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.test.d.ts +0 -0
  118. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/faked-completion.test.d.ts +0 -0
  119. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
  120. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  121. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  122. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
  123. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
  124. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.test.d.ts +0 -0
  125. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
  126. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  127. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
  128. /package/{umd/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.test.d.ts → esm/typings/scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
  129. /package/{umd/typings/execution/plugins/llm-execution-tools/mocked/faked-completion.test.d.ts → esm/typings/scripting/_test/custom-function-missing.test.d.ts} +0 -0
  130. /package/{umd/typings/execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts → esm/typings/scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
  131. /package/{umd/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts → esm/typings/scripting/_test/custom-function.test.d.ts} +0 -0
  132. /package/{umd/typings/utils/isValidJsonString.test.d.ts → esm/typings/scripting/_test/postprocessing.test.d.ts} +0 -0
  133. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  134. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  135. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
  136. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
  137. /package/umd/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
  138. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  139. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  140. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  141. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
  142. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
  143. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  144. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  145. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
  146. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
  147. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
  148. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  149. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
  150. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  151. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  152. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
  153. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
@@ -0,0 +1,53 @@
1
+ import type { string_mime_type } from '../../types/typeAliases';
2
+ import type { string_name } from '../../types/typeAliases';
3
+ /**
4
+ * A format definition is a set of functions that define how to validate, heal and convert response from LLM
5
+ *
6
+ * @see https://github.com/webgptorg/promptbook/discussions/36
7
+ */
8
+ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSchema extends object> = {
9
+ /**
10
+ * The name of the format used in .ptbk.md files
11
+ *
12
+ * @sample "JSON"
13
+ */
14
+ readonly name: string_name;
15
+ /**
16
+ * The mime type of the format (if any)
17
+ *
18
+ * @sample "application/json"
19
+ */
20
+ readonly mimeType?: string_mime_type;
21
+ /**
22
+ * Check if a value is fully valid
23
+ *
24
+ * @param value The value to check, for example "{\"foo\": true}"
25
+ * @param schema Optional schema to do extra validation
26
+ */
27
+ isValid(value: string, schema?: TSchema): value is TValue;
28
+ /**
29
+ * Check if a first part of a value is valid
30
+ *
31
+ * @see https://github.com/webgptorg/promptbook/discussions/37
32
+ *
33
+ * @param partialValue Partial value to check, for example "{\"foo\": t"
34
+ * @param schema Optional schema to do extra validation
35
+ */
36
+ canBeValid(partialValue: string, schema?: TSchema): partialValue is TPartialValue;
37
+ /**
38
+ * Heal a value to make it valid if possible
39
+ *
40
+ * Note: This make sense in context of LLMs that often returns slightly invalid values
41
+ * @see https://github.com/webgptorg/promptbook/discussions/31
42
+ *
43
+ * @param value The value to heal, for example "{foo: true}"
44
+ * @param scheme
45
+ * @throws {Error} If the value cannot be healed
46
+ */
47
+ heal(value: string, scheme?: TSchema): TValue;
48
+ };
49
+ /**
50
+ * TODO: [👨‍⚖️] Compute TPartialValue dynamically - PartialString<TValue>
51
+ * TODO: [🧠] Should execution tools be aviable to heal, canBeValid and isValid?
52
+ * TODO: [🧠] llm Provider Bindings
53
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Definitions for all formats supported by Promptbook
3
+ */
4
+ export declare const FORMAT_DEFINITIONS: import("./_common/FormatDefinition").FormatDefinition<string, string, object>[];
@@ -0,0 +1,11 @@
1
+ import type { FormatDefinition } from '../_common/FormatDefinition';
2
+ /**
3
+ * Definition for JSON format
4
+ */
5
+ export declare const JsonFormatDefinition: FormatDefinition<string, string, object>;
6
+ /**
7
+ * TODO: [🧠] Maybe propper instance of object
8
+ * TODO: [0] Make string_serialized_json
9
+ * TODO: [1] Make type for JSON Schema
10
+ * TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
11
+ */
@@ -0,0 +1,11 @@
1
+ import type { FormatDefinition } from '../_common/FormatDefinition';
2
+ /**
3
+ * Definition for XML format
4
+ */
5
+ export declare const XmlFormatDefinition: FormatDefinition<string, string, object>;
6
+ /**
7
+ * TODO: [🧠] Maybe propper instance of object
8
+ * TODO: [0] Make string_serialized_xml
9
+ * TODO: [1] Make type for XML Schema
10
+ * TODO: [🧠] What to use for validating XMLs - XSD,...
11
+ */
@@ -1,5 +1,5 @@
1
- import type { UserInterfaceTools } from '../../../UserInterfaceTools';
2
- import type { UserInterfaceToolsPromptDialogOptions } from '../../../UserInterfaceTools';
1
+ import type { UserInterfaceTools } from '../../../execution/UserInterfaceTools';
2
+ import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/UserInterfaceTools';
3
3
  import type { CallbackInterfaceToolsOptions } from './CallbackInterfaceToolsOptions';
4
4
  /**
5
5
  * Delagates the user interaction to a async callback function
@@ -1,6 +1,6 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
3
- import type { UserInterfaceToolsPromptDialogOptions } from '../../../UserInterfaceTools';
2
+ import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
3
+ import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/UserInterfaceTools';
4
4
  /**
5
5
  * Options for CallbackInterfaceTools
6
6
  */
@@ -1,6 +1,6 @@
1
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
- import type { UserInterfaceTools } from '../../../UserInterfaceTools';
3
- import type { UserInterfaceToolsPromptDialogOptions } from '../../../UserInterfaceTools';
1
+ import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
2
+ import type { UserInterfaceTools } from '../../../execution/UserInterfaceTools';
3
+ import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/UserInterfaceTools';
4
4
  /**
5
5
  * Wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt
6
6
  *
@@ -1,8 +1,8 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
3
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
4
- import type { PromptChatResult } from '../../../PromptResult';
5
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { PromptChatResult } from '../../execution/PromptResult';
4
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
5
+ import type { Prompt } from '../../types/Prompt';
6
6
  import type { AnthropicClaudeExecutionToolsOptions } from './AnthropicClaudeExecutionToolsOptions';
7
7
  /**
8
8
  * Execution Tools for calling Anthropic Claude API.
@@ -1,5 +1,5 @@
1
1
  import type { ClientOptions } from '@anthropic-ai/sdk';
2
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
3
  /**
4
4
  * Options for AnthropicClaudeExecutionTools
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { number_usd } from '../../../../types/typeAliases';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { number_usd } from '../../types/typeAliases';
3
3
  /**
4
4
  * List of available Anthropic Claude models with pricing
5
5
  *
@@ -1,8 +1,8 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
3
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
4
- import type { PromptChatResult } from '../../../PromptResult';
5
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { PromptChatResult } from '../../execution/PromptResult';
4
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
5
+ import type { Prompt } from '../../types/Prompt';
6
6
  import type { AzureOpenAiExecutionToolsOptions } from './AzureOpenAiExecutionToolsOptions';
7
7
  /**
8
8
  * Execution Tools for calling Azure OpenAI API.
@@ -1,6 +1,6 @@
1
- import type { string_name } from '../../../../types/typeAliases';
2
- import type { string_token } from '../../../../types/typeAliases';
3
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { string_name } from '../../types/typeAliases';
3
+ import type { string_token } from '../../types/typeAliases';
4
4
  /**
5
5
  * Options for AzureOpenAiExecutionTools
6
6
  *
@@ -1,4 +1,4 @@
1
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
2
  import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
3
3
  /**
4
4
  * Execution Tools for calling OpenAI API.
@@ -1,9 +1,9 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
3
- import type { AvailableModel } from '../../../LlmExecutionTools';
4
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
5
- import type { PromptChatResult } from '../../../PromptResult';
6
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
3
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
+ import type { PromptChatResult } from '../../execution/PromptResult';
5
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
6
+ import type { Prompt } from '../../types/Prompt';
7
7
  /**
8
8
  * Mocked execution Tools for just echoing the requests for testing purposes.
9
9
  */
@@ -1,9 +1,9 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
3
- import type { AvailableModel } from '../../../LlmExecutionTools';
4
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
5
- import type { PromptChatResult } from '../../../PromptResult';
6
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
3
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
+ import type { PromptChatResult } from '../../execution/PromptResult';
5
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
6
+ import type { Prompt } from '../../types/Prompt';
7
7
  /**
8
8
  * Mocked execution Tools for just faking expected responses for testing purposes
9
9
  */
@@ -1,5 +1,5 @@
1
- import type { Expectations } from '../../../../types/PromptbookJson/PromptTemplateJson';
2
- import type { PostprocessingFunction } from '../../script-execution-tools/javascript/JavascriptExecutionToolsOptions';
1
+ import type { PostprocessingFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
2
+ import type { Expectations } from '../../types/PromptbookJson/PromptTemplateJson';
3
3
  /**
4
4
  * Gets the expectations and creates a fake text that meets the expectations
5
5
  *
@@ -1,8 +1,8 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
3
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
4
- import type { PromptChatResult } from '../../../PromptResult';
5
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { PromptChatResult } from '../../execution/PromptResult';
4
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
5
+ import type { Prompt } from '../../types/Prompt';
6
6
  /**
7
7
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
8
8
  *
@@ -1,6 +1,6 @@
1
- import type { client_id } from '../../../../types/typeAliases';
2
- import type { string_uri } from '../../../../types/typeAliases';
3
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { client_id } from '../../types/typeAliases';
3
+ import type { string_uri } from '../../types/typeAliases';
4
4
  /**
5
5
  * Options for MultipleLlmExecutionTools
6
6
  */
@@ -1,8 +1,8 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
3
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
4
- import type { PromptChatResult } from '../../../PromptResult';
5
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { PromptChatResult } from '../../execution/PromptResult';
4
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
5
+ import type { Prompt } from '../../types/Prompt';
6
6
  import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
7
7
  /**
8
8
  * Execution Tools for calling OpenAI API.
@@ -1,6 +1,6 @@
1
1
  import type { ClientOptions } from 'openai';
2
- import type { string_token } from '../../../../types/typeAliases';
3
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
+ import type { string_token } from '../../types/typeAliases';
4
4
  /**
5
5
  * Options for OpenAiExecutionTools
6
6
  *
@@ -1,7 +1,7 @@
1
1
  import type OpenAI from 'openai';
2
- import type { Prompt } from '../../../../types/Prompt';
3
- import type { PromptResult } from '../../../PromptResult';
4
- import type { PromptResultUsage } from '../../../PromptResult';
2
+ import type { PromptResult } from '../../execution/PromptResult';
3
+ import type { PromptResultUsage } from '../../execution/PromptResult';
4
+ import type { Prompt } from '../../types/Prompt';
5
5
  /**
6
6
  * Computes the usage of the OpenAI API based on the response from OpenAI
7
7
  *
@@ -1,5 +1,5 @@
1
- import type { number_usd } from '../../../../types/typeAliases';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { number_usd } from '../../types/typeAliases';
3
3
  /**
4
4
  * List of available OpenAI models with pricing
5
5
  *
@@ -1,8 +1,8 @@
1
- import type { Prompt } from '../../../../types/Prompt';
2
- import type { AvailableModel } from '../../../LlmExecutionTools';
3
- import type { LlmExecutionTools } from '../../../LlmExecutionTools';
4
- import type { PromptChatResult } from '../../../PromptResult';
5
- import type { PromptCompletionResult } from '../../../PromptResult';
1
+ import type { AvailableModel } from '../../execution/LlmExecutionTools';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { PromptChatResult } from '../../execution/PromptResult';
4
+ import type { PromptCompletionResult } from '../../execution/PromptResult';
5
+ import type { Prompt } from '../../types/Prompt';
6
6
  import type { RemoteLlmExecutionToolsOptions } from './RemoteLlmExecutionToolsOptions';
7
7
  /**
8
8
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -1,6 +1,6 @@
1
- import type { client_id } from '../../../../types/typeAliases';
2
- import type { string_uri } from '../../../../types/typeAliases';
3
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { client_id } from '../../types/typeAliases';
3
+ import type { string_uri } from '../../types/typeAliases';
4
4
  /**
5
5
  * Options for RemoteLlmExecutionTools
6
6
  */
@@ -1,4 +1,4 @@
1
- import type { TaskProgress } from '../../../../../types/TaskProgress';
1
+ import type { TaskProgress } from '../../../types/TaskProgress';
2
2
  /**
3
3
  * Socket.io progress for remote text generation
4
4
  *
@@ -1,5 +1,5 @@
1
- import type { client_id } from '../../../../../types/typeAliases';
2
- import type { Prompt } from '../../../../../types/Prompt';
1
+ import type { Prompt } from '../../../types/Prompt';
2
+ import type { client_id } from '../../../types/typeAliases';
3
3
  /**
4
4
  * Socket.io progress for remote text generation
5
5
  *
@@ -1,4 +1,4 @@
1
- import type { PromptResult } from '../../../../PromptResult';
1
+ import type { PromptResult } from '../../../execution/PromptResult';
2
2
  /**
3
3
  * Socket.io error for remote text generation
4
4
  *
@@ -1,8 +1,8 @@
1
- import type { PromptbookLibrary } from '../../../../../library/PromptbookLibrary';
2
- import type { client_id } from '../../../../../types/typeAliases';
3
- import type { string_uri } from '../../../../../types/typeAliases';
4
- import type { CommonExecutionToolsOptions } from '../../../../CommonExecutionToolsOptions';
5
- import type { LlmExecutionTools } from '../../../../LlmExecutionTools';
1
+ import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
2
+ import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
3
+ import type { PromptbookLibrary } from '../../../library/PromptbookLibrary';
4
+ import type { client_id } from '../../../types/typeAliases';
5
+ import type { string_uri } from '../../../types/typeAliases';
6
6
  export type RemoteServerOptions = CommonExecutionToolsOptions & {
7
7
  /**
8
8
  * Port on which the server will listen
@@ -1,5 +1,5 @@
1
- import { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../../../ScriptExecutionTools';
2
- import { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptions';
1
+ import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../../execution/ScriptExecutionTools';
2
+ import type { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptions';
3
3
  /**
4
4
  * ScriptExecutionTools for JavaScript implemented via eval
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { string_javascript_name } from '../../../../types/typeAliases';
3
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
+ import type { string_javascript_name } from '../../types/typeAliases';
4
4
  /**
5
5
  * Options for javascript execution
6
6
  */
@@ -1,6 +1,6 @@
1
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
- import type { ScriptExecutionTools } from '../../../ScriptExecutionTools';
3
- import type { ScriptExecutionToolsExecuteOptions } from '../../../ScriptExecutionTools';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { ScriptExecutionTools } from '../../execution/ScriptExecutionTools';
3
+ import type { ScriptExecutionToolsExecuteOptions } from '../../execution/ScriptExecutionTools';
4
4
  /**
5
5
  * ScriptExecutionTools for Python
6
6
  *
@@ -1,6 +1,6 @@
1
- import type { CommonExecutionToolsOptions } from '../../../CommonExecutionToolsOptions';
2
- import type { ScriptExecutionTools } from '../../../ScriptExecutionTools';
3
- import type { ScriptExecutionToolsExecuteOptions } from '../../../ScriptExecutionTools';
1
+ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { ScriptExecutionTools } from '../../execution/ScriptExecutionTools';
3
+ import type { ScriptExecutionToolsExecuteOptions } from '../../execution/ScriptExecutionTools';
4
4
  /**
5
5
  * ScriptExecutionTools for TypeScript
6
6
  *
@@ -1,4 +1,4 @@
1
- import type { PostprocessingFunction } from '../execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions';
1
+ import type { PostprocessingFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
2
2
  import type { ExpectFormatCommand } from './Command';
3
3
  import type { ModelRequirements } from './ModelRequirements';
4
4
  import type { Expectations } from './PromptbookJson/PromptTemplateJson';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/utils",
3
- "version": "0.57.2",
3
+ "version": "0.58.0",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -1008,6 +1008,25 @@
1008
1008
  return replacedTemplate;
1009
1009
  }
1010
1010
 
1011
+ /**
1012
+ * Function isValidJsonString will tell you if the string is valid JSON or not
1013
+ */
1014
+ function isValidJsonString(value /* <-[👨‍⚖️] */) {
1015
+ try {
1016
+ JSON.parse(value);
1017
+ return true;
1018
+ }
1019
+ catch (error) {
1020
+ if (!(error instanceof Error)) {
1021
+ throw error;
1022
+ }
1023
+ if (error.message.includes('Unexpected token')) {
1024
+ return false;
1025
+ }
1026
+ return false;
1027
+ }
1028
+ }
1029
+
1011
1030
  /**
1012
1031
  * Counts number of characters in the text
1013
1032
  */
@@ -1082,25 +1101,6 @@
1082
1101
  PAGES: countPages,
1083
1102
  };
1084
1103
 
1085
- /**
1086
- * Function isValidJsonString will tell you if the string is valid JSON or not
1087
- */
1088
- function isValidJsonString(value) {
1089
- try {
1090
- JSON.parse(value);
1091
- return true;
1092
- }
1093
- catch (error) {
1094
- if (!(error instanceof Error)) {
1095
- throw error;
1096
- }
1097
- if (error.message.includes('Unexpected token')) {
1098
- return false;
1099
- }
1100
- return false;
1101
- }
1102
- }
1103
-
1104
1104
  /**
1105
1105
  * Makes first letter of a string uppercase
1106
1106
  *
@@ -1695,7 +1695,7 @@
1695
1695
  /**
1696
1696
  * The version of the Promptbook library
1697
1697
  */
1698
- var PROMPTBOOK_VERSION = '0.57.1';
1698
+ var PROMPTBOOK_VERSION = '0.57.2';
1699
1699
 
1700
1700
  // @promptbook/utils
1701
1701
  // And the normalization (originally n12 library) utilities: