openlayer 0.1.43 → 0.1.44

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