openlayer 0.0.6 → 0.0.8

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 (2) hide show
  1. package/dist/index.js +10 -4
  2. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  const openai_1 = require("openai");
20
+ const uuid_1 = require("uuid");
20
21
  const request_1 = require("./utils/request");
21
22
  class OpenAIMonitor {
22
23
  constructor({ openAiApiKey, openlayerApiKey, openlayerInferencePipelineName, openlayerProjectName, openlayerServerUrl, }) {
@@ -28,7 +29,7 @@ class OpenAIMonitor {
28
29
  .map(({ content }) => content)
29
30
  .join('\n')
30
31
  .trim();
31
- this.resolvedQuery = (endpoint, args = {}) => (0, request_1.resolvedQuery)(this.openlayerServerUrl, endpoint, Object.assign({ version: this.version }, args));
32
+ this.resolvedQuery = (endpoint, args = {}) => (0, request_1.resolvedQuery)(this.openlayerServerUrl, endpoint, args);
32
33
  this.uploadDataToOpenlayer = (data) => __awaiter(this, void 0, void 0, function* () {
33
34
  const uploadToInferencePipeline = (id) => __awaiter(this, void 0, void 0, function* () {
34
35
  const dataStreamEndpoint = `/inference-pipelines/${id}/data-stream`;
@@ -36,14 +37,17 @@ class OpenAIMonitor {
36
37
  const response = yield fetch(dataStreamQuery, {
37
38
  body: JSON.stringify({
38
39
  config: {
39
- inferenceIdColumnName: 'inference_id',
40
+ groundTruthColumnName: null,
41
+ inferenceIdColumnName: 'id',
40
42
  inputVariableNames: ['input'],
41
43
  latencyColumnName: 'latency',
42
44
  outputColumnName: 'output',
43
45
  timestampColumnName: 'timestamp',
44
46
  tokensColumnName: 'tokens',
45
47
  },
46
- rows: [data],
48
+ rows: [
49
+ Object.assign({ id: (0, uuid_1.v4)() }, data),
50
+ ],
47
51
  }),
48
52
  headers: {
49
53
  Authorization: `Bearer ${this.openlayerApiKey}`,
@@ -64,6 +68,7 @@ class OpenAIMonitor {
64
68
  const projectsEndpoint = '/projects';
65
69
  const projectsQueryParameters = {
66
70
  name: this.openlayerProjectName,
71
+ version: this.version,
67
72
  };
68
73
  const projectsQuery = this.resolvedQuery(projectsEndpoint, projectsQueryParameters);
69
74
  const projectsResponse = yield fetch(projectsQuery, {
@@ -84,6 +89,7 @@ class OpenAIMonitor {
84
89
  const inferencePipelineEndpoint = `/projects/${project.id}/inference-pipelines`;
85
90
  const inferencePipelineQueryParameters = {
86
91
  name: this.openlayerInferencePipelineName,
92
+ version: this.version,
87
93
  };
88
94
  const inferencePipelineQuery = this.resolvedQuery(inferencePipelineEndpoint, inferencePipelineQueryParameters);
89
95
  const inferencePipelineResponse = yield fetch(inferencePipelineQuery, {
@@ -104,7 +110,7 @@ class OpenAIMonitor {
104
110
  }
105
111
  else {
106
112
  const createInferencePipelineEndpoint = `/projects/${project.id}/inference-pipelines`;
107
- const createInferencePipelineQuery = this.resolvedQuery(createInferencePipelineEndpoint);
113
+ const createInferencePipelineQuery = this.resolvedQuery(createInferencePipelineEndpoint, { version: this.version });
108
114
  const createInferencePipelineResponse = yield fetch(createInferencePipelineQuery, {
109
115
  body: JSON.stringify({
110
116
  description: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openlayer",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "The Openlayer TypeScript client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,9 +19,11 @@
19
19
  "eslint-plugin-prettier": "^5.0.1",
20
20
  "eslint-plugin-typescript-sort-keys": "^3.1.0",
21
21
  "node-fetch": "^3.3.2",
22
- "openai": "^4.19.0"
22
+ "openai": "^4.19.0",
23
+ "uuid": "^9.0.1"
23
24
  },
24
25
  "devDependencies": {
26
+ "@types/uuid": "^9.0.7",
25
27
  "typescript": "^5.2.2"
26
28
  }
27
29
  }