llm-exe 1.0.2 → 2.0.0-beta.10

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 (209) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.mts +1224 -0
  3. package/dist/index.d.ts +1207 -46
  4. package/dist/index.js +4188 -80
  5. package/dist/index.mjs +4150 -0
  6. package/package.json +35 -29
  7. package/readme.md +79 -2
  8. package/dist/embedding/base.d.ts +0 -8
  9. package/dist/embedding/base.js +0 -43
  10. package/dist/embedding/base.js.map +0 -1
  11. package/dist/embedding/openai.d.ts +0 -11
  12. package/dist/embedding/openai.js +0 -73
  13. package/dist/embedding/openai.js.map +0 -1
  14. package/dist/executor/_base.d.ts +0 -68
  15. package/dist/executor/_base.js +0 -229
  16. package/dist/executor/_base.js.map +0 -1
  17. package/dist/executor/_functions.d.ts +0 -25
  18. package/dist/executor/_functions.js +0 -30
  19. package/dist/executor/_functions.js.map +0 -1
  20. package/dist/executor/_metadata.d.ts +0 -8
  21. package/dist/executor/_metadata.js +0 -59
  22. package/dist/executor/_metadata.js.map +0 -1
  23. package/dist/executor/core.d.ts +0 -10
  24. package/dist/executor/core.js +0 -28
  25. package/dist/executor/core.js.map +0 -1
  26. package/dist/executor/index.d.ts +0 -5
  27. package/dist/executor/index.js +0 -15
  28. package/dist/executor/index.js.map +0 -1
  29. package/dist/executor/llm-openai-function.d.ts +0 -13
  30. package/dist/executor/llm-openai-function.js +0 -23
  31. package/dist/executor/llm-openai-function.js.map +0 -1
  32. package/dist/executor/llm.d.ts +0 -32
  33. package/dist/executor/llm.js +0 -82
  34. package/dist/executor/llm.js.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/interfaces/chat.d.ts +0 -74
  37. package/dist/interfaces/chat.js +0 -3
  38. package/dist/interfaces/chat.js.map +0 -1
  39. package/dist/interfaces/functions.d.ts +0 -67
  40. package/dist/interfaces/functions.js +0 -4
  41. package/dist/interfaces/functions.js.map +0 -1
  42. package/dist/interfaces/index.d.ts +0 -7
  43. package/dist/interfaces/index.js +0 -23
  44. package/dist/interfaces/index.js.map +0 -1
  45. package/dist/interfaces/openai.d.ts +0 -46
  46. package/dist/interfaces/openai.js +0 -3
  47. package/dist/interfaces/openai.js.map +0 -1
  48. package/dist/interfaces/parser.d.ts +0 -8
  49. package/dist/interfaces/parser.js +0 -3
  50. package/dist/interfaces/parser.js.map +0 -1
  51. package/dist/interfaces/prompt.d.ts +0 -22
  52. package/dist/interfaces/prompt.js +0 -3
  53. package/dist/interfaces/prompt.js.map +0 -1
  54. package/dist/interfaces/utils.d.ts +0 -18
  55. package/dist/interfaces/utils.js +0 -3
  56. package/dist/interfaces/utils.js.map +0 -1
  57. package/dist/llm/_base.d.ts +0 -84
  58. package/dist/llm/_base.js +0 -184
  59. package/dist/llm/_base.js.map +0 -1
  60. package/dist/llm/index.d.ts +0 -2
  61. package/dist/llm/index.js +0 -9
  62. package/dist/llm/index.js.map +0 -1
  63. package/dist/llm/openai.d.ts +0 -96
  64. package/dist/llm/openai.js +0 -259
  65. package/dist/llm/openai.js.map +0 -1
  66. package/dist/llm/output/base.d.ts +0 -12
  67. package/dist/llm/output/base.js +0 -45
  68. package/dist/llm/output/base.js.map +0 -1
  69. package/dist/llm/output/index.d.ts +0 -9
  70. package/dist/llm/output/index.js +0 -30
  71. package/dist/llm/output/index.js.map +0 -1
  72. package/dist/llm/output/openai.d.ts +0 -17
  73. package/dist/llm/output/openai.js +0 -58
  74. package/dist/llm/output/openai.js.map +0 -1
  75. package/dist/parser/_base.d.ts +0 -33
  76. package/dist/parser/_base.js +0 -62
  77. package/dist/parser/_base.js.map +0 -1
  78. package/dist/parser/_functions.d.ts +0 -109
  79. package/dist/parser/_functions.js +0 -55
  80. package/dist/parser/_functions.js.map +0 -1
  81. package/dist/parser/_utils.d.ts +0 -3
  82. package/dist/parser/_utils.js +0 -24
  83. package/dist/parser/_utils.js.map +0 -1
  84. package/dist/parser/index.d.ts +0 -15
  85. package/dist/parser/index.js +0 -34
  86. package/dist/parser/index.js.map +0 -1
  87. package/dist/parser/parsers/BooleanParser.d.ts +0 -8
  88. package/dist/parser/parsers/BooleanParser.js +0 -20
  89. package/dist/parser/parsers/BooleanParser.js.map +0 -1
  90. package/dist/parser/parsers/CustomParser.d.ts +0 -28
  91. package/dist/parser/parsers/CustomParser.js +0 -42
  92. package/dist/parser/parsers/CustomParser.js.map +0 -1
  93. package/dist/parser/parsers/JsonParser.d.ts +0 -7
  94. package/dist/parser/parsers/JsonParser.js +0 -27
  95. package/dist/parser/parsers/JsonParser.js.map +0 -1
  96. package/dist/parser/parsers/ListToArrayParser.d.ts +0 -5
  97. package/dist/parser/parsers/ListToArrayParser.js +0 -17
  98. package/dist/parser/parsers/ListToArrayParser.js.map +0 -1
  99. package/dist/parser/parsers/ListToJsonParser.d.ts +0 -7
  100. package/dist/parser/parsers/ListToJsonParser.js +0 -34
  101. package/dist/parser/parsers/ListToJsonParser.js.map +0 -1
  102. package/dist/parser/parsers/ListToKeyValueParser.d.ts +0 -14
  103. package/dist/parser/parsers/ListToKeyValueParser.js +0 -24
  104. package/dist/parser/parsers/ListToKeyValueParser.js.map +0 -1
  105. package/dist/parser/parsers/MarkdownCodeBlock.d.ts +0 -14
  106. package/dist/parser/parsers/MarkdownCodeBlock.js +0 -16
  107. package/dist/parser/parsers/MarkdownCodeBlock.js.map +0 -1
  108. package/dist/parser/parsers/MarkdownCodeBlocks.d.ts +0 -14
  109. package/dist/parser/parsers/MarkdownCodeBlocks.js +0 -25
  110. package/dist/parser/parsers/MarkdownCodeBlocks.js.map +0 -1
  111. package/dist/parser/parsers/NumberParser.d.ts +0 -8
  112. package/dist/parser/parsers/NumberParser.js +0 -16
  113. package/dist/parser/parsers/NumberParser.js.map +0 -1
  114. package/dist/parser/parsers/OpenAiFunctionParser.d.ts +0 -16
  115. package/dist/parser/parsers/OpenAiFunctionParser.js +0 -32
  116. package/dist/parser/parsers/OpenAiFunctionParser.js.map +0 -1
  117. package/dist/parser/parsers/ReplaceStringTemplateParser.d.ts +0 -8
  118. package/dist/parser/parsers/ReplaceStringTemplateParser.js +0 -15
  119. package/dist/parser/parsers/ReplaceStringTemplateParser.js.map +0 -1
  120. package/dist/parser/parsers/StringExtractParser.d.ts +0 -12
  121. package/dist/parser/parsers/StringExtractParser.js +0 -42
  122. package/dist/parser/parsers/StringExtractParser.js.map +0 -1
  123. package/dist/parser/parsers/StringParser.d.ts +0 -8
  124. package/dist/parser/parsers/StringParser.js +0 -17
  125. package/dist/parser/parsers/StringParser.js.map +0 -1
  126. package/dist/plugins/callable/callable.d.ts +0 -87
  127. package/dist/plugins/callable/callable.js +0 -149
  128. package/dist/plugins/callable/callable.js.map +0 -1
  129. package/dist/plugins/callable/index.d.ts +0 -21
  130. package/dist/plugins/callable/index.js +0 -29
  131. package/dist/plugins/callable/index.js.map +0 -1
  132. package/dist/prompt/_base.d.ts +0 -61
  133. package/dist/prompt/_base.js +0 -164
  134. package/dist/prompt/_base.js.map +0 -1
  135. package/dist/prompt/_functions.d.ts +0 -19
  136. package/dist/prompt/_functions.js +0 -24
  137. package/dist/prompt/_functions.js.map +0 -1
  138. package/dist/prompt/chat.d.ts +0 -103
  139. package/dist/prompt/chat.js +0 -328
  140. package/dist/prompt/chat.js.map +0 -1
  141. package/dist/prompt/index.d.ts +0 -4
  142. package/dist/prompt/index.js +0 -13
  143. package/dist/prompt/index.js.map +0 -1
  144. package/dist/prompt/text.d.ts +0 -10
  145. package/dist/prompt/text.js +0 -16
  146. package/dist/prompt/text.js.map +0 -1
  147. package/dist/state/_base.d.ts +0 -29
  148. package/dist/state/_base.js +0 -96
  149. package/dist/state/_base.js.map +0 -1
  150. package/dist/state/_functions.d.ts +0 -7
  151. package/dist/state/_functions.js +0 -34
  152. package/dist/state/_functions.js.map +0 -1
  153. package/dist/state/dialogue.d.ts +0 -24
  154. package/dist/state/dialogue.js +0 -111
  155. package/dist/state/dialogue.js.map +0 -1
  156. package/dist/state/index.d.ts +0 -4
  157. package/dist/state/index.js +0 -16
  158. package/dist/state/index.js.map +0 -1
  159. package/dist/state/item.d.ts +0 -22
  160. package/dist/state/item.js +0 -63
  161. package/dist/state/item.js.map +0 -1
  162. package/dist/types/index.d.ts +0 -1
  163. package/dist/types/index.js +0 -18
  164. package/dist/types/index.js.map +0 -1
  165. package/dist/utils/const.d.ts +0 -16
  166. package/dist/utils/const.js +0 -20
  167. package/dist/utils/const.js.map +0 -1
  168. package/dist/utils/index.d.ts +0 -1
  169. package/dist/utils/index.js +0 -18
  170. package/dist/utils/index.js.map +0 -1
  171. package/dist/utils/modules/asyncCallWithTimeout.d.ts +0 -1
  172. package/dist/utils/modules/asyncCallWithTimeout.js +0 -17
  173. package/dist/utils/modules/asyncCallWithTimeout.js.map +0 -1
  174. package/dist/utils/modules/handlebars/hbs.d.ts +0 -11
  175. package/dist/utils/modules/handlebars/hbs.js +0 -65
  176. package/dist/utils/modules/handlebars/hbs.js.map +0 -1
  177. package/dist/utils/modules/handlebars/helpers/index.d.ts +0 -11
  178. package/dist/utils/modules/handlebars/helpers/index.js +0 -108
  179. package/dist/utils/modules/handlebars/helpers/index.js.map +0 -1
  180. package/dist/utils/modules/handlebars/index.d.ts +0 -2
  181. package/dist/utils/modules/handlebars/index.js +0 -79
  182. package/dist/utils/modules/handlebars/index.js.map +0 -1
  183. package/dist/utils/modules/handlebars/templates/index.d.ts +0 -12
  184. package/dist/utils/modules/handlebars/templates/index.js +0 -46
  185. package/dist/utils/modules/handlebars/templates/index.js.map +0 -1
  186. package/dist/utils/modules/index.d.ts +0 -73
  187. package/dist/utils/modules/index.js +0 -190
  188. package/dist/utils/modules/index.js.map +0 -1
  189. package/dist/utils/modules/json-schema-filter.d.ts +0 -2
  190. package/dist/utils/modules/json-schema-filter.js +0 -90
  191. package/dist/utils/modules/json-schema-filter.js.map +0 -1
  192. package/dist/utils/modules/json.d.ts +0 -3
  193. package/dist/utils/modules/json.js +0 -57
  194. package/dist/utils/modules/json.js.map +0 -1
  195. package/dist/utils/modules/openai.d.ts +0 -12
  196. package/dist/utils/modules/openai.js +0 -31
  197. package/dist/utils/modules/openai.js.map +0 -1
  198. package/dist/utils/modules/replaceTemplateString.d.ts +0 -2
  199. package/dist/utils/modules/replaceTemplateString.js +0 -21
  200. package/dist/utils/modules/replaceTemplateString.js.map +0 -1
  201. package/dist/vector/base.d.ts +0 -11
  202. package/dist/vector/base.js +0 -23
  203. package/dist/vector/base.js.map +0 -1
  204. package/dist/vector/index.d.ts +0 -2
  205. package/dist/vector/index.js +0 -8
  206. package/dist/vector/index.js.map +0 -1
  207. package/dist/vector/pinecone.d.ts +0 -6
  208. package/dist/vector/pinecone.js +0 -23
  209. package/dist/vector/pinecone.js.map +0 -1
package/package.json CHANGED
@@ -1,19 +1,32 @@
1
1
  {
2
2
  "name": "llm-exe",
3
- "version": "1.0.2",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "Simplify building LLM-powered apps with easy-to-use base components, supporting text and chat-based prompts with handlebars template engine, output parsers, and flexible function calling capabilities.",
5
5
  "keywords": [
6
6
  "ai",
7
7
  "llm",
8
8
  "openai",
9
+ "anthropic",
10
+ "bedrock",
11
+ "llama",
9
12
  "gpt-3.5-turbo",
10
13
  "gpt-4",
14
+ "claude",
11
15
  "chain",
12
16
  "prompt",
13
17
  "agent"
14
18
  ],
15
- "main": "dist/index.js",
16
- "types": "dist/index.d.ts",
19
+ "source": "./src/index.ts",
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "require": "./dist/index.js",
26
+ "import": "./dist/index.mjs",
27
+ "types": "./dist/index.d.ts"
28
+ }
29
+ },
17
30
  "files": [
18
31
  "dist"
19
32
  ],
@@ -21,12 +34,15 @@
21
34
  "node": ">=18"
22
35
  },
23
36
  "scripts": {
24
- "tsc": "tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json -w",
25
- "tsc-ci": "tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
26
- "tsc-build": "tsc --project ./tsconfig-build.json && tsc-alias -p tsconfig-build.json",
27
37
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --coverage --forceExit",
28
- "docs:dev": "vuepress dev docs --clean-temp --clean-cache",
29
- "docs:build": "vuepress build docs --clean-temp --clean-cache",
38
+ "build": "(concurrently \"tsc --p ./tsconfig.json -w\" \"tsc-alias -p tsconfig.json -w\")",
39
+ "build:ci": "tsup src/index.ts --format cjs,esm --dts --clean",
40
+ "build:package": "tsup src/index.ts --format cjs,esm --dts --clean",
41
+ "build:docs-examples": "./node_modules/.bin/esbuild examples/prompt/index.ts examples/state/index.ts --bundle --outdir=docs/.vitepress/components/examples --platform=node --target=es6 --format=esm",
42
+ "build:watch:docs-examples": "./node_modules/.bin/esbuild examples/prompt/index.ts examples/state/index.ts --watch --bundle --outdir=docs/.vitepress/components/examples --platform=node --target=es6 --format=esm",
43
+ "predocs:build": "npm run build:docs-examples",
44
+ "docs:dev": "(concurrently \"vitepress dev docs\" \"npm run build:watch:docs-examples\")",
45
+ "docs:build": "vitepress build docs",
30
46
  "lint": "eslint",
31
47
  "format:check": "prettier --check \"src\"",
32
48
  "format:write": "prettier --write \"src\""
@@ -34,35 +50,24 @@
34
50
  "author": "Greg Reindel",
35
51
  "license": "MIT",
36
52
  "dependencies": {
53
+ "@aws-crypto/sha256-js": "5.2.0",
54
+ "@aws-sdk/credential-providers": "3.624.0",
55
+ "@smithy/signature-v4": "4.1.0",
37
56
  "exponential-backoff": "3.1.1",
38
- "handlebars": "4.7.7",
39
- "json-schema-to-ts": "^2.8.2",
57
+ "handlebars": "4.7.8",
58
+ "json-schema-to-ts": "3.1.0",
40
59
  "jsonschema": "1.4.1",
41
- "lodash.camelcase": "^4.3.0",
42
- "lodash.escape": "^4.0.1",
43
- "lodash.get": "^4.4.2",
44
- "lodash.pick": "^4.4.0",
45
- "lodash.set": "^4.3.2",
46
- "lodash.unescape": "^4.0.1",
47
- "object-assign-deep": "0.4.0",
48
- "openai": "^3.2.1",
49
- "uuid": "^9.0.0"
60
+ "uuid": "10.0.0"
50
61
  },
51
62
  "devDependencies": {
52
63
  "@tsconfig/recommended": "^1.0.2",
53
64
  "@types/jest": "^29.5.2",
54
65
  "@types/json-schema": "^7.0.11",
55
- "@types/lodash.camelcase": "^4.3.7",
56
- "@types/lodash.escape": "^4.0.7",
57
- "@types/lodash.get": "^4.4.7",
58
- "@types/lodash.pick": "^4.4.7",
59
- "@types/lodash.set": "^4.3.7",
60
- "@types/lodash.unescape": "^4.0.7",
61
66
  "@types/node": "17.0.23",
62
67
  "@types/prettier": "2.6.0",
63
- "@types/uuid": "^9.0.1",
64
- "@vuepress/plugin-google-analytics": "^2.0.0-beta.62",
65
- "@vuepress/plugin-register-components": "^2.0.0-beta.63",
68
+ "@types/uuid": "^10.0.0",
69
+ "concurrently": "^8.2.2",
70
+ "esbuild": "0.23.1",
66
71
  "eslint": "^8.41.0",
67
72
  "eslint-config-airbnb-base": "^15.0.0",
68
73
  "eslint-config-prettier": "^8.8.0",
@@ -72,9 +77,10 @@
72
77
  "ts-jest": "^29.1.0",
73
78
  "ts-node": "^10.9.1",
74
79
  "tsc-alias": "^1.6.6",
80
+ "tsup": "^8.2.4",
75
81
  "tsconfig-paths": "^3.14.1",
76
82
  "typescript": "^4.8.4",
77
- "vuepress": "^2.0.0-beta.62"
83
+ "vitepress": "^1.3.2"
78
84
  },
79
85
  "repository": {
80
86
  "type": "git",
package/readme.md CHANGED
@@ -6,9 +6,86 @@ A package that provides simplified base components to make building and maintain
6
6
 
7
7
  - Write functions powered by LLM's with easy to use building blocks.
8
8
  - Pure Javascript and Typescript. Allows you to pass and infer types.
9
- - Support for text-based and chat-based prompts (gpt-3.5-turbo and gpt-4).
9
+ - Support for text-based (llama-3) and chat-based prompts (gpt-4o, claude-3.5).
10
10
  - Supercharge your prompts by using handlebars within prompt template.
11
11
  - Allow LLM's to call functions (or call other LLM executors).
12
12
  - Not very opinionated. You have control on how you use it.
13
13
 
14
- See full docs [here](https://llm-exe.com)
14
+ ![llm-exe](https://assets.llm-exe.com/llm-exe-featured.jpg)
15
+
16
+
17
+ See full docs [here](https://llm-exe.com)
18
+
19
+
20
+ ---
21
+ # Install
22
+
23
+ Install llm-exe using npm.
24
+ ```
25
+ npm i llm-exe
26
+ ```
27
+
28
+ ```typescript
29
+ import llmExe from "llm-exe"
30
+
31
+ // or
32
+
33
+ import { /* specific modules */ } from from "llm-exe"
34
+ ```
35
+
36
+ ## Basic Example
37
+ Below is simple example:
38
+ ```javascript
39
+ import {
40
+ useLlm,
41
+ createChatPrompt,
42
+ createParser
43
+ } from "llm-exe";
44
+
45
+ const instruction = `<some prompt>
46
+
47
+ Your response must be formatted like:
48
+ <subtask>
49
+ <subtask>
50
+ <subtask>`;
51
+
52
+ const llm = useLlm("openai.chat.v1",{ /* options */ });
53
+ const prompt = createChatPrompt(instruction).addUserMessage()
54
+ const parser = createParser("listToArray");
55
+
56
+ const executor = createLlmExecutor({
57
+ llm,
58
+ prompt,
59
+ parser
60
+ })
61
+
62
+ const input = "Hello! When was my last appointment?";
63
+ const response = await executor.execute({ input })
64
+ /**
65
+ *
66
+ * The prompt sent to the LLM would be:
67
+ * (line breaks added for readability)
68
+ *
69
+ * [{
70
+ * role: 'system',
71
+ * content: '<some prompt>\n
72
+ * Your response must be formatted like:\n<subtask>\n<subtask>\n
73
+ * <subtask>'
74
+ * },
75
+ * {
76
+ * role: 'user',
77
+ * content: 'Hello! When was my last appointment?'
78
+ * }]
79
+ *
80
+ */
81
+
82
+ /**
83
+ *
84
+ * console.log(response)
85
+ * [
86
+ * "a subtask the llm generated",
87
+ * "a subtask the llm generated",
88
+ * "a subtask the llm generated",
89
+ * ]
90
+ * /
91
+ ```
@@ -1,8 +0,0 @@
1
- export declare class BaseEmbedding {
2
- protected client: any;
3
- protected timeout: number;
4
- protected maxDelay: number;
5
- protected numOfAttempts: number;
6
- protected jitter: "none" | "full";
7
- constructor(options: any);
8
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseEmbedding = void 0;
4
- class BaseEmbedding {
5
- constructor(options) {
6
- Object.defineProperty(this, "client", {
7
- enumerable: true,
8
- configurable: true,
9
- writable: true,
10
- value: void 0
11
- });
12
- Object.defineProperty(this, "timeout", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- Object.defineProperty(this, "maxDelay", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- Object.defineProperty(this, "numOfAttempts", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: void 0
29
- });
30
- Object.defineProperty(this, "jitter", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
36
- this.timeout = options.timeout || 10000;
37
- this.jitter = options.jitter || "none";
38
- this.maxDelay = options.maxDelay || 4000;
39
- this.numOfAttempts = options.numOfAttempts || 3;
40
- }
41
- }
42
- exports.BaseEmbedding = BaseEmbedding;
43
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"src/","sources":["embedding/base.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IAOxB,YAAY,OAAY;QANxB;;;;;WAAsB;QACtB;;;;;WAA0B;QAE1B;;;;;WAA2B;QAC3B;;;;;WAAgC;QAChC;;;;;WAAkC;QAEhC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;QAExC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAdD,sCAcC"}
@@ -1,11 +0,0 @@
1
- import { BaseEmbedding } from "./base";
2
- import { EmbedOpenAIOptions } from "../types";
3
- export declare class EmbeddingOpenAI extends BaseEmbedding {
4
- private model;
5
- batchSize: number;
6
- stripNewLines: boolean;
7
- constructor(options: EmbedOpenAIOptions);
8
- embedDocuments(texts: string[]): Promise<any[]>;
9
- embedQuery(text: string): Promise<any>;
10
- embeddingWithRetry(input: string): Promise<any>;
11
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmbeddingOpenAI = void 0;
4
- const openai_1 = require("openai");
5
- const utils_1 = require("../utils");
6
- const base_1 = require("./base");
7
- const exponential_backoff_1 = require("exponential-backoff");
8
- class EmbeddingOpenAI extends base_1.BaseEmbedding {
9
- constructor(options) {
10
- super(options);
11
- Object.defineProperty(this, "model", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "batchSize", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- Object.defineProperty(this, "stripNewLines", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- this.model = options.modelName || "text-embedding-ada-002";
30
- this.batchSize = options.temperature || 0;
31
- this.stripNewLines = !!options.stripNewLines;
32
- const apiKey = options.openAIApiKey || (0, utils_1.getEnvironmentVariable)("OPENAI_API_KEY");
33
- this.client = new openai_1.OpenAIApi(new openai_1.Configuration({
34
- apiKey,
35
- }));
36
- }
37
- async embedDocuments(texts) {
38
- const subPrompts = (0, utils_1.chunkArray)(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize);
39
- const embeddings = [];
40
- for (let i = 0; i < subPrompts.length; i += 1) {
41
- const input = subPrompts[i];
42
- const { data } = await this.embeddingWithRetry(input);
43
- for (let j = 0; j < input.length; j += 1) {
44
- embeddings.push(data[j].embedding);
45
- }
46
- }
47
- return embeddings;
48
- }
49
- async embedQuery(text) {
50
- const { data } = await this.embeddingWithRetry(this.stripNewLines ? text.replace(/\n/g, " ") : text);
51
- return data[0].embedding;
52
- }
53
- async embeddingWithRetry(input) {
54
- const response = await (0, exponential_backoff_1.backOff)(() => (0, utils_1.asyncCallWithTimeout)(this.client.createEmbedding({
55
- model: this.model,
56
- input: input,
57
- user: "",
58
- }), this.timeout), {
59
- startingDelay: 0,
60
- maxDelay: this.maxDelay,
61
- numOfAttempts: this.numOfAttempts,
62
- jitter: this.jitter,
63
- retry: () => {
64
- console.log(`OpenAI timeout after ${this.timeout}. Retrying...`);
65
- return true;
66
- },
67
- });
68
- const { data } = response;
69
- return data;
70
- }
71
- }
72
- exports.EmbeddingOpenAI = EmbeddingOpenAI;
73
- //# sourceMappingURL=openai.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.js","sourceRoot":"src/","sources":["embedding/openai.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAClD,mCAAmF;AACnF,iCAAuC;AACvC,6DAA8C;AAG9C,MAAa,eAAgB,SAAQ,oBAAa;IAKhD,YAAY,OAA2B;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QALjB;;;;;WAAsB;QAEtB;;;;;WAAyB;QACzB;;;;;WAA8B;QAI5B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,SAAS,IAAI,wBAAwB,CAAC;QAC3D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;QAE7C,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,IAAI,IAAA,8BAAsB,EAAC,gBAAgB,CAAC,CAAC;QAChF,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CACzB,IAAI,sBAAa,CAAC;YAChB,MAAM;SACP,CAAC,CACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAe;QAClC,MAAM,U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K;YACjB,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,EAAE;SACT,CAAC,EACF,IAAI,CAAC,OAAO,CACb,EACH;YACE,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,GAAG,EAAE;gBACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC;gBACjE,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CACF,CAAC;QAEF,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnED,0CAmEC"}
@@ -1,68 +0,0 @@
1
- import { PlainObject, ExecutorMetadata, ListenerFunction, CoreExecutorHookInput, ExecutorExecutionMetadata, CoreExecutorExecuteOptions, BaseExecutorHooks } from "../types";
2
- /**
3
- * BaseExecutor
4
- * @template I - Input type.
5
- * @template O - Output type.
6
- * @template H - Hooks type.
7
- */
8
- export declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends BaseExecutorHooks = BaseExecutorHooks> {
9
- /**
10
- * @property id - internal id of the executor
11
- */
12
- readonly id: string;
13
- /**
14
- * @property type - type of executor
15
- */
16
- type: string;
17
- /**
18
- * @property created - timestamp date created
19
- */
20
- readonly created: number;
21
- /**
22
- * @property name - name of executor
23
- */
24
- name: string;
25
- /**
26
- * @property executions -
27
- */
28
- executions: number;
29
- traceId: string | null;
30
- /**
31
- * @property hooks - hooks to be ran during execution
32
- */
33
- hooks: any;
34
- readonly allowedHooks: any[];
35
- constructor(name: string, type: string, options?: CoreExecutorExecuteOptions<H>);
36
- abstract handler(input: I, _options?: any): Promise<any>;
37
- /**
38
- *
39
- * Used to filter the input of the handler
40
- * @param _input
41
- * @returns original input formatted for handler
42
- */
43
- getHandlerInput(_input: I, _metadata: ExecutorExecutionMetadata<I, any>, _options?: any): any;
44
- /**
45
- *
46
- * Used to filter the output of the handler
47
- * @param _input
48
- * @returns output O
49
- */
50
- getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any): O;
51
- /**
52
- *
53
- * execute - Runs the executor
54
- * @param _input
55
- * @returns handler output
56
- */
57
- execute(_input: I, _options?: any): Promise<O>;
58
- metadata(): Record<string, any>;
59
- getMetadata(metadata?: Record<string, any>): ExecutorMetadata;
60
- runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): void;
61
- setHooks(hooks?: CoreExecutorHookInput<H>): this;
62
- removeHook(eventName: keyof H, fn: ListenerFunction): this;
63
- on(eventName: keyof H, fn: ListenerFunction): this;
64
- off(eventName: keyof H, fn: ListenerFunction): this;
65
- once(eventName: keyof H, fn: ListenerFunction): this;
66
- withTraceId(traceId: string): this;
67
- getTraceId(): string | null;
68
- }
@@ -1,229 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseExecutor = void 0;
4
- const utils_1 = require("../utils");
5
- const _metadata_1 = require("./_metadata");
6
- const const_1 = require("../utils/const");
7
- /**
8
- * BaseExecutor
9
- * @template I - Input type.
10
- * @template O - Output type.
11
- * @template H - Hooks type.
12
- */
13
- class BaseExecutor {
14
- constructor(name, type, options) {
15
- /**
16
- * @property id - internal id of the executor
17
- */
18
- Object.defineProperty(this, "id", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- /**
25
- * @property type - type of executor
26
- */
27
- Object.defineProperty(this, "type", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
- /**
34
- * @property created - timestamp date created
35
- */
36
- Object.defineProperty(this, "created", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- /**
43
- * @property name - name of executor
44
- */
45
- Object.defineProperty(this, "name", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: void 0
50
- });
51
- /**
52
- * @property executions -
53
- */
54
- Object.defineProperty(this, "executions", {
55
- enumerable: true,
56
- configurable: true,
57
- writable: true,
58
- value: void 0
59
- });
60
- Object.defineProperty(this, "traceId", {
61
- enumerable: true,
62
- configurable: true,
63
- writable: true,
64
- value: null
65
- });
66
- /**
67
- * @property hooks - hooks to be ran during execution
68
- */
69
- Object.defineProperty(this, "hooks", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- Object.defineProperty(this, "allowedHooks", {
76
- enumerable: true,
77
- configurable: true,
78
- writable: true,
79
- value: [const_1.hookOnComplete, const_1.hookOnError, const_1.hookOnSuccess]
80
- });
81
- this.id = (0, utils_1.uuid)();
82
- this.type = type;
83
- this.name = name;
84
- this.created = new Date().getTime();
85
- this.executions = 0;
86
- this.hooks = {
87
- onSuccess: [],
88
- onError: [],
89
- onComplete: [],
90
- };
91
- if (options?.hooks) {
92
- this.setHooks(options.hooks);
93
- }
94
- }
95
- /**
96
- *
97
- * Used to filter the input of the handler
98
- * @param _input
99
- * @returns original input formatted for handler
100
- */
101
- getHandlerInput(_input, _metadata, _options) {
102
- return (0, utils_1.ensureInputIsObject)(_input);
103
- }
104
- /**
105
- *
106
- * Used to filter the output of the handler
107
- * @param _input
108
- * @returns output O
109
- */
110
- getHandlerOutput(out, _metadata, _options) {
111
- return out;
112
- }
113
- /**
114
- *
115
- * execute - Runs the executor
116
- * @param _input
117
- * @returns handler output
118
- */
119
- async execute(_input, _options) {
120
- this.executions++;
121
- const _metadata = (0, _metadata_1.createMetadataState)({
122
- start: new Date().getTime(),
123
- input: _input,
124
- });
125
- try {
126
- const input = this.getHandlerInput(_input, _metadata.asPlainObject(), _options);
127
- _metadata.setItem({ handlerInput: input });
128
- let result = await this.handler(input, _options);
129
- _metadata.setItem({ handlerOutput: result });
130
- const output = this.getHandlerOutput(result, _metadata.asPlainObject(), _options);
131
- _metadata.setItem({ output });
132
- this.runHook("onSuccess", _metadata.asPlainObject());
133
- return output;
134
- }
135
- catch (error) {
136
- _metadata.setItem({ error, errorMessage: error.message });
137
- this.runHook("onError", _metadata.asPlainObject());
138
- throw error;
139
- }
140
- finally {
141
- _metadata.setItem({ end: new Date().getTime() });
142
- this.runHook("onComplete", _metadata.asPlainObject());
143
- }
144
- }
145
- metadata() {
146
- return {};
147
- }
148
- getMetadata(metadata) {
149
- return Object.assign({}, this.metadata(), {
150
- traceId: this.getTraceId(),
151
- id: this.id,
152
- type: this.type,
153
- name: this.name,
154
- created: this.created,
155
- executions: this.executions,
156
- metadata,
157
- });
158
- }
159
- runHook(hook, _metadata) {
160
- /* istanbul ignore next */
161
- const { [hook]: hooks = [] } = (0, utils_1.pick)(this.hooks, this.allowedHooks);
162
- for (const hookFn of [...hooks] /** clone hooks */) {
163
- if (typeof hookFn === "function") {
164
- try {
165
- hookFn(_metadata, this.getMetadata());
166
- }
167
- catch (error) {
168
- /** We should call an error handler */
169
- }
170
- }
171
- }
172
- }
173
- setHooks(hooks = {}) {
174
- const hookKeys = Object.keys(hooks);
175
- for (const hookKey of hookKeys.filter((k) => this.allowedHooks.includes(k))) {
176
- const hookInput = hooks[hookKey];
177
- if (hookInput) {
178
- const _hooks = Array.isArray(hookInput) ? hookInput : [hookInput];
179
- for (const hook of _hooks) {
180
- if (hook &&
181
- typeof hook === "function" &&
182
- !this.hooks[hookKey].find((h) => h === hook)) {
183
- this.hooks[hookKey].push(hook);
184
- }
185
- }
186
- }
187
- }
188
- return this;
189
- }
190
- removeHook(eventName, fn) {
191
- if (typeof fn !== "function")
192
- return this;
193
- const lis = this.hooks[eventName];
194
- if (!lis)
195
- return this;
196
- for (let i = lis.length; i >= 0; i--) {
197
- if (lis[i] === fn) {
198
- lis.splice(i, 1);
199
- break;
200
- }
201
- }
202
- return this;
203
- }
204
- on(eventName, fn) {
205
- return this.setHooks({ [eventName]: fn });
206
- }
207
- off(eventName, fn) {
208
- return this.removeHook(eventName, fn);
209
- }
210
- once(eventName, fn) {
211
- if (typeof fn !== "function")
212
- return this;
213
- const onceWrapper = (...args) => {
214
- fn(...args);
215
- this.off(eventName, onceWrapper);
216
- };
217
- this.hooks[eventName].push(onceWrapper);
218
- return this;
219
- }
220
- withTraceId(traceId) {
221
- this.traceId = traceId;
222
- return this;
223
- }
224
- getTraceId() {
225
- return this.traceId;
226
- }
227
- }
228
- exports.BaseExecutor = BaseExecutor;
229
- //# sourceMappingURL=_base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_base.js","sourceRoot":"src/","sources":["executor/_base.ts"],"names":[],"mappings":";;;AAUA,mCAA0D;AAC1D,2CAAkD;AAClD,yCAA2E;AAE3E;;;;;GAKG;AACH,MAAsB,YAAY;IAqChC,YACE,IAAY,EACZ,IAAY,EACZ,OAAuC;QAnCzC;;WAEG;QACH;;;;;WAAY;QAEZ;;WAEG;QACH;;;;;WAAY;QAEZ;;WAEG;QACH;;;;;WAAiB;QAEjB;;WAEG;QACH;;;;;WAAY;QAEZ;;WAEG;QACH;;;;;WAAkB;QAElB;;;;mBAAgC,IAAI;WAAC;QACrC;;WAEG;QACH;;;;;WAAkB;QAClB;;;;mBAA+B,CAAC,sBAAc,EAAE,mBAAW,EAAE,qBAAa,CAAC;WAAC;QAO1E,IAAI,CAAC,EAAE,GAAG,IAAA,YAAI,GAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG;YACX,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,EAAE;SACf,CAAC;QAEF,IAAI,OAAO,EAAE,KAAK,EAAE;YAClB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC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