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
@@ -1,259 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpenAI = exports.createLlmOpenAi = void 0;
4
- const openai_1 = require("openai");
5
- const _base_1 = require("./_base");
6
- const output_1 = require("../llm/output");
7
- const utils_1 = require("../utils");
8
- const openai_2 = require("./output/openai");
9
- /**
10
- * Create a new instance of the OpenAI API wrapper.
11
- * @param options - Configuration options for the OpenAI API wrapper.
12
- * @returns - A new instance of the OpenAI API wrapper class.
13
- */
14
- function createLlmOpenAi(options) {
15
- return new OpenAI(options);
16
- }
17
- exports.createLlmOpenAi = createLlmOpenAi;
18
- /**
19
- * A class that extends BaseLlm and provides functionality for the OpenAI API.
20
- */
21
- class OpenAI extends _base_1.BaseLlm {
22
- /**
23
- * Constructor for the OpenAI class.
24
- * @param {OpenAIOptions} options - Configuration options for the OpenAI API wrapper.
25
- */
26
- constructor(options) {
27
- const { openAIApiKey = (0, utils_1.getEnvironmentVariable)("OPEN_AI_API_KEY"), modelName, temperature, maxTokens, topP = null, n = null, stream = null, stop, presencePenalty = null, frequencyPenalty = null, logitBias = null, user = "", ...restOfOptions } = options;
28
- super(restOfOptions);
29
- Object.defineProperty(this, "model", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- Object.defineProperty(this, "temperature", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "maxTokens", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- Object.defineProperty(this, "topP", {
48
- enumerable: true,
49
- configurable: true,
50
- writable: true,
51
- value: void 0
52
- });
53
- Object.defineProperty(this, "n", {
54
- enumerable: true,
55
- configurable: true,
56
- writable: true,
57
- value: null
58
- });
59
- Object.defineProperty(this, "stream", {
60
- enumerable: true,
61
- configurable: true,
62
- writable: true,
63
- value: void 0
64
- });
65
- Object.defineProperty(this, "stop", {
66
- enumerable: true,
67
- configurable: true,
68
- writable: true,
69
- value: null
70
- });
71
- Object.defineProperty(this, "presencePenalty", {
72
- enumerable: true,
73
- configurable: true,
74
- writable: true,
75
- value: void 0
76
- });
77
- Object.defineProperty(this, "frequencyPenalty", {
78
- enumerable: true,
79
- configurable: true,
80
- writable: true,
81
- value: void 0
82
- });
83
- Object.defineProperty(this, "logitBias", {
84
- enumerable: true,
85
- configurable: true,
86
- writable: true,
87
- value: void 0
88
- });
89
- Object.defineProperty(this, "user", {
90
- enumerable: true,
91
- configurable: true,
92
- writable: true,
93
- value: void 0
94
- });
95
- this.model = modelName || "gpt-3.5-turbo";
96
- this.temperature = temperature || 0;
97
- this.maxTokens = maxTokens || 500;
98
- this.topP = topP;
99
- this.n = n;
100
- this.stream = stream;
101
- this.stop = stop;
102
- this.presencePenalty = presencePenalty;
103
- this.frequencyPenalty = frequencyPenalty;
104
- this.logitBias = logitBias;
105
- this.user = user;
106
- if (this.model.substring(0, 13) === "gpt-3.5-turbo" ||
107
- this.model.substring(0, 5) === "gpt-4") {
108
- this.promptType = "chat";
109
- }
110
- else {
111
- this.promptType = "text";
112
- }
113
- this.client = new openai_1.OpenAIApi(new openai_1.Configuration({
114
- apiKey: openAIApiKey,
115
- }));
116
- }
117
- /**
118
- * Get the total prompt and completion tokens across all calls to the API.
119
- * @returns - An object with total prompt and completion tokens.
120
- */
121
- getMetrics() {
122
- let total_completionTokens = 0;
123
- let total_promptTokens = 0;
124
- let total_totalTokens = 0;
125
- for (const item of this.metrics.history) {
126
- /* istanbul ignore next */
127
- const { completion_tokens = 0, prompt_tokens = 0, total_tokens = 0, } = item.usage;
128
- total_completionTokens = total_completionTokens + completion_tokens;
129
- total_promptTokens = total_promptTokens + prompt_tokens;
130
- total_totalTokens = total_totalTokens + total_tokens;
131
- }
132
- return {
133
- total_completionTokens,
134
- total_promptTokens,
135
- total_totalTokens,
136
- };
137
- }
138
- /**
139
- * Calculate the API call cost based on input and output tokens.
140
- * @param input_tokens - The number of input tokens.
141
- * @param output_tokens=0 - The number of output tokens (defaults to 0).
142
- * @returns An object for input/output tokens and cost.
143
- */
144
- calculatePrice(input_tokens, output_tokens = 0) {
145
- return (0, utils_1.calculateOpenAiPrice)(this.model, input_tokens, output_tokens);
146
- }
147
- /**
148
- * Log a table containing usage metrics for the OpenAI API.
149
- */
150
- logMetrics() {
151
- const metrics = this.getMetrics();
152
- /* istanbul ignore next */
153
- const { total_completionTokens = 0, total_promptTokens = 0, total_totalTokens = 0, } = metrics;
154
- const cost = this.calculatePrice(total_promptTokens, total_completionTokens);
155
- console.table([
156
- {
157
- ["Total Calls"]: this.metrics.total_call_success,
158
- ["Total Completion Tokens"]: total_completionTokens,
159
- ["Total Completion Cost"]: parseFloat(cost.output_cost.toFixed(3)),
160
- ["Total Prompt Tokens"]: total_promptTokens,
161
- ["Total Prompt Cost"]: parseFloat(cost.input_cost.toFixed(3)),
162
- ["Total Tokens"]: total_totalTokens,
163
- ["Total Cost"]: parseFloat(cost.total_cost.toFixed(3)),
164
- },
165
- ]);
166
- }
167
- /**
168
- * Wrapper function to call chat/completion with the specified input.
169
- * @private
170
- * @param input - The input for the chat/completion API.
171
- * @returns The chat/completion response from the API.
172
- */
173
- async _call(input, arg2) {
174
- if (this.model.substring(0, 13) === "gpt-3.5-turbo" ||
175
- this.model.substring(0, 5) === "gpt-4") {
176
- (0, utils_1.assert)(Array.isArray(input), "Invalid prompt.");
177
- return await this.chat(input, arg2);
178
- }
179
- else {
180
- (0, utils_1.assert)(typeof input === "string");
181
- return await this.completion(input);
182
- }
183
- }
184
- /**
185
- * Communicate with the OpenAI Chat API.
186
- * @param messages - A list of message objects for the API call.
187
- * @returns The chat response from the API.
188
- */
189
- async chat(messages, _args) {
190
- (0, utils_1.assert)(Array.isArray(messages), "Invalid prompt.");
191
- const options = (0, utils_1.removeEmptyFromObject)({
192
- messages,
193
- model: this.model,
194
- temperature: this.temperature,
195
- max_tokens: this.maxTokens,
196
- topP: this.topP,
197
- n: this.n,
198
- stream: this.stream,
199
- stop: this.stop,
200
- presencePenalty: this.presencePenalty,
201
- frequencyPenalty: this.frequencyPenalty,
202
- logitBias: this.logitBias,
203
- user: this.user,
204
- });
205
- if (_args && _args?.function_call) {
206
- options["function_call"] = _args?.function_call;
207
- }
208
- if (_args && _args?.functions?.length) {
209
- options["functions"] = _args.functions.map(f => (0, utils_1.pick)(f, ["name", "description", "parameters"]));
210
- }
211
- const response = await this.client.createChatCompletion(options);
212
- const { data } = response;
213
- this.metrics.history.push(data);
214
- return new output_1.OutputOpenAIChat(data);
215
- }
216
- /**
217
- * Communicate with the OpenAI Completion API.
218
- * @param messages - A list of message objects for the API call.
219
- * @returns The chat response from the API.
220
- */
221
- async completion(prompt) {
222
- (0, utils_1.assert)(typeof prompt === "string" && prompt !== "", "Missing prompt.");
223
- const options = (0, utils_1.removeEmptyFromObject)({
224
- prompt,
225
- model: this.model,
226
- temperature: this.temperature,
227
- max_tokens: this.maxTokens,
228
- topP: this.topP,
229
- n: this.n,
230
- stream: this.stream,
231
- stop: this.stop,
232
- presencePenalty: this.presencePenalty,
233
- frequencyPenalty: this.frequencyPenalty,
234
- logitBias: this.logitBias,
235
- user: this.user,
236
- });
237
- const response = await this.client.createCompletion(options);
238
- const { data } = response;
239
- this.metrics.history.push(data);
240
- return new openai_2.OutputOpenAICompletion(data);
241
- }
242
- getMetadata() {
243
- return Object.assign({}, super.getMetadata(), (0, utils_1.removeEmptyFromObject)({
244
- model: this.model,
245
- temperature: this.temperature,
246
- max_tokens: this.maxTokens,
247
- topP: this.topP,
248
- n: this.n,
249
- stream: this.stream,
250
- stop: this.stop,
251
- presencePenalty: this.presencePenalty,
252
- frequencyPenalty: this.frequencyPenalty,
253
- logitBias: this.logitBias,
254
- user: this.user,
255
- }));
256
- }
257
- }
258
- exports.OpenAI = OpenAI;
259
- //# sourceMappingURL=openai.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.js","sourceRoot":"src/","sources":["llm/openai.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAOlD,mCAAkC;AAClC,yCAAgD;AAChD,mCAA4G;AAC5G,4CAAyD;AAEzD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,OAAsB;IACpD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAFD,0CAEC;AAED;;GAEG;AACH,MAAa,MAAO,SAAQ,eAAkB;IAa5C;;;OAGG;IACH,YAAY,OAAsB;QAChC,MAAM,EACJ,YAAY,GAAG,IAAA,8BAAsB,EAAC,iBAAiB,CAAC,EACxD,SAAS,EACT,WAAW,EACX,SAAS,EACT,IAAI,GAAG,IAAI,EACX,CAAC,GAAG,IAAI,EACR,MAAM,GAAG,IAAI,EACb,IAAI,EACJ,eAAe,GAAG,IAAI,EACtB,gBAAgB,GAAG,IAAI,EACvB,SAAS,GAAG,IAAI,EAChB,IAAI,GAAG,EAAE,EACT,GAAG,aAAa,EACjB,GAAG,OAAO,CAAC;QAEZ,KAAK,CAAC,aAAa,CAAC,CAAC;QAjCvB;;;;;WAA+B;QAC/B;;;;;WAA4B;QAC5B;;;;;WAA0B;QAC1B;;;;;WAA4B;QAC5B;;;;mBAA2B,IAAI;WAAC;QAChC;;;;;WAA+B;QAC/B;;;;mBAAoB,IAAI;WA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I,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAE7D,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,+BAAsB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW;QACT,OAAO,MAAM,CAAC,MAAM,CAClB,EAAE,EACF,KAAK,CAAC,WAAW,EAAE,EACnB,IAAA,6BAAqB,EAAC;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;CAcF;AAnPD,wBAmPC"}
@@ -1,12 +0,0 @@
1
- export declare abstract class BaseLlmOutput {
2
- protected id: string;
3
- protected name: string | undefined;
4
- protected created: number | undefined;
5
- protected results: any[];
6
- protected usage: any;
7
- constructor(result: any);
8
- getResults(): any[];
9
- abstract setResult(result: any): void;
10
- abstract getResult(resultIndex: number): any;
11
- abstract getResultContent(resultIndex?: number): any;
12
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseLlmOutput = void 0;
4
- const utils_1 = require("../../utils");
5
- class BaseLlmOutput {
6
- constructor(result) {
7
- Object.defineProperty(this, "id", {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value: void 0
12
- });
13
- Object.defineProperty(this, "name", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- Object.defineProperty(this, "created", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- Object.defineProperty(this, "results", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: []
30
- });
31
- Object.defineProperty(this, "usage", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: {}
36
- });
37
- this.id = (0, utils_1.uuid)();
38
- this.setResult(result);
39
- }
40
- getResults() {
41
- return [...this.results];
42
- }
43
- }
44
- exports.BaseLlmOutput = BaseLlmOutput;
45
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"src/","sources":["llm/output/base.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,MAAsB,aAAa;IAQjC,YAAY,MAAW;QAPvB;;;;;WAAqB;QACrB;;;;;WAAmC;QACnC;;;;;WAAsC;QACtC;;;;mBAA2B,EAAE;WAAC;QAE9B;;;;mBAAuB,EAAE;WAAC;QAGxB,IAAI,CAAC,EAAE,GAAG,IAAA,YAAI,GAAE,CAAC;QACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CAIF;AAnBD,sCAmBC"}
@@ -1,9 +0,0 @@
1
- import { BaseLlmOutput } from "./base";
2
- export { BaseLlmOutput };
3
- export { OutputOpenAIChat, OutputOpenAICompletion } from "./openai";
4
- export declare class OutputDefault extends BaseLlmOutput {
5
- constructor(result: any);
6
- setResult(result: any): void;
7
- getResult(): any;
8
- getResultContent(): any;
9
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutputDefault = exports.OutputOpenAICompletion = exports.OutputOpenAIChat = exports.BaseLlmOutput = void 0;
4
- const utils_1 = require("../../utils");
5
- const base_1 = require("./base");
6
- Object.defineProperty(exports, "BaseLlmOutput", { enumerable: true, get: function () { return base_1.BaseLlmOutput; } });
7
- var openai_1 = require("./openai");
8
- Object.defineProperty(exports, "OutputOpenAIChat", { enumerable: true, get: function () { return openai_1.OutputOpenAIChat; } });
9
- Object.defineProperty(exports, "OutputOpenAICompletion", { enumerable: true, get: function () { return openai_1.OutputOpenAICompletion; } });
10
- class OutputDefault extends base_1.BaseLlmOutput {
11
- constructor(result) {
12
- super(result);
13
- }
14
- setResult(result) {
15
- this.id = `fn-${(0, utils_1.uuid)()}`;
16
- this.name = `none`;
17
- this.created = new Date().getTime();
18
- this.usage = {};
19
- this.results = [result];
20
- }
21
- getResult() {
22
- const [result] = this.results;
23
- return result;
24
- }
25
- getResultContent() {
26
- return this.getResult();
27
- }
28
- }
29
- exports.OutputDefault = OutputDefault;
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["llm/output/index.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,iCAAuC;AAE9B,8FAFA,oBAAa,OAEA;AACtB,mCAAoE;AAA3D,0GAAA,gBAAgB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAEjD,MAAa,aAAc,SAAQ,oBAAa;IAC9C,YAAY,MAAW;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,SAAS,CAAC,MAAW;QACnB,IAAI,CAAC,EAAE,GAAG,MAAM,IAAA,YAAI,GAAE,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,SAAS;QACP,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AArBD,sCAqBC"}
@@ -1,17 +0,0 @@
1
- import { OutputOpenAIChatChoice } from "../../types";
2
- import { BaseLlmOutput } from "./base";
3
- export interface OutputOpenAIChat {
4
- results: OutputOpenAIChatChoice[];
5
- }
6
- export declare class OutputOpenAIChat extends BaseLlmOutput {
7
- constructor(result: any);
8
- setResult(result: any, _attributes?: {}): void;
9
- getResult(resultIndex?: number): OutputOpenAIChatChoice | undefined;
10
- getResultContent(resultIndex?: number): string | undefined;
11
- }
12
- export declare class OutputOpenAICompletion extends BaseLlmOutput {
13
- constructor(result: any);
14
- setResult(result: any, _attributes?: {}): void;
15
- getResult(resultIndex?: number): any;
16
- getResultContent(resultIndex?: number): any;
17
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutputOpenAICompletion = exports.OutputOpenAIChat = void 0;
4
- const base_1 = require("./base");
5
- class OutputOpenAIChat extends base_1.BaseLlmOutput {
6
- constructor(result) {
7
- super(result);
8
- }
9
- setResult(result, _attributes = {}) {
10
- this.id = result.id;
11
- this.name = result.model;
12
- this.created = result.created;
13
- this.usage = result.usage;
14
- this.results = result.choices;
15
- }
16
- getResult(resultIndex = 0) {
17
- if (resultIndex > -1 && resultIndex <= this.results.length) {
18
- const result = this.results[resultIndex];
19
- return result;
20
- }
21
- return;
22
- }
23
- getResultContent(resultIndex = 0) {
24
- const result = this.getResult(resultIndex);
25
- if (result?.message?.content) {
26
- return result?.message?.content;
27
- }
28
- if (result?.message?.content === null || result?.message?.function_call) {
29
- return JSON.stringify({ function_call: result?.message?.function_call });
30
- }
31
- return;
32
- }
33
- }
34
- exports.OutputOpenAIChat = OutputOpenAIChat;
35
- class OutputOpenAICompletion extends base_1.BaseLlmOutput {
36
- constructor(result) {
37
- super(result);
38
- }
39
- setResult(result, _attributes = {}) {
40
- this.id = result.id;
41
- this.name = result.model;
42
- this.created = result.created;
43
- this.usage = result.usage;
44
- this.results = result.choices;
45
- }
46
- getResult(resultIndex = 0) {
47
- if (resultIndex > -1 && resultIndex <= this.results.length) {
48
- const result = this.results[resultIndex];
49
- return result;
50
- }
51
- }
52
- getResultContent(resultIndex = 0) {
53
- const result = this.getResult(resultIndex);
54
- return result?.text;
55
- }
56
- }
57
- exports.OutputOpenAICompletion = OutputOpenAICompletion;
58
- //# sourceMappingURL=openai.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openai.js","sourceRoot":"src/","sources":["llm/output/openai.ts"],"names":[],"mappings":";;;AACA,iCAAuC;AAOvC,MAAa,gBAAiB,SAAQ,oBAAa;IACjD,YAAY,MAAW;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,SAAS,CAAC,MAAW,EAAE,WAAW,GAAG,EAAE;QACrC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,WAAW,GAAG,CAAC;QACvB,IAAI,WAAW,GAAG,CAAC,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CA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AM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC3C,OAAO,MAAM,EAAE,IAAI,CAAC;IACtB,CAAC;CACF;AAvBD,wDAuBC"}
@@ -1,33 +0,0 @@
1
- import { BaseParserOptions, BaseParserOptionsWithSchema } from "../types";
2
- import { FromSchema, JSONSchema } from "json-schema-to-ts";
3
- /**
4
- * BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
5
- */
6
- export declare abstract class BaseParser<T = any> {
7
- name: string;
8
- options: BaseParserOptions;
9
- /**
10
- * Create a new BaseParser.
11
- * @param name - The name of the parser.
12
- * @param options - options
13
- */
14
- constructor(name: string, options?: BaseParserOptions);
15
- /**
16
- * Parse the given text and return the parsed data.
17
- * @abstract
18
- * @param text - The text to parse.
19
- * @param [attributes] - Optional attributes to use during parsing.
20
- * @returns The parsed data.
21
- */
22
- abstract parse(text: string, attributes?: Record<string, any>): T;
23
- }
24
- export declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>> extends BaseParser<T> {
25
- schema: S;
26
- validateSchema: boolean;
27
- /**
28
- * Create a new BaseParser.
29
- * @param name - The name of the parser.
30
- * @param options - options
31
- */
32
- constructor(name: string, options: BaseParserOptionsWithSchema<S>);
33
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseParserWithJson = exports.BaseParser = void 0;
4
- /**
5
- * BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
6
- */
7
- class BaseParser {
8
- /**
9
- * Create a new BaseParser.
10
- * @param name - The name of the parser.
11
- * @param options - options
12
- */
13
- constructor(name, options = {}) {
14
- Object.defineProperty(this, "name", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: void 0
19
- });
20
- // public schema: JSONSchema7 | undefined;
21
- Object.defineProperty(this, "options", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: void 0
26
- });
27
- this.name = name;
28
- if (options) {
29
- this.options = options;
30
- }
31
- }
32
- }
33
- exports.BaseParser = BaseParser;
34
- class BaseParserWithJson extends BaseParser {
35
- /**
36
- * Create a new BaseParser.
37
- * @param name - The name of the parser.
38
- * @param options - options
39
- */
40
- constructor(name, options) {
41
- super(name);
42
- Object.defineProperty(this, "schema", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
- Object.defineProperty(this, "validateSchema", {
49
- enumerable: true,
50
- configurable: true,
51
- writable: true,
52
- value: void 0
53
- });
54
- const { schema, validateSchema } = options;
55
- this.validateSchema = !!validateSchema;
56
- if (schema) {
57
- this.schema = schema;
58
- }
59
- }
60
- }
61
- exports.BaseParserWithJson = BaseParserWithJson;
62
- //# sourceMappingURL=_base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_base.js","sourceRoot":"src/","sources":["parser/_base.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAsB,UAAU;IAI9B;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAA6B,EAAE;QARzD;;;;;WAAoB;QACpB,0CAA0C;QAC1C;;;;;WAAkC;QAOhC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACxB;IACH,CAAC;CAUF;AAxBD,gCAwBC;AAGD,MAAsB,kBAGpB,SAAQ,UAAa;IAGrB;;;;OAIG;IACH,YAAY,IAAY,EAAE,OAAuC;QAC/D,KAAK,CAAC,IAAI,CAAC,CAAC;QARd;;;;;WAAiB;QACjB;;;;;WAA+B;QAS7B,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QAC3C,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC;QAEvC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACtB;IACH,CAAC;CACF;AArBD,gDAqBC"}