openlayer 0.1.42 → 0.1.43

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.
package/dist/cli.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * Description: This file contains the CLIHandler class which is responsible
4
3
  * For handling the CLI input and output.
@@ -19,21 +18,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
18
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
19
  });
21
20
  };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.CLIHandler = void 0;
24
- const commander_1 = require("commander");
25
- const fs = require("fs");
26
- const path = require("path");
27
- class CLIHandler {
21
+ import { program } from 'commander';
22
+ import * as fs from 'fs';
23
+ import * as path from 'path';
24
+ export class CLIHandler {
28
25
  constructor(runFunction) {
29
26
  this.run = runFunction;
30
27
  }
31
28
  runFromCLI() {
32
- commander_1.program
29
+ program
33
30
  .requiredOption('--dataset-path <path>', 'Path to the dataset')
34
31
  .requiredOption('--output-dir <path>', 'Directory to place results');
35
- commander_1.program.parse(process.argv);
36
- const options = commander_1.program.opts();
32
+ program.parse(process.argv);
33
+ const options = program.opts();
37
34
  const { datasetPath, outputDir } = options;
38
35
  // Load dataset
39
36
  const datasetFullPath = path.resolve(datasetPath);
@@ -73,4 +70,3 @@ class CLIHandler {
73
70
  console.log(`Config written to ${configPath}`);
74
71
  }
75
72
  }
76
- exports.CLIHandler = CLIHandler;
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -15,12 +14,10 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
15
14
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
15
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
16
  };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.OpenAIMonitor = exports.OpenlayerClient = void 0;
20
- const node_fetch_1 = require("node-fetch");
21
- const openai_1 = require("openai");
22
- const uuid_1 = require("uuid");
23
- const request_1 = require("./request");
17
+ import fetch from 'node-fetch';
18
+ import OpenAI from 'openai';
19
+ import { v4 as uuid } from 'uuid';
20
+ import { resolvedQuery } from './request';
24
21
  const OpenAIPricing = {
25
22
  'babbage-002': {
26
23
  input: 0.0004,
@@ -95,7 +92,7 @@ const OpenAIPricing = {
95
92
  output: 0.06,
96
93
  },
97
94
  };
98
- class OpenlayerClient {
95
+ export class OpenlayerClient {
99
96
  /**
100
97
  * Constructs an OpenlayerClient instance.
101
98
  * @param {OpenlayerClientConstructorProps} props - The config for the Openlayer client. The API key is required.
@@ -112,7 +109,7 @@ class OpenlayerClient {
112
109
  };
113
110
  this.openlayerServerUrl = 'https://api.openlayer.com/v1';
114
111
  this.version = '0.1.0a21';
115
- this.resolvedQuery = (endpoint, args = {}) => (0, request_1.resolvedQuery)(this.openlayerServerUrl, endpoint, args);
112
+ this.resolvedQuery = (endpoint, args = {}) => resolvedQuery(this.openlayerServerUrl, endpoint, args);
116
113
  /**
117
114
  * Creates a new inference pipeline in Openlayer or loads an existing one.
118
115
  * @param {string} projectId - The ID of the project containing the inference pipeline.
@@ -127,7 +124,7 @@ class OpenlayerClient {
127
124
  catch (_a) { }
128
125
  const createInferencePipelineEndpoint = `/projects/${projectId}/inference-pipelines`;
129
126
  const createInferencePipelineQuery = this.resolvedQuery(createInferencePipelineEndpoint, { version: this.version });
130
- const createInferencePipelineResponse = yield (0, node_fetch_1.default)(createInferencePipelineQuery, {
127
+ const createInferencePipelineResponse = yield fetch(createInferencePipelineQuery, {
131
128
  body: JSON.stringify({
132
129
  description: '',
133
130
  name,
@@ -159,7 +156,7 @@ class OpenlayerClient {
159
156
  catch (_b) { }
160
157
  const projectsEndpoint = '/projects';
161
158
  const projectsQuery = this.resolvedQuery(projectsEndpoint);
162
- const response = yield (0, node_fetch_1.default)(projectsQuery, {
159
+ const response = yield fetch(projectsQuery, {
163
160
  body: JSON.stringify({
164
161
  description,
165
162
  name,
@@ -196,7 +193,7 @@ class OpenlayerClient {
196
193
  version: this.version,
197
194
  };
198
195
  const inferencePipelineQuery = this.resolvedQuery(inferencePipelineEndpoint, inferencePipelineQueryParameters);
199
- const inferencePipelineResponse = yield (0, node_fetch_1.default)(inferencePipelineQuery, {
196
+ const inferencePipelineResponse = yield fetch(inferencePipelineQuery, {
200
197
  headers: {
201
198
  Authorization: `Bearer ${this.openlayerApiKey}`,
202
199
  'Content-Type': 'application/json',
@@ -225,7 +222,7 @@ class OpenlayerClient {
225
222
  version: this.version,
226
223
  };
227
224
  const projectsQuery = this.resolvedQuery(projectsEndpoint, projectsQueryParameters);
228
- const response = yield (0, node_fetch_1.default)(projectsQuery, {
225
+ const response = yield fetch(projectsQuery, {
229
226
  headers: {
230
227
  Authorization: `Bearer ${this.openlayerApiKey}`,
231
228
  'Content-Type': 'application/json',
@@ -258,11 +255,11 @@ class OpenlayerClient {
258
255
  try {
259
256
  const dataStreamEndpoint = `/inference-pipelines/${inferencePipelineId}/data-stream`;
260
257
  const dataStreamQuery = this.resolvedQuery(dataStreamEndpoint);
261
- const response = yield (0, node_fetch_1.default)(dataStreamQuery, {
258
+ const response = yield fetch(dataStreamQuery, {
262
259
  body: JSON.stringify({
263
260
  config,
264
261
  rows: [
265
- Object.assign(Object.assign({}, data), { id: (0, uuid_1.v4)(), timestamp: Math.round(((_c = data.timestamp) !== null && _c !== void 0 ? _c : Date.now()) / 1000) }),
262
+ Object.assign(Object.assign({}, data), { id: uuid(), timestamp: Math.round(((_c = data.timestamp) !== null && _c !== void 0 ? _c : Date.now()) / 1000) }),
266
263
  ],
267
264
  }),
268
265
  headers: {
@@ -290,8 +287,7 @@ class OpenlayerClient {
290
287
  }
291
288
  }
292
289
  }
293
- exports.OpenlayerClient = OpenlayerClient;
294
- class OpenAIMonitor {
290
+ export class OpenAIMonitor {
295
291
  /**
296
292
  * Constructs an OpenAIMonitor instance.
297
293
  * @param {OpenAIMonitorConstructorProps} props - The configuration properties for the OpenAI and Openlayer clients.
@@ -513,7 +509,7 @@ class OpenAIMonitor {
513
509
  openlayerApiKey,
514
510
  openlayerServerUrl,
515
511
  });
516
- this.openAIClient = new openai_1.default({
512
+ this.openAIClient = new OpenAI({
517
513
  apiKey: openAiApiKey,
518
514
  dangerouslyAllowBrowser: true,
519
515
  });
@@ -605,4 +601,3 @@ class OpenAIMonitor {
605
601
  });
606
602
  }
607
603
  }
608
- exports.OpenAIMonitor = OpenAIMonitor;
package/dist/request.js CHANGED
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryParameters = exports.resolvedQuery = void 0;
4
- const resolvedQuery = (baseUrl, endpoint, args = {}) => `${baseUrl}${endpoint}${(0, exports.queryParameters)(args)}`;
5
- exports.resolvedQuery = resolvedQuery;
6
- const queryParameters = (args) => {
1
+ export const resolvedQuery = (baseUrl, endpoint, args = {}) => `${baseUrl}${endpoint}${queryParameters(args)}`;
2
+ export const queryParameters = (args) => {
7
3
  const filteredArgs = Object.keys(args)
8
4
  .filter((key) => typeof args[key] !== 'undefined')
9
5
  .reduce((acc, arg) => {
@@ -31,4 +27,3 @@ const queryParameters = (args) => {
31
27
  .join('&');
32
28
  return `?${resolvedArgs}`;
33
29
  };
34
- exports.queryParameters = queryParameters;
package/dist/run.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "openlayer",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "The Openlayer TypeScript client",
5
- "main": "dist/index.js",
6
5
  "types": "dist/index.d.ts",
7
6
  "scripts": {
8
7
  "prepublish": "npm run build",
@@ -38,7 +37,6 @@
38
37
  "./run": {
39
38
  "import": "./lib/run.ts",
40
39
  "types": "./lib/run.d.ts"
41
- },
42
- "./dist/index.js": "./dist/index.js"
40
+ }
43
41
  }
44
42
  }
package/tsconfig.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "exclude": ["node_modules", "dist", "/lib/request", "examples"],
3
3
  "compilerOptions": {
4
4
  "target": "ES2015",
5
- "module": "CommonJS",
5
+ "module": "esnext",
6
+ "moduleResolution": "node",
6
7
  "declaration": true,
7
8
  "outDir": "./dist",
8
9
  "strict": true