openlayer 0.0.0 → 0.0.1-alpha.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 (262) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +408 -0
  3. package/_shims/MultipartBody.d.ts +9 -0
  4. package/_shims/MultipartBody.d.ts.map +1 -0
  5. package/_shims/MultipartBody.js +16 -0
  6. package/_shims/MultipartBody.js.map +1 -0
  7. package/_shims/MultipartBody.mjs +12 -0
  8. package/_shims/MultipartBody.mjs.map +1 -0
  9. package/_shims/README.md +46 -0
  10. package/_shims/auto/runtime-bun.d.ts +5 -0
  11. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  12. package/_shims/auto/runtime-bun.js +21 -0
  13. package/_shims/auto/runtime-bun.js.map +1 -0
  14. package/_shims/auto/runtime-bun.mjs +2 -0
  15. package/_shims/auto/runtime-bun.mjs.map +1 -0
  16. package/_shims/auto/runtime-node.d.ts +5 -0
  17. package/_shims/auto/runtime-node.d.ts.map +1 -0
  18. package/_shims/auto/runtime-node.js +21 -0
  19. package/_shims/auto/runtime-node.js.map +1 -0
  20. package/_shims/auto/runtime-node.mjs +2 -0
  21. package/_shims/auto/runtime-node.mjs.map +1 -0
  22. package/_shims/auto/runtime.d.ts +5 -0
  23. package/_shims/auto/runtime.d.ts.map +1 -0
  24. package/_shims/auto/runtime.js +21 -0
  25. package/_shims/auto/runtime.js.map +1 -0
  26. package/_shims/auto/runtime.mjs +2 -0
  27. package/_shims/auto/runtime.mjs.map +1 -0
  28. package/_shims/auto/types-node.d.ts +5 -0
  29. package/_shims/auto/types-node.d.ts.map +1 -0
  30. package/_shims/auto/types-node.js +21 -0
  31. package/_shims/auto/types-node.js.map +1 -0
  32. package/_shims/auto/types-node.mjs +2 -0
  33. package/_shims/auto/types-node.mjs.map +1 -0
  34. package/_shims/auto/types.d.ts +101 -0
  35. package/_shims/auto/types.js +3 -0
  36. package/_shims/auto/types.mjs +3 -0
  37. package/_shims/bun-runtime.d.ts +6 -0
  38. package/_shims/bun-runtime.d.ts.map +1 -0
  39. package/_shims/bun-runtime.js +14 -0
  40. package/_shims/bun-runtime.js.map +1 -0
  41. package/_shims/bun-runtime.mjs +10 -0
  42. package/_shims/bun-runtime.mjs.map +1 -0
  43. package/_shims/index.d.ts +81 -0
  44. package/_shims/index.js +13 -0
  45. package/_shims/index.mjs +7 -0
  46. package/_shims/manual-types.d.ts +12 -0
  47. package/_shims/manual-types.js +3 -0
  48. package/_shims/manual-types.mjs +3 -0
  49. package/_shims/node-runtime.d.ts +3 -0
  50. package/_shims/node-runtime.d.ts.map +1 -0
  51. package/_shims/node-runtime.js +90 -0
  52. package/_shims/node-runtime.js.map +1 -0
  53. package/_shims/node-runtime.mjs +56 -0
  54. package/_shims/node-runtime.mjs.map +1 -0
  55. package/_shims/node-types.d.ts +42 -0
  56. package/_shims/node-types.js +3 -0
  57. package/_shims/node-types.mjs +3 -0
  58. package/_shims/registry.d.ts +37 -0
  59. package/_shims/registry.d.ts.map +1 -0
  60. package/_shims/registry.js +41 -0
  61. package/_shims/registry.js.map +1 -0
  62. package/_shims/registry.mjs +37 -0
  63. package/_shims/registry.mjs.map +1 -0
  64. package/_shims/web-runtime.d.ts +5 -0
  65. package/_shims/web-runtime.d.ts.map +1 -0
  66. package/_shims/web-runtime.js +78 -0
  67. package/_shims/web-runtime.js.map +1 -0
  68. package/_shims/web-runtime.mjs +71 -0
  69. package/_shims/web-runtime.mjs.map +1 -0
  70. package/_shims/web-types.d.ts +83 -0
  71. package/_shims/web-types.js +3 -0
  72. package/_shims/web-types.mjs +3 -0
  73. package/core.d.ts +237 -0
  74. package/core.d.ts.map +1 -0
  75. package/core.js +868 -0
  76. package/core.js.map +1 -0
  77. package/core.mjs +837 -0
  78. package/core.mjs.map +1 -0
  79. package/error.d.ts +53 -0
  80. package/error.d.ts.map +1 -0
  81. package/error.js +143 -0
  82. package/error.js.map +1 -0
  83. package/error.mjs +127 -0
  84. package/error.mjs.map +1 -0
  85. package/index.d.mts +114 -0
  86. package/index.d.ts +114 -0
  87. package/index.d.ts.map +1 -0
  88. package/index.js +119 -0
  89. package/index.js.map +1 -0
  90. package/index.mjs +91 -0
  91. package/index.mjs.map +1 -0
  92. package/lib/core/cli.d.ts +7 -0
  93. package/lib/core/cli.d.ts.map +1 -0
  94. package/lib/core/cli.js +91 -0
  95. package/lib/core/cli.js.map +1 -0
  96. package/lib/core/cli.mjs +64 -0
  97. package/lib/core/cli.mjs.map +1 -0
  98. package/lib/core/index.d.ts +237 -0
  99. package/lib/core/index.d.ts.map +1 -0
  100. package/lib/core/index.js +635 -0
  101. package/lib/core/index.js.map +1 -0
  102. package/lib/core/index.mjs +627 -0
  103. package/lib/core/index.mjs.map +1 -0
  104. package/lib/core/run.d.ts +14 -0
  105. package/lib/core/run.d.ts.map +1 -0
  106. package/lib/core/run.js +3 -0
  107. package/lib/core/run.js.map +1 -0
  108. package/lib/core/run.mjs +2 -0
  109. package/lib/core/run.mjs.map +1 -0
  110. package/package.json +102 -6
  111. package/resource.d.ts +6 -0
  112. package/resource.d.ts.map +1 -0
  113. package/resource.js +11 -0
  114. package/resource.js.map +1 -0
  115. package/resource.mjs +7 -0
  116. package/resource.mjs.map +1 -0
  117. package/resources/commits/commits.d.ts +11 -0
  118. package/resources/commits/commits.d.ts.map +1 -0
  119. package/resources/commits/commits.js +40 -0
  120. package/resources/commits/commits.js.map +1 -0
  121. package/resources/commits/commits.mjs +13 -0
  122. package/resources/commits/commits.mjs.map +1 -0
  123. package/resources/commits/index.d.ts +3 -0
  124. package/resources/commits/index.d.ts.map +1 -0
  125. package/resources/commits/index.js +9 -0
  126. package/resources/commits/index.js.map +1 -0
  127. package/resources/commits/index.mjs +4 -0
  128. package/resources/commits/index.mjs.map +1 -0
  129. package/resources/commits/test-results.d.ts +217 -0
  130. package/resources/commits/test-results.d.ts.map +1 -0
  131. package/resources/commits/test-results.js +18 -0
  132. package/resources/commits/test-results.js.map +1 -0
  133. package/resources/commits/test-results.mjs +14 -0
  134. package/resources/commits/test-results.mjs.map +1 -0
  135. package/resources/index.d.ts +4 -0
  136. package/resources/index.d.ts.map +1 -0
  137. package/resources/index.js +11 -0
  138. package/resources/index.js.map +1 -0
  139. package/resources/index.mjs +5 -0
  140. package/resources/index.mjs.map +1 -0
  141. package/resources/inference-pipelines/data.d.ts +228 -0
  142. package/resources/inference-pipelines/data.d.ts.map +1 -0
  143. package/resources/inference-pipelines/data.js +17 -0
  144. package/resources/inference-pipelines/data.js.map +1 -0
  145. package/resources/inference-pipelines/data.mjs +13 -0
  146. package/resources/inference-pipelines/data.mjs.map +1 -0
  147. package/resources/inference-pipelines/index.d.ts +4 -0
  148. package/resources/inference-pipelines/index.d.ts.map +1 -0
  149. package/resources/inference-pipelines/index.js +11 -0
  150. package/resources/inference-pipelines/index.js.map +1 -0
  151. package/resources/inference-pipelines/index.mjs +5 -0
  152. package/resources/inference-pipelines/index.mjs.map +1 -0
  153. package/resources/inference-pipelines/inference-pipelines.d.ts +16 -0
  154. package/resources/inference-pipelines/inference-pipelines.d.ts.map +1 -0
  155. package/resources/inference-pipelines/inference-pipelines.js +43 -0
  156. package/resources/inference-pipelines/inference-pipelines.js.map +1 -0
  157. package/resources/inference-pipelines/inference-pipelines.mjs +16 -0
  158. package/resources/inference-pipelines/inference-pipelines.mjs.map +1 -0
  159. package/resources/inference-pipelines/test-results.d.ts +217 -0
  160. package/resources/inference-pipelines/test-results.d.ts.map +1 -0
  161. package/resources/inference-pipelines/test-results.js +18 -0
  162. package/resources/inference-pipelines/test-results.js.map +1 -0
  163. package/resources/inference-pipelines/test-results.mjs +14 -0
  164. package/resources/inference-pipelines/test-results.mjs.map +1 -0
  165. package/resources/projects/commits.d.ts +171 -0
  166. package/resources/projects/commits.d.ts.map +1 -0
  167. package/resources/projects/commits.js +18 -0
  168. package/resources/projects/commits.js.map +1 -0
  169. package/resources/projects/commits.mjs +14 -0
  170. package/resources/projects/commits.mjs.map +1 -0
  171. package/resources/projects/index.d.ts +4 -0
  172. package/resources/projects/index.d.ts.map +1 -0
  173. package/resources/projects/index.js +11 -0
  174. package/resources/projects/index.js.map +1 -0
  175. package/resources/projects/index.mjs +5 -0
  176. package/resources/projects/index.mjs.map +1 -0
  177. package/resources/projects/inference-pipelines.d.ts +121 -0
  178. package/resources/projects/inference-pipelines.d.ts.map +1 -0
  179. package/resources/projects/inference-pipelines.js +18 -0
  180. package/resources/projects/inference-pipelines.js.map +1 -0
  181. package/resources/projects/inference-pipelines.mjs +14 -0
  182. package/resources/projects/inference-pipelines.mjs.map +1 -0
  183. package/resources/projects/projects.d.ts +172 -0
  184. package/resources/projects/projects.d.ts.map +1 -0
  185. package/resources/projects/projects.js +50 -0
  186. package/resources/projects/projects.js.map +1 -0
  187. package/resources/projects/projects.mjs +23 -0
  188. package/resources/projects/projects.mjs.map +1 -0
  189. package/shims/node.d.ts +29 -0
  190. package/shims/node.d.ts.map +1 -0
  191. package/shims/node.js +31 -0
  192. package/shims/node.js.map +1 -0
  193. package/shims/node.mjs +5 -0
  194. package/shims/node.mjs.map +1 -0
  195. package/shims/web.d.ts +26 -0
  196. package/shims/web.d.ts.map +1 -0
  197. package/shims/web.js +31 -0
  198. package/shims/web.js.map +1 -0
  199. package/shims/web.mjs +5 -0
  200. package/shims/web.mjs.map +1 -0
  201. package/src/_shims/MultipartBody.ts +9 -0
  202. package/src/_shims/README.md +46 -0
  203. package/src/_shims/auto/runtime-bun.ts +4 -0
  204. package/src/_shims/auto/runtime-node.ts +4 -0
  205. package/src/_shims/auto/runtime.ts +4 -0
  206. package/src/_shims/auto/types-node.ts +4 -0
  207. package/src/_shims/auto/types.d.ts +101 -0
  208. package/src/_shims/auto/types.js +3 -0
  209. package/src/_shims/auto/types.mjs +3 -0
  210. package/src/_shims/bun-runtime.ts +14 -0
  211. package/src/_shims/index.d.ts +81 -0
  212. package/src/_shims/index.js +13 -0
  213. package/src/_shims/index.mjs +7 -0
  214. package/src/_shims/manual-types.d.ts +12 -0
  215. package/src/_shims/manual-types.js +3 -0
  216. package/src/_shims/manual-types.mjs +3 -0
  217. package/src/_shims/node-runtime.ts +83 -0
  218. package/src/_shims/node-types.d.ts +42 -0
  219. package/src/_shims/node-types.js +3 -0
  220. package/src/_shims/node-types.mjs +3 -0
  221. package/src/_shims/registry.ts +67 -0
  222. package/src/_shims/web-runtime.ts +103 -0
  223. package/src/_shims/web-types.d.ts +83 -0
  224. package/src/_shims/web-types.js +3 -0
  225. package/src/_shims/web-types.mjs +3 -0
  226. package/src/core.ts +1146 -0
  227. package/src/error.ts +146 -0
  228. package/src/index.ts +199 -0
  229. package/src/lib/.keep +4 -0
  230. package/src/lib/core/cli.ts +80 -0
  231. package/src/lib/core/index.ts +1067 -0
  232. package/src/lib/core/run.ts +14 -0
  233. package/src/resource.ts +11 -0
  234. package/src/resources/commits/commits.ts +14 -0
  235. package/src/resources/commits/index.ts +4 -0
  236. package/src/resources/commits/test-results.ts +284 -0
  237. package/src/resources/index.ts +5 -0
  238. package/src/resources/inference-pipelines/data.ts +285 -0
  239. package/src/resources/inference-pipelines/index.ts +5 -0
  240. package/src/resources/inference-pipelines/inference-pipelines.ts +19 -0
  241. package/src/resources/inference-pipelines/test-results.ts +284 -0
  242. package/src/resources/projects/commits.ts +226 -0
  243. package/src/resources/projects/index.ts +9 -0
  244. package/src/resources/projects/inference-pipelines.ts +165 -0
  245. package/src/resources/projects/projects.ts +232 -0
  246. package/src/shims/node.ts +50 -0
  247. package/src/shims/web.ts +50 -0
  248. package/src/tsconfig.json +11 -0
  249. package/src/uploads.ts +248 -0
  250. package/src/version.ts +1 -0
  251. package/uploads.d.ts +75 -0
  252. package/uploads.d.ts.map +1 -0
  253. package/uploads.js +165 -0
  254. package/uploads.js.map +1 -0
  255. package/uploads.mjs +152 -0
  256. package/uploads.mjs.map +1 -0
  257. package/version.d.ts +2 -0
  258. package/version.d.ts.map +1 -0
  259. package/version.js +5 -0
  260. package/version.js.map +1 -0
  261. package/version.mjs +2 -0
  262. package/version.mjs.map +1 -0
@@ -0,0 +1,635 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OpenAIMonitor = exports.OpenlayerClient = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const openai_1 = __importDefault(require("openai"));
9
+ const uuid_1 = require("uuid");
10
+ const resolvedQuery = (baseUrl, endpoint, args = {}) => `${baseUrl}${endpoint}${queryParameters(args)}`;
11
+ const queryParameters = (args) => {
12
+ const filteredArgs = Object.keys(args)
13
+ .filter((key) => typeof args[key] !== 'undefined')
14
+ .reduce((acc, arg) => {
15
+ if (Array.isArray(args[arg])) {
16
+ if (args[arg].length === 0) {
17
+ return acc;
18
+ }
19
+ acc[arg] = args[arg].join(`&${arg}=`);
20
+ }
21
+ else {
22
+ if ((typeof args[arg] === 'string' && args[arg].length === 0) ||
23
+ (typeof args[arg] === 'object' &&
24
+ Object.values(args[arg]).length === 0)) {
25
+ return acc;
26
+ }
27
+ acc[arg] = args[arg];
28
+ }
29
+ return acc;
30
+ }, {});
31
+ if (Object.keys(filteredArgs).length === 0) {
32
+ return '';
33
+ }
34
+ const resolvedArgs = Object.keys(filteredArgs)
35
+ .map((key) => `${key}=${filteredArgs[key]}`)
36
+ .join('&');
37
+ return `?${resolvedArgs}`;
38
+ };
39
+ const OpenAIPricing = {
40
+ 'babbage-002': {
41
+ input: 0.0004,
42
+ output: 0.0004,
43
+ },
44
+ 'davinci-002': {
45
+ input: 0.002,
46
+ output: 0.002,
47
+ },
48
+ 'gpt-3.5-turbo': {
49
+ input: 0.0005,
50
+ output: 0.0015,
51
+ },
52
+ 'gpt-3.5-turbo-0125': {
53
+ input: 0.0005,
54
+ output: 0.0015,
55
+ },
56
+ 'gpt-3.5-turbo-0301': {
57
+ input: 0.0015,
58
+ output: 0.002,
59
+ },
60
+ 'gpt-3.5-turbo-0613': {
61
+ input: 0.0015,
62
+ output: 0.002,
63
+ },
64
+ 'gpt-3.5-turbo-1106': {
65
+ input: 0.001,
66
+ output: 0.002,
67
+ },
68
+ 'gpt-3.5-turbo-16k-0613': {
69
+ input: 0.003,
70
+ output: 0.004,
71
+ },
72
+ 'gpt-3.5-turbo-instruct': {
73
+ input: 0.0015,
74
+ output: 0.002,
75
+ },
76
+ 'gpt-4': {
77
+ input: 0.03,
78
+ output: 0.06,
79
+ },
80
+ 'gpt-4-0125-preview': {
81
+ input: 0.01,
82
+ output: 0.03,
83
+ },
84
+ 'gpt-4-0314': {
85
+ input: 0.03,
86
+ output: 0.06,
87
+ },
88
+ 'gpt-4-0613': {
89
+ input: 0.03,
90
+ output: 0.06,
91
+ },
92
+ 'gpt-4-1106-preview': {
93
+ input: 0.01,
94
+ output: 0.03,
95
+ },
96
+ 'gpt-4-1106-vision-preview': {
97
+ input: 0.01,
98
+ output: 0.03,
99
+ },
100
+ 'gpt-4-32k': {
101
+ input: 0.06,
102
+ output: 0.12,
103
+ },
104
+ 'gpt-4-32k-0314': {
105
+ input: 0.06,
106
+ output: 0.12,
107
+ },
108
+ 'gpt-4-32k-0613': {
109
+ input: 0.03,
110
+ output: 0.06,
111
+ },
112
+ };
113
+ class OpenlayerClient {
114
+ /**
115
+ * Constructs an OpenlayerClient instance.
116
+ * @param {OpenlayerClientConstructorProps} props - The config for the Openlayer client. The API key is required.
117
+ */
118
+ constructor({ openlayerApiKey, openlayerServerUrl, }) {
119
+ this.defaultConfig = {
120
+ costColumnName: 'cost',
121
+ groundTruthColumnName: null,
122
+ inferenceIdColumnName: 'id',
123
+ latencyColumnName: 'latency',
124
+ numOfTokenColumnName: 'tokens',
125
+ outputColumnName: 'output',
126
+ timestampColumnName: 'timestamp',
127
+ };
128
+ this.openlayerServerUrl = 'https://api.openlayer.com/v1';
129
+ this.version = '0.1.0a21';
130
+ this.resolvedQuery = (endpoint, args = {}) => resolvedQuery(this.openlayerServerUrl, endpoint, args);
131
+ /**
132
+ * Creates a new inference pipeline in Openlayer or loads an existing one.
133
+ * @param {string} projectId - The ID of the project containing the inference pipeline.
134
+ * @param {string} [name='production'] - The name of the inference pipeline, defaults to 'production'.
135
+ * @returns {Promise<OpenlayerInferencePipeline>} A promise that resolves to an OpenlayerInferencePipeline object.
136
+ * @throws {Error} Throws an error if the inference pipeline cannot be created or found.
137
+ */
138
+ this.createInferencePipeline = async (projectId, name = 'production') => {
139
+ try {
140
+ return await this.loadInferencePipeline(projectId, name);
141
+ }
142
+ catch { }
143
+ const createInferencePipelineEndpoint = `/projects/${projectId}/inference-pipelines`;
144
+ const createInferencePipelineQuery = this.resolvedQuery(createInferencePipelineEndpoint, { version: this.version });
145
+ const createInferencePipelineResponse = await (0, node_fetch_1.default)(createInferencePipelineQuery, {
146
+ body: JSON.stringify({
147
+ description: '',
148
+ name,
149
+ }),
150
+ headers: {
151
+ Authorization: `Bearer ${this.openlayerApiKey}`,
152
+ 'Content-Type': 'application/json',
153
+ },
154
+ method: 'POST',
155
+ });
156
+ const inferencePipeline = (await createInferencePipelineResponse.json());
157
+ if (!inferencePipeline?.id) {
158
+ throw new Error('Error creating inference pipeline');
159
+ }
160
+ return inferencePipeline;
161
+ };
162
+ /**
163
+ * Creates a new project in Openlayer or loads an existing one.
164
+ * @param {string} name - The name of the project.
165
+ * @param {OpenlayerTaskType} taskType - The type of task associated with the project.
166
+ * @param {string} [description] - Optional description of the project.
167
+ * @returns {Promise<OpenlayerProject>} A promise that resolves to an OpenlayerProject object.
168
+ * @throws {Error} Throws an error if the project cannot be created or found.
169
+ */
170
+ this.createProject = async (name, taskType, description) => {
171
+ try {
172
+ return await this.loadProject(name);
173
+ }
174
+ catch { }
175
+ const projectsEndpoint = '/projects';
176
+ const projectsQuery = this.resolvedQuery(projectsEndpoint);
177
+ const response = await (0, node_fetch_1.default)(projectsQuery, {
178
+ body: JSON.stringify({
179
+ description,
180
+ name,
181
+ taskType,
182
+ }),
183
+ headers: {
184
+ Authorization: `Bearer ${this.openlayerApiKey}`,
185
+ 'Content-Type': 'application/json',
186
+ },
187
+ method: 'POST',
188
+ });
189
+ const data = (await response.json());
190
+ const { items: projects, error } = data;
191
+ if (!Array.isArray(projects)) {
192
+ throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
193
+ }
194
+ const project = projects.find((p) => p.name === name);
195
+ if (!project?.id) {
196
+ throw new Error('Project not found');
197
+ }
198
+ return project;
199
+ };
200
+ /**
201
+ * Loads an existing inference pipeline from Openlayer based on its name and project ID.
202
+ * @param {string} projectId - The ID of the project containing the inference pipeline.
203
+ * @param {string} [name='production'] - The name of the inference pipeline, defaults to 'production'.
204
+ * @returns {Promise<OpenlayerInferencePipeline>} A promise that resolves to an OpenlayerInferencePipeline object.
205
+ * @throws {Error} Throws an error if the inference pipeline is not found.
206
+ */
207
+ this.loadInferencePipeline = async (projectId, name = 'production') => {
208
+ const inferencePipelineEndpoint = `/projects/${projectId}/inference-pipelines`;
209
+ const inferencePipelineQueryParameters = {
210
+ name,
211
+ version: this.version,
212
+ };
213
+ const inferencePipelineQuery = this.resolvedQuery(inferencePipelineEndpoint, inferencePipelineQueryParameters);
214
+ const inferencePipelineResponse = await (0, node_fetch_1.default)(inferencePipelineQuery, {
215
+ headers: {
216
+ Authorization: `Bearer ${this.openlayerApiKey}`,
217
+ 'Content-Type': 'application/json',
218
+ },
219
+ method: 'GET',
220
+ });
221
+ const { items: inferencePipelines, error } = (await inferencePipelineResponse.json());
222
+ const inferencePipeline = Array.isArray(inferencePipelines)
223
+ ? inferencePipelines.find((p) => p.name === name)
224
+ : undefined;
225
+ if (!inferencePipeline?.id) {
226
+ throw new Error(typeof error === 'string' ? error : 'Inference pipeline not found');
227
+ }
228
+ return inferencePipeline;
229
+ };
230
+ /**
231
+ * Loads an existing project from Openlayer based on its name.
232
+ * @param {string} name - The name of the project.
233
+ * @returns {Promise<OpenlayerProject>} A promise that resolves to an OpenlayerProject object.
234
+ * @throws {Error} Throws an error if the project is not found.
235
+ */
236
+ this.loadProject = async (name) => {
237
+ const projectsEndpoint = '/projects';
238
+ const projectsQueryParameters = {
239
+ name,
240
+ version: this.version,
241
+ };
242
+ const projectsQuery = this.resolvedQuery(projectsEndpoint, projectsQueryParameters);
243
+ const response = await (0, node_fetch_1.default)(projectsQuery, {
244
+ headers: {
245
+ Authorization: `Bearer ${this.openlayerApiKey}`,
246
+ 'Content-Type': 'application/json',
247
+ },
248
+ method: 'GET',
249
+ });
250
+ const data = await response.json();
251
+ const { items: projects, error } = data;
252
+ if (!Array.isArray(projects)) {
253
+ throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
254
+ }
255
+ const project = projects.find((p) => p.name === name);
256
+ if (!project?.id) {
257
+ throw new Error('Project not found');
258
+ }
259
+ return project;
260
+ };
261
+ /**
262
+ * Streams data to the Openlayer inference pipeline.
263
+ * @param {StreamingData} data - The chat completion data to be streamed.
264
+ * @param {string} inferencePipelineId - The ID of the Openlayer inference pipeline to which data is streamed.
265
+ * @returns {Promise<void>} A promise that resolves when the data has been successfully streamed.
266
+ */
267
+ this.streamData = async (data, config, inferencePipelineId) => {
268
+ if (!this.openlayerApiKey) {
269
+ console.error('Openlayer API key are required for streaming data.');
270
+ return;
271
+ }
272
+ try {
273
+ const dataStreamEndpoint = `/inference-pipelines/${inferencePipelineId}/data-stream`;
274
+ const dataStreamQuery = this.resolvedQuery(dataStreamEndpoint);
275
+ const response = await (0, node_fetch_1.default)(dataStreamQuery, {
276
+ body: JSON.stringify({
277
+ config,
278
+ rows: [
279
+ {
280
+ ...data,
281
+ id: (0, uuid_1.v4)(),
282
+ timestamp: Math.round((data.timestamp ?? Date.now()) / 1000),
283
+ },
284
+ ],
285
+ }),
286
+ headers: {
287
+ Authorization: `Bearer ${this.openlayerApiKey}`,
288
+ 'Content-Type': 'application/json',
289
+ },
290
+ method: 'POST',
291
+ });
292
+ if (!response.ok) {
293
+ console.error('Error making POST request:', response.status);
294
+ console.error(`Error: ${response.status}`);
295
+ }
296
+ await response.json();
297
+ }
298
+ catch (error) {
299
+ console.error('Error streaming data to Openlayer:', error);
300
+ }
301
+ };
302
+ this.openlayerApiKey = openlayerApiKey;
303
+ if (openlayerServerUrl) {
304
+ this.openlayerServerUrl = openlayerServerUrl;
305
+ }
306
+ if (!this.openlayerApiKey) {
307
+ console.error('Openlayer API key are required for publishing.');
308
+ }
309
+ }
310
+ }
311
+ exports.OpenlayerClient = OpenlayerClient;
312
+ class OpenAIMonitor {
313
+ /**
314
+ * Constructs an OpenAIMonitor instance.
315
+ * @param {OpenAIMonitorConstructorProps} props - The configuration properties for the OpenAI and Openlayer clients.
316
+ */
317
+ constructor({ openAiApiKey, openlayerApiKey, openlayerProjectName, openlayerInferencePipelineId, openlayerInferencePipelineName, openlayerServerUrl, }) {
318
+ this.openlayerInferencePipelineName = 'production';
319
+ this.cost = (model, inputTokens, outputTokens) => {
320
+ const pricing = OpenAIPricing[model];
321
+ const inputCost = typeof pricing === 'undefined'
322
+ ? undefined
323
+ : (inputTokens / 1000) * pricing.input;
324
+ const outputCost = typeof pricing === 'undefined'
325
+ ? undefined
326
+ : (outputTokens / 1000) * pricing.output;
327
+ return typeof pricing === 'undefined'
328
+ ? undefined
329
+ : (inputCost ?? 0) + (outputCost ?? 0);
330
+ };
331
+ this.chatCompletionPrompt = (fromMessages) => fromMessages.map(({ content, role }, i) => ({
332
+ content: role === 'user' ? `{{ message_${i} }}` : content,
333
+ role,
334
+ }));
335
+ this.threadPrompt = async (fromMessages) => {
336
+ const messages = [];
337
+ for await (const page of fromMessages.iterPages()) {
338
+ messages.push(...page.getPaginatedItems());
339
+ }
340
+ return messages
341
+ .map(({ content, role }) => content.map((item) => ({
342
+ content: (() => {
343
+ switch (item.type) {
344
+ case 'image_file':
345
+ return item.image_file.file_id;
346
+ case 'text':
347
+ return item.text.value;
348
+ default:
349
+ return '';
350
+ }
351
+ })(),
352
+ role,
353
+ })))
354
+ .flat();
355
+ };
356
+ this.inputVariables = (fromPrompt, andMessages) => {
357
+ const inputVariableNames = fromPrompt
358
+ .filter(({ role }) => role === 'user')
359
+ .map(({ content }) => String(content).replace(/{{\s*|\s*}}/g, ''));
360
+ const inputVariables = andMessages
361
+ .filter(({ role }) => role === 'user')
362
+ .map(({ content }) => content);
363
+ const inputVariablesMap = inputVariableNames.reduce((acc, name, i) => ({ ...acc, [name]: inputVariables[i] }), {});
364
+ return { inputVariableNames, inputVariables, inputVariablesMap };
365
+ };
366
+ /**
367
+ * Creates a chat completion using the OpenAI client and streams the result to Openlayer.
368
+ * @param {ChatCompletionCreateParams} body - The parameters for creating a chat completion.
369
+ * @param {RequestOptions} [options] - Optional request options.
370
+ * @param {StreamingData} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
371
+ * @returns {Promise<ChatCompletion | Stream<ChatCompletionChunk>>} Promise of a ChatCompletion or a Stream
372
+ * @throws {Error} Throws errors from the OpenAI client.
373
+ */
374
+ this.createChatCompletion = async (body, options, additionalLogs) => {
375
+ if (typeof this.openlayerInferencePipelineId === 'undefined') {
376
+ console.error('No inference pipeline found.');
377
+ }
378
+ // Start a timer to measure latency
379
+ const startTime = Date.now();
380
+ // Accumulate output for streamed responses
381
+ let streamedOutput = '';
382
+ const response = await this.openAIClient.chat.completions.create(body, options);
383
+ try {
384
+ if (typeof this.openlayerInferencePipelineId !== 'undefined') {
385
+ const prompt = this.chatCompletionPrompt(body.messages);
386
+ const { inputVariableNames, inputVariablesMap } = this.inputVariables(prompt, body.messages);
387
+ const config = {
388
+ ...this.openlayerClient.defaultConfig,
389
+ inputVariableNames,
390
+ prompt,
391
+ };
392
+ if (body.stream) {
393
+ const streamedResponse = response;
394
+ for await (const chunk of streamedResponse) {
395
+ const [choice] = chunk.choices;
396
+ // Process each chunk - for example, accumulate input data
397
+ const chunkOutput = choice?.delta.content ?? '';
398
+ streamedOutput += chunkOutput;
399
+ }
400
+ const endTime = Date.now();
401
+ const latency = endTime - startTime;
402
+ this.openlayerClient.streamData({
403
+ latency,
404
+ output: streamedOutput,
405
+ timestamp: startTime,
406
+ ...inputVariablesMap,
407
+ ...additionalLogs,
408
+ }, config, this.openlayerInferencePipelineId);
409
+ }
410
+ else {
411
+ const nonStreamedResponse = response;
412
+ // Handle regular (non-streamed) response
413
+ const endTime = Date.now();
414
+ const latency = endTime - startTime;
415
+ const [choice] = nonStreamedResponse.choices;
416
+ const output = choice?.message.content;
417
+ const tokens = nonStreamedResponse.usage?.total_tokens ?? 0;
418
+ const inputTokens = nonStreamedResponse.usage?.prompt_tokens ?? 0;
419
+ const outputTokens = nonStreamedResponse.usage?.completion_tokens ?? 0;
420
+ const cost = this.cost(nonStreamedResponse.model, inputTokens, outputTokens);
421
+ if (typeof output === 'string') {
422
+ this.openlayerClient.streamData({
423
+ cost,
424
+ latency,
425
+ model: nonStreamedResponse.model,
426
+ output,
427
+ timestamp: startTime,
428
+ tokens,
429
+ ...inputVariablesMap,
430
+ ...additionalLogs,
431
+ }, config, this.openlayerInferencePipelineId);
432
+ }
433
+ else {
434
+ console.error('No output received from OpenAI.');
435
+ }
436
+ }
437
+ }
438
+ }
439
+ catch (error) {
440
+ console.error(error);
441
+ }
442
+ return response;
443
+ };
444
+ /**
445
+ * Creates a completion using the OpenAI client and streams the result to Openlayer.
446
+ * @param {CompletionCreateParams} body - The parameters for creating a completion.
447
+ * @param {RequestOptions} [options] - Optional request options.
448
+ * @param {StreamingData} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
449
+ * @returns {Promise<Completion | Stream<Completion>>} Promise that resolves to a Completion or a Stream.
450
+ * @throws {Error} Throws errors from the OpenAI client.
451
+ */
452
+ this.createCompletion = async (body, options, additionalLogs) => {
453
+ if (!body.prompt) {
454
+ console.error('No prompt provided.');
455
+ }
456
+ if (typeof this.openlayerInferencePipelineId === 'undefined') {
457
+ console.error('No inference pipeline found.');
458
+ }
459
+ // Start a timer to measure latency
460
+ const startTime = Date.now();
461
+ // Accumulate output and tokens data for streamed responses
462
+ let streamedModel = body.model;
463
+ let streamedOutput = '';
464
+ let streamedTokens = 0;
465
+ let streamedInputTokens = 0;
466
+ let streamedOutputTokens = 0;
467
+ const response = await this.openAIClient.completions.create(body, options);
468
+ try {
469
+ if (typeof this.openlayerInferencePipelineId !== 'undefined') {
470
+ const config = {
471
+ ...this.openlayerClient.defaultConfig,
472
+ inputVariableNames: ['input'],
473
+ };
474
+ if (body.stream) {
475
+ const streamedResponse = response;
476
+ for await (const chunk of streamedResponse) {
477
+ const [choice] = chunk.choices;
478
+ // Process each chunk - for example, accumulate input data
479
+ streamedModel = chunk.model;
480
+ streamedOutput += choice?.text.trim();
481
+ streamedTokens += chunk.usage?.total_tokens ?? 0;
482
+ streamedInputTokens += chunk.usage?.prompt_tokens ?? 0;
483
+ streamedOutputTokens += chunk.usage?.completion_tokens ?? 0;
484
+ }
485
+ const endTime = Date.now();
486
+ const latency = endTime - startTime;
487
+ const cost = this.cost(streamedModel, streamedInputTokens, streamedOutputTokens);
488
+ this.openlayerClient.streamData({
489
+ cost,
490
+ input: body.prompt,
491
+ latency,
492
+ output: streamedOutput,
493
+ timestamp: startTime,
494
+ tokens: streamedTokens,
495
+ ...additionalLogs,
496
+ }, config, this.openlayerInferencePipelineId);
497
+ }
498
+ else {
499
+ const nonStreamedResponse = response;
500
+ const [choice] = nonStreamedResponse.choices;
501
+ // Handle regular (non-streamed) response
502
+ const endTime = Date.now();
503
+ const latency = endTime - startTime;
504
+ const tokens = nonStreamedResponse.usage?.total_tokens ?? 0;
505
+ const inputTokens = nonStreamedResponse.usage?.prompt_tokens ?? 0;
506
+ const outputTokens = nonStreamedResponse.usage?.completion_tokens ?? 0;
507
+ const cost = this.cost(nonStreamedResponse.model, inputTokens, outputTokens);
508
+ this.openlayerClient.streamData({
509
+ cost,
510
+ input: body.prompt,
511
+ latency,
512
+ output: choice?.text ?? '',
513
+ timestamp: startTime,
514
+ tokens,
515
+ ...additionalLogs,
516
+ }, config, this.openlayerInferencePipelineId);
517
+ }
518
+ }
519
+ }
520
+ catch (error) {
521
+ console.error(error);
522
+ }
523
+ return response;
524
+ };
525
+ this.openlayerProjectName = openlayerProjectName;
526
+ this.openlayerInferencePipelineId = openlayerInferencePipelineId;
527
+ if (openlayerInferencePipelineName) {
528
+ this.openlayerInferencePipelineName = openlayerInferencePipelineName;
529
+ }
530
+ this.openlayerClient = new OpenlayerClient({
531
+ openlayerApiKey,
532
+ openlayerServerUrl,
533
+ });
534
+ this.openAIClient = new openai_1.default({
535
+ apiKey: openAiApiKey,
536
+ dangerouslyAllowBrowser: true,
537
+ });
538
+ }
539
+ /**
540
+ * Monitor a run from an OpenAI assistant.
541
+ * Once the run is completed, the thread data is published to Openlayer,
542
+ * along with the latency, cost, and number of tokens used.
543
+ * @param {Run} run - The run created by the OpenAI assistant.
544
+ * @param {StreamingData} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
545
+ * @returns {Promise<void>} A promise that resolves when the run data has been successfully published to Openlayer.
546
+ */
547
+ async monitorThreadRun(run, additionalLogs) {
548
+ if (run.status !== 'completed') {
549
+ return;
550
+ }
551
+ if (typeof this.openlayerInferencePipelineId === 'undefined') {
552
+ console.error('No inference pipeline found.');
553
+ return;
554
+ }
555
+ try {
556
+ const { assistant_id, completed_at, created_at, model, thread_id,
557
+ // @ts-ignore
558
+ usage, } = run;
559
+ // @ts-ignore
560
+ const { completion_tokens, prompt_tokens, total_tokens } = typeof usage === 'undefined' ||
561
+ typeof usage !== 'object' ||
562
+ usage === null
563
+ ? {}
564
+ : usage;
565
+ const cost = this.cost(model, prompt_tokens, completion_tokens);
566
+ const latency = completed_at === null ||
567
+ created_at === null ||
568
+ isNaN(completed_at) ||
569
+ isNaN(created_at)
570
+ ? undefined
571
+ : (completed_at - created_at) * 1000;
572
+ const messages = await this.openAIClient.beta.threads.messages.list(thread_id, { order: 'asc' });
573
+ const populatedPrompt = await this.threadPrompt(messages);
574
+ const prompt = this.chatCompletionPrompt(populatedPrompt);
575
+ const { inputVariableNames, inputVariablesMap } = this.inputVariables(prompt, populatedPrompt);
576
+ const config = {
577
+ ...this.openlayerClient.defaultConfig,
578
+ inputVariableNames,
579
+ prompt: prompt.slice(0, prompt.length - 1),
580
+ };
581
+ const output = prompt[prompt.length - 1]?.content;
582
+ const resolvedOutput = typeof output === 'string'
583
+ ? output
584
+ : typeof output === 'undefined' || output === null
585
+ ? ''
586
+ : `${output}`;
587
+ this.openlayerClient.streamData({
588
+ cost,
589
+ latency,
590
+ openai_assistant_id: assistant_id,
591
+ openai_thread_id: thread_id,
592
+ output: resolvedOutput,
593
+ timestamp: run.created_at,
594
+ tokens: total_tokens,
595
+ ...inputVariablesMap,
596
+ ...additionalLogs,
597
+ }, config, this.openlayerInferencePipelineId);
598
+ }
599
+ catch (error) {
600
+ console.error('Error logging thread run:', error);
601
+ }
602
+ }
603
+ /**
604
+ * Starts monitoring for the OpenAI Monitor instance. If monitoring is already active, a warning is logged.
605
+ */
606
+ async initialize() {
607
+ console.info('Initializing monitor: creating or loading an Openlayer project and inference pipeline...');
608
+ if (typeof this.openlayerInferencePipelineId !== 'undefined') {
609
+ console.info('Monitor initialized: using inference pipeline ID provided.');
610
+ return;
611
+ }
612
+ try {
613
+ if (typeof this.openlayerProjectName === 'undefined') {
614
+ console.error('No project name provided.');
615
+ return;
616
+ }
617
+ const project = await this.openlayerClient.createProject(this.openlayerProjectName, 'llm-base');
618
+ if (typeof project !== 'undefined') {
619
+ const inferencePipeline = await this.openlayerClient.createInferencePipeline(project.id, this.openlayerInferencePipelineName);
620
+ if (typeof inferencePipeline?.id === 'undefined') {
621
+ console.error('Unable to locate inference pipeline.');
622
+ }
623
+ else {
624
+ this.openlayerInferencePipelineId = inferencePipeline.id;
625
+ }
626
+ }
627
+ console.info('Monitor started');
628
+ }
629
+ catch (error) {
630
+ console.error('An error occurred while starting the monitor:', error);
631
+ }
632
+ }
633
+ }
634
+ exports.OpenAIMonitor = OpenAIMonitor;
635
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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