openlayer 0.0.1-alpha.0 → 0.0.1-alpha.1

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 (43) hide show
  1. package/README.md +10 -6
  2. package/_shims/web-runtime.js +1 -1
  3. package/_shims/web-runtime.js.map +1 -1
  4. package/_shims/web-runtime.mjs +1 -1
  5. package/_shims/web-runtime.mjs.map +1 -1
  6. package/lib/core/cli.d.ts +15 -1
  7. package/lib/core/cli.d.ts.map +1 -1
  8. package/lib/core/cli.js +3 -4
  9. package/lib/core/cli.js.map +1 -1
  10. package/lib/core/cli.mjs +4 -3
  11. package/lib/core/cli.mjs.map +1 -1
  12. package/lib/core/openai-monitor.d.ts +54 -0
  13. package/lib/core/openai-monitor.d.ts.map +1 -0
  14. package/lib/core/openai-monitor.js +376 -0
  15. package/lib/core/openai-monitor.js.map +1 -0
  16. package/lib/core/openai-monitor.mjs +371 -0
  17. package/lib/core/openai-monitor.mjs.map +1 -0
  18. package/package.json +2 -2
  19. package/src/_shims/web-runtime.ts +1 -1
  20. package/src/lib/core/cli.ts +21 -5
  21. package/src/lib/core/index.d.ts +2 -0
  22. package/src/lib/core/openai-monitor.ts +470 -0
  23. package/src/lib/index.d.ts +1 -0
  24. package/src/version.ts +1 -1
  25. package/version.d.ts +1 -1
  26. package/version.js +1 -1
  27. package/version.js.map +1 -1
  28. package/version.mjs +1 -1
  29. package/version.mjs.map +1 -1
  30. package/lib/core/index.d.ts +0 -237
  31. package/lib/core/index.d.ts.map +0 -1
  32. package/lib/core/index.js +0 -635
  33. package/lib/core/index.js.map +0 -1
  34. package/lib/core/index.mjs +0 -627
  35. package/lib/core/index.mjs.map +0 -1
  36. package/lib/core/run.d.ts +0 -14
  37. package/lib/core/run.d.ts.map +0 -1
  38. package/lib/core/run.js +0 -3
  39. package/lib/core/run.js.map +0 -1
  40. package/lib/core/run.mjs +0 -2
  41. package/lib/core/run.mjs.map +0 -1
  42. package/src/lib/core/index.ts +0 -1067
  43. package/src/lib/core/run.ts +0 -14
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Openlayer TypeScript API Library
1
+ # Openlayer Node API Library
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/openlayer.svg)](https://npmjs.org/package/openlayer)
3
+ [![NPM version](https://img.shields.io/npm/v/openlayer.svg)](https://npmjs.org/package/openlayer) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/openlayer)
4
4
 
5
5
  This library provides convenient access to the Openlayer REST API from server-side TypeScript or JavaScript.
6
6
 
@@ -11,8 +11,12 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
11
11
  ## Installation
12
12
 
13
13
  ```sh
14
- npm i openlayer
14
+ npm install git+ssh://git@github.com:openlayer-ai/openlayer-ts.git
15
15
  ```
16
+
17
+ > [!NOTE]
18
+ > Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install openlayer`
19
+
16
20
  ## Usage
17
21
 
18
22
  The full API of this library can be found in [api.md](api.md).
@@ -139,7 +143,7 @@ main();
139
143
  Error codes are as followed:
140
144
 
141
145
  | Status Code | Error Type |
142
- |-------------|----------------------------|
146
+ | ----------- | -------------------------- |
143
147
  | 400 | `BadRequestError` |
144
148
  | 401 | `AuthenticationError` |
145
149
  | 403 | `PermissionDeniedError` |
@@ -310,7 +314,7 @@ import Openlayer from 'openlayer';
310
314
  ```
311
315
 
312
316
  To do the inverse, add `import "openlayer/shims/node"` (which does import polyfills).
313
- This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/openlayer-node/tree/main/src/_shims#readme)).
317
+ This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/openlayer-ai/openlayer-ts/tree/main/src/_shims#readme)).
314
318
 
315
319
  ### Logging and middleware
316
320
 
@@ -387,7 +391,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
387
391
 
388
392
  We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
389
393
 
390
- We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/openlayer-node/issues) with questions, bugs, or suggestions.
394
+ We are keen for your feedback; please open an [issue](https://www.github.com/openlayer-ai/openlayer-ts/issues) with questions, bugs, or suggestions.
391
395
 
392
396
  ## Requirements
393
397
 
@@ -69,7 +69,7 @@ function getRuntime({ manuallyImported } = {}) {
69
69
  }),
70
70
  getDefaultAgent: (url) => undefined,
71
71
  fileFromPath: () => {
72
- throw new Error('The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/openlayer-node#file-uploads');
72
+ throw new Error('The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openlayer-ai/openlayer-ts#file-uploads');
73
73
  },
74
74
  isFsReadStream: (value) => false,
75
75
  };
@@ -1 +1 @@
1
- {"version":3,"file":"web-runtime.js","sourceRoot":"","sources":["../src/_shims/web-runtime.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sDAAgD;AAIhD,SAAgB,UAAU,CAAC,EAAE,gBAAgB,KAAqC,EAAE;IAClF,MAAM,cAAc,GAClB,gBAAgB,CAAC,CAAC;QAChB,+BAA+B;QACjC,CAAC,CAAC;;;CAGL,CAAC;IAEA,IAAI,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;IAC1C,IAAI;QACF,aAAa;QACb,MAAM,GAAG,KAAK,CAAC;QACf,aAAa;QACb,QAAQ,GAAG,OAAO,CAAC;QACnB,aAAa;QACb,SAAS,GAAG,QAAQ,CAAC;QACrB,aAAa;QACb,QAAQ,GAAG,OAAO,CAAC;KACpB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,iEACG,KAAa,CAAC,OACjB,KAAK,cAAc,EAAE,CACtB,CAAC;KACH;IAED,OAAO;QACL,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,SAAS;QACnB,OAAO,EA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AC,CAAC,CAAC,CACnC,MAAM,IAAI;YACR,aAAa;YACb;gBACE,MAAM,IAAI,KAAK,CACb,iFAAiF,cAAc,EAAE,CAClG,CAAC;YACJ,CAAC;SACF,CACF;QACH,cAAc;QACZ,aAAa;QACb,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CACvD,MAAM,cAAc;YAClB,aAAa;YACb;gBACE,MAAM,IAAI,KAAK,CACb,uFAAuF,cAAc,EAAE,CACxG,CAAC;YACJ,CAAC;SACF,CACF;QACH,0BAA0B,EAAE,KAAK;QAC/B,aAAa;QACb,IAAc,EACd,IAAuB,EACK,EAAE,CAAC,CAAC;YAChC,GAAG,IAAI;YACP,IAAI,EAAE,IAAI,6BAAa,CAAC,IAAI,CAAQ;SACrC,CAAC;QACF,eAAe,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS;QAC3C,YAAY,EAAE,GAAG,EAAE;YACjB,MAAM,IAAI,KAAK,CACb,uJAAuJ,CACxJ,CAAC;QACJ,CAAC;QACD,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK;KACtC,CAAC;AACJ,CAAC;AA/FD,gCA+FC"}
@@ -63,7 +63,7 @@ export function getRuntime({ manuallyImported } = {}) {
63
63
  }),
64
64
  getDefaultAgent: (url) => undefined,
65
65
  fileFromPath: () => {
66
- throw new Error('The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/openlayer-node#file-uploads');
66
+ throw new Error('The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openlayer-ai/openlayer-ts#file-uploads');
67
67
  },
68
68
  isFsReadStream: (value) => false,
69
69
  };
@@ -1 +1 @@
1
- {"version":3,"file":"web-runtime.mjs","sourceRoot":"","sources":["../src/_shims/web-runtime.ts"],"names":[],"mappings":"OAGO,EAAE,aAAa,EAAE;AAIxB,MAAM,UAAU,UAAU,CAAC,EAAE,gBAAgB,KAAqC,EAAE;IAClF,M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AAE,EAAE,CAAC,KAAK;KACtC,CAAC;AACJ,CAAC"}
package/lib/core/cli.d.ts CHANGED
@@ -1,7 +1,21 @@
1
- export declare class CLIHandler {
1
+ export interface RunReturn {
2
+ otherFields: {
3
+ [key: string]: any;
4
+ };
5
+ output: any;
6
+ }
7
+ export interface Config {
8
+ inputVariableNames?: string[];
9
+ metadata: {
10
+ outputTimestamp: number;
11
+ };
12
+ outputColumnName: string;
13
+ }
14
+ declare class CLIHandler {
2
15
  private run;
3
16
  constructor(runFunction: (...args: any[]) => Promise<any>);
4
17
  runFromCLI(): void;
5
18
  private writeOutput;
6
19
  }
20
+ export default CLIHandler;
7
21
  //# sourceMappingURL=cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/lib/core/cli.ts"],"names":[],"mappings":"AAiBA,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAmC;gBAElC,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC;IAIlD,UAAU;IAoCjB,OAAO,CAAC,WAAW;CAmBpB"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/lib/core/cli.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACpC,MAAM,EAAE,GAAG,CAAC;CACb;AAGD,MAAM,WAAW,MAAM;IACrB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE;QACR,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,cAAM,UAAU;IACd,OAAO,CAAC,GAAG,CAAmC;gBAElC,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC;IAIlD,UAAU;IAoCjB,OAAO,CAAC,WAAW;CAmBpB;AAED,eAAe,UAAU,CAAC"}
package/lib/core/cli.js CHANGED
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
34
34
  return result;
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.CLIHandler = void 0;
38
37
  const commander_1 = require("commander");
39
38
  const fs = __importStar(require("fs"));
40
39
  const path = __importStar(require("path"));
@@ -83,9 +82,9 @@ class CLIHandler {
83
82
  const configPath = path.join(outputDirPath, 'config.json');
84
83
  fs.writeFileSync(datasetPath, JSON.stringify(results, null, 4), 'utf8');
85
84
  fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf8');
86
- console.log(`Output written to ${datasetPath}`);
87
- console.log(`Config written to ${configPath}`);
85
+ console.info(`Output written to ${datasetPath}`);
86
+ console.info(`Config written to ${configPath}`);
88
87
  }
89
88
  }
90
- exports.CLIHandler = CLIHandler;
89
+ exports.default = CLIHandler;
91
90
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/lib/core/cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAG7B,MAAa,UAAU;IAGrB,YAAY,WAA6C;QACvD,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC;IACzB,CAAC;IAEM,UAAU;QACf,mBAAO;aACJ,cAAc,CAAC,uBAAuB,EAAE,qBAAqB,CAAC;aAC9D,cAAc,CAAC,qBAAqB,EAAE,4BAA4B,CAAC,CAAC;QAEvE,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE5B,MAAM,OAAO,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAE3C,eA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AAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACxE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAEtE,OAAO,CAAC,IAAI,CAAC,qBAAqB,WAAW,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;CACF;AAED,kBAAe,UAAU,CAAC"}
package/lib/core/cli.mjs CHANGED
@@ -12,7 +12,7 @@
12
12
  import { program } from 'commander';
13
13
  import * as fs from 'fs';
14
14
  import * as path from 'path';
15
- export class CLIHandler {
15
+ class CLIHandler {
16
16
  constructor(runFunction) {
17
17
  this.run = runFunction;
18
18
  }
@@ -57,8 +57,9 @@ export class CLIHandler {
57
57
  const configPath = path.join(outputDirPath, 'config.json');
58
58
  fs.writeFileSync(datasetPath, JSON.stringify(results, null, 4), 'utf8');
59
59
  fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf8');
60
- console.log(`Output written to ${datasetPath}`);
61
- console.log(`Config written to ${configPath}`);
60
+ console.info(`Output written to ${datasetPath}`);
61
+ console.info(`Config written to ${configPath}`);
62
62
  }
63
63
  }
64
+ export default CLIHandler;
64
65
  //# sourceMappingURL=cli.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../../src/lib/core/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;OAEI,EAAE,OAAO,EAAE,MAAM,WAAW;OAC5B,KAAK,EAAE,MAAM,IAAI;OACjB,KAAK,IAAI,MAAM,MAAM;AAG5B,MAAM,OAAO,UAAU;IAGrB,YAAY,WAA6C;QACvD,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC;IACzB,C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A2D;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9C,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEjD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QAE3D,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACxE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAEtE,OAAO,CAAC,IAAI,CAAC,qBAAqB,WAAW,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { RequestOptions } from 'openai/core';
2
+ import { ChatCompletion, ChatCompletionChunk, ChatCompletionCreateParams, Completion, CompletionCreateParams } from 'openai/resources';
3
+ import { Run } from 'openai/resources/beta/threads/runs/runs';
4
+ import { Stream } from 'openai/streaming';
5
+ import Openlayer from "../../index.js";
6
+ type OpenAIMonitorConstructorProps = {
7
+ openAiApiKey: string;
8
+ openlayerClient: Openlayer;
9
+ openlayerInferencePipelineId: string;
10
+ };
11
+ declare class OpenAIMonitor {
12
+ private openlayerClient;
13
+ private openAIClient;
14
+ private openlayerInferencePipelineId;
15
+ private defaultConfig;
16
+ /**
17
+ * Constructs an OpenAIMonitor instance.
18
+ * @param {OpenAIMonitorConstructorProps} props - The configuration properties for the OpenAI and Openlayer clients.
19
+ */
20
+ constructor({ openAiApiKey, openlayerClient, openlayerInferencePipelineId, }: OpenAIMonitorConstructorProps);
21
+ private cost;
22
+ private chatCompletionPrompt;
23
+ private threadPrompt;
24
+ private inputVariables;
25
+ /**
26
+ * Creates a chat completion using the OpenAI client and streams the result to Openlayer.
27
+ * @param {ChatCompletionCreateParams} body - The parameters for creating a chat completion.
28
+ * @param {RequestOptions} [options] - Optional request options.
29
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
30
+ * @returns {Promise<ChatCompletion | Stream<ChatCompletionChunk>>} Promise of a ChatCompletion or a Stream
31
+ * @throws {Error} Throws errors from the OpenAI client.
32
+ */
33
+ createChatCompletion: (body: ChatCompletionCreateParams, options?: RequestOptions, additionalLogs?: Openlayer.RequestOptions<any> | undefined) => Promise<ChatCompletion | Stream<ChatCompletionChunk>>;
34
+ /**
35
+ * Creates a completion using the OpenAI client and streams the result to Openlayer.
36
+ * @param {CompletionCreateParams} body - The parameters for creating a completion.
37
+ * @param {RequestOptions} [options] - Optional request options.
38
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
39
+ * @returns {Promise<Completion | Stream<Completion>>} Promise that resolves to a Completion or a Stream.
40
+ * @throws {Error} Throws errors from the OpenAI client.
41
+ */
42
+ createCompletion: (body: CompletionCreateParams, options?: RequestOptions, additionalLogs?: Openlayer.RequestOptions<any> | undefined) => Promise<Completion | Stream<Completion>>;
43
+ /**
44
+ * Monitor a run from an OpenAI assistant.
45
+ * Once the run is completed, the thread data is published to Openlayer,
46
+ * along with the latency, cost, and number of tokens used.
47
+ * @param {Run} run - The run created by the OpenAI assistant.
48
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
49
+ * @returns {Promise<void>} A promise that resolves when the run data has been successfully published to Openlayer.
50
+ */
51
+ monitorThreadRun(run: Run, additionalLogs?: Openlayer.RequestOptions<any> | undefined): Promise<void>;
52
+ }
53
+ export default OpenAIMonitor;
54
+ //# sourceMappingURL=openai-monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-monitor.d.ts","sourceRoot":"","sources":["../../src/lib/core/openai-monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAE1B,UAAU,EACV,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,yCAAyC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,KAAK,6BAA6B,GAAG;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,SAAS,CAAC;IAC3B,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAAC;AAkFF,cAAM,aAAa;IACjB,OAAO,CAAC,eAAe,CAAY;IAEnC,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,4BAA4B,CAAS;IAE7C,OAAO,CAAC,aAAa,CAOnB;IAEF;;;OAGG;gBACS,EACV,YAAY,EACZ,eAAe,EACf,4BAA4B,GAC7B,EAAE,6BAA6B;IAUhC,OAAO,CAAC,IAAI,CAKV;IAEF,OAAO,CAAC,oBAAoB,CAStB;IAEN,OAAO,CAAC,YAAY,CAyBlB;IAEF,OAAO,CAAC,cAAc,CAgBpB;IAEF;;;;;;;OAOG;IACI,oBAAoB,SACnB,0BAA0B,YACtB,cAAc,mBACP,wBAAwB,CAAC,GAAG,CAAC,GAAG,SAAS,KACzD,QAAQ,cAAc,GAAG,OAAO,mBAAmB,CAAC,CAAC,CAkFtD;IAEF;;;;;;;OAOG;IACI,gBAAgB,SACf,sBAAsB,YAClB,cAAc,mBACP,wBAAwB,CAAC,GAAG,CAAC,GAAG,SAAS,KACzD,QAAQ,UAAU,GAAG,OAAO,UAAU,CAAC,CAAC,CAuFzC;IAEF;;;;;;;OAOG;IACU,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS;CAgEnG;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,376 @@
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
+ const openai_1 = __importDefault(require("openai"));
7
+ const OpenAIPricing = {
8
+ 'babbage-002': {
9
+ input: 0.0004,
10
+ output: 0.0004,
11
+ },
12
+ 'davinci-002': {
13
+ input: 0.002,
14
+ output: 0.002,
15
+ },
16
+ 'gpt-3.5-turbo': {
17
+ input: 0.0005,
18
+ output: 0.0015,
19
+ },
20
+ 'gpt-3.5-turbo-0125': {
21
+ input: 0.0005,
22
+ output: 0.0015,
23
+ },
24
+ 'gpt-3.5-turbo-0301': {
25
+ input: 0.0015,
26
+ output: 0.002,
27
+ },
28
+ 'gpt-3.5-turbo-0613': {
29
+ input: 0.0015,
30
+ output: 0.002,
31
+ },
32
+ 'gpt-3.5-turbo-1106': {
33
+ input: 0.001,
34
+ output: 0.002,
35
+ },
36
+ 'gpt-3.5-turbo-16k-0613': {
37
+ input: 0.003,
38
+ output: 0.004,
39
+ },
40
+ 'gpt-3.5-turbo-instruct': {
41
+ input: 0.0015,
42
+ output: 0.002,
43
+ },
44
+ 'gpt-4': {
45
+ input: 0.03,
46
+ output: 0.06,
47
+ },
48
+ 'gpt-4-0125-preview': {
49
+ input: 0.01,
50
+ output: 0.03,
51
+ },
52
+ 'gpt-4-0314': {
53
+ input: 0.03,
54
+ output: 0.06,
55
+ },
56
+ 'gpt-4-0613': {
57
+ input: 0.03,
58
+ output: 0.06,
59
+ },
60
+ 'gpt-4-1106-preview': {
61
+ input: 0.01,
62
+ output: 0.03,
63
+ },
64
+ 'gpt-4-1106-vision-preview': {
65
+ input: 0.01,
66
+ output: 0.03,
67
+ },
68
+ 'gpt-4-32k': {
69
+ input: 0.06,
70
+ output: 0.12,
71
+ },
72
+ 'gpt-4-32k-0314': {
73
+ input: 0.06,
74
+ output: 0.12,
75
+ },
76
+ 'gpt-4-32k-0613': {
77
+ input: 0.03,
78
+ output: 0.06,
79
+ },
80
+ };
81
+ class OpenAIMonitor {
82
+ /**
83
+ * Constructs an OpenAIMonitor instance.
84
+ * @param {OpenAIMonitorConstructorProps} props - The configuration properties for the OpenAI and Openlayer clients.
85
+ */
86
+ constructor({ openAiApiKey, openlayerClient, openlayerInferencePipelineId, }) {
87
+ this.defaultConfig = {
88
+ costColumnName: 'cost',
89
+ inferenceIdColumnName: 'id',
90
+ latencyColumnName: 'latency',
91
+ numOfTokenColumnName: 'tokens',
92
+ outputColumnName: 'output',
93
+ timestampColumnName: 'timestamp',
94
+ };
95
+ this.cost = (model, inputTokens, outputTokens) => {
96
+ const pricing = OpenAIPricing[model];
97
+ const inputCost = typeof pricing === 'undefined' ? undefined : (inputTokens / 1000) * pricing.input;
98
+ const outputCost = typeof pricing === 'undefined' ? undefined : (outputTokens / 1000) * pricing.output;
99
+ return typeof pricing === 'undefined' ? undefined : (inputCost ?? 0) + (outputCost ?? 0);
100
+ };
101
+ this.chatCompletionPrompt = (fromMessages) => fromMessages.map(({ content, role }, i) => ({
102
+ content: role === 'user' ? `{{ message_${i} }}`
103
+ : content === null || typeof content === 'undefined' ? ''
104
+ : content,
105
+ role,
106
+ }));
107
+ this.threadPrompt = async (fromMessages) => {
108
+ const messages = [];
109
+ for await (const page of fromMessages.iterPages()) {
110
+ messages.push(...page.getPaginatedItems());
111
+ }
112
+ return messages
113
+ .map(({ content, role }) => content.map((item) => ({
114
+ content: (() => {
115
+ switch (item.type) {
116
+ case 'image_file':
117
+ return item.image_file.file_id;
118
+ case 'text':
119
+ return item.text.value;
120
+ default:
121
+ return '';
122
+ }
123
+ })(),
124
+ role,
125
+ })))
126
+ .flat();
127
+ };
128
+ this.inputVariables = (fromPrompt, andMessages) => {
129
+ const inputVariableNames = fromPrompt
130
+ .filter(({ role }) => role === 'user')
131
+ .map(({ content }) => String(content).replace(/{{\s*|\s*}}/g, ''));
132
+ const inputVariables = andMessages
133
+ .filter(({ role }) => role === 'user')
134
+ .map(({ content }) => content);
135
+ const inputVariablesMap = inputVariableNames.reduce((acc, name, i) => ({ ...acc, [name]: inputVariables[i] }), {});
136
+ return { inputVariableNames, inputVariables, inputVariablesMap };
137
+ };
138
+ /**
139
+ * Creates a chat completion using the OpenAI client and streams the result to Openlayer.
140
+ * @param {ChatCompletionCreateParams} body - The parameters for creating a chat completion.
141
+ * @param {RequestOptions} [options] - Optional request options.
142
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
143
+ * @returns {Promise<ChatCompletion | Stream<ChatCompletionChunk>>} Promise of a ChatCompletion or a Stream
144
+ * @throws {Error} Throws errors from the OpenAI client.
145
+ */
146
+ this.createChatCompletion = async (body, options, additionalLogs) => {
147
+ // Start a timer to measure latency
148
+ const startTime = Date.now();
149
+ // Accumulate output for streamed responses
150
+ let streamedOutput = '';
151
+ const response = await this.openAIClient.chat.completions.create(body, options);
152
+ if (this.openlayerInferencePipelineId.length > 0) {
153
+ try {
154
+ const prompt = this.chatCompletionPrompt(body.messages);
155
+ const { inputVariableNames, inputVariablesMap } = this.inputVariables(prompt, body.messages);
156
+ const config = {
157
+ ...this.defaultConfig,
158
+ inputVariableNames,
159
+ prompt,
160
+ };
161
+ if (body.stream) {
162
+ const streamedResponse = response;
163
+ for await (const chunk of streamedResponse) {
164
+ const [choice] = chunk.choices;
165
+ // Process each chunk - for example, accumulate input data
166
+ const chunkOutput = choice?.delta.content ?? '';
167
+ streamedOutput += chunkOutput;
168
+ }
169
+ const endTime = Date.now();
170
+ const latency = endTime - startTime;
171
+ this.openlayerClient.inferencePipelines.data.stream(this.openlayerInferencePipelineId, {
172
+ config,
173
+ rows: [
174
+ {
175
+ latency,
176
+ output: streamedOutput,
177
+ timestamp: startTime,
178
+ ...inputVariablesMap,
179
+ ...additionalLogs,
180
+ },
181
+ ],
182
+ });
183
+ }
184
+ else {
185
+ const nonStreamedResponse = response;
186
+ // Handle regular (non-streamed) response
187
+ const endTime = Date.now();
188
+ const latency = endTime - startTime;
189
+ const [choice] = nonStreamedResponse.choices;
190
+ const output = choice?.message.content;
191
+ const tokens = nonStreamedResponse.usage?.total_tokens ?? 0;
192
+ const inputTokens = nonStreamedResponse.usage?.prompt_tokens ?? 0;
193
+ const outputTokens = nonStreamedResponse.usage?.completion_tokens ?? 0;
194
+ const cost = this.cost(nonStreamedResponse.model, inputTokens, outputTokens);
195
+ if (typeof output === 'string') {
196
+ this.openlayerClient.inferencePipelines.data.stream(this.openlayerInferencePipelineId, {
197
+ config,
198
+ rows: [
199
+ {
200
+ cost,
201
+ latency,
202
+ model: nonStreamedResponse.model,
203
+ output,
204
+ timestamp: startTime,
205
+ tokens,
206
+ ...inputVariablesMap,
207
+ ...additionalLogs,
208
+ },
209
+ ],
210
+ });
211
+ }
212
+ else {
213
+ console.error('No output received from OpenAI.');
214
+ }
215
+ }
216
+ }
217
+ catch (error) {
218
+ console.error(error);
219
+ }
220
+ }
221
+ return response;
222
+ };
223
+ /**
224
+ * Creates a completion using the OpenAI client and streams the result to Openlayer.
225
+ * @param {CompletionCreateParams} body - The parameters for creating a completion.
226
+ * @param {RequestOptions} [options] - Optional request options.
227
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
228
+ * @returns {Promise<Completion | Stream<Completion>>} Promise that resolves to a Completion or a Stream.
229
+ * @throws {Error} Throws errors from the OpenAI client.
230
+ */
231
+ this.createCompletion = async (body, options, additionalLogs) => {
232
+ if (!body.prompt) {
233
+ console.error('No prompt provided.');
234
+ }
235
+ // Start a timer to measure latency
236
+ const startTime = Date.now();
237
+ // Accumulate output and tokens data for streamed responses
238
+ let streamedModel = body.model;
239
+ let streamedOutput = '';
240
+ let streamedTokens = 0;
241
+ let streamedInputTokens = 0;
242
+ let streamedOutputTokens = 0;
243
+ const response = await this.openAIClient.completions.create(body, options);
244
+ if (this.openlayerInferencePipelineId.length > 0) {
245
+ try {
246
+ const config = {
247
+ ...this.defaultConfig,
248
+ inputVariableNames: ['input'],
249
+ };
250
+ if (body.stream) {
251
+ const streamedResponse = response;
252
+ for await (const chunk of streamedResponse) {
253
+ const [choice] = chunk.choices;
254
+ // Process each chunk - for example, accumulate input data
255
+ streamedModel = chunk.model;
256
+ streamedOutput += choice?.text.trim();
257
+ streamedTokens += chunk.usage?.total_tokens ?? 0;
258
+ streamedInputTokens += chunk.usage?.prompt_tokens ?? 0;
259
+ streamedOutputTokens += chunk.usage?.completion_tokens ?? 0;
260
+ }
261
+ const endTime = Date.now();
262
+ const latency = endTime - startTime;
263
+ const cost = this.cost(streamedModel, streamedInputTokens, streamedOutputTokens);
264
+ this.openlayerClient.inferencePipelines.data.stream(this.openlayerInferencePipelineId, {
265
+ config,
266
+ rows: [
267
+ {
268
+ cost,
269
+ input: body.prompt,
270
+ latency,
271
+ output: streamedOutput,
272
+ timestamp: startTime,
273
+ tokens: streamedTokens,
274
+ ...additionalLogs,
275
+ },
276
+ ],
277
+ });
278
+ }
279
+ else {
280
+ const nonStreamedResponse = response;
281
+ const [choice] = nonStreamedResponse.choices;
282
+ // Handle regular (non-streamed) response
283
+ const endTime = Date.now();
284
+ const latency = endTime - startTime;
285
+ const tokens = nonStreamedResponse.usage?.total_tokens ?? 0;
286
+ const inputTokens = nonStreamedResponse.usage?.prompt_tokens ?? 0;
287
+ const outputTokens = nonStreamedResponse.usage?.completion_tokens ?? 0;
288
+ const cost = this.cost(nonStreamedResponse.model, inputTokens, outputTokens);
289
+ this.openlayerClient.inferencePipelines.data.stream(this.openlayerInferencePipelineId, {
290
+ config,
291
+ rows: [
292
+ {
293
+ cost,
294
+ input: body.prompt,
295
+ latency,
296
+ output: choice?.text ?? '',
297
+ timestamp: startTime,
298
+ tokens,
299
+ ...additionalLogs,
300
+ },
301
+ ],
302
+ });
303
+ }
304
+ }
305
+ catch (error) {
306
+ console.error(error);
307
+ }
308
+ }
309
+ return response;
310
+ };
311
+ this.openlayerInferencePipelineId = openlayerInferencePipelineId;
312
+ this.openlayerClient = openlayerClient;
313
+ this.openAIClient = new openai_1.default({
314
+ apiKey: openAiApiKey,
315
+ dangerouslyAllowBrowser: true,
316
+ });
317
+ }
318
+ /**
319
+ * Monitor a run from an OpenAI assistant.
320
+ * Once the run is completed, the thread data is published to Openlayer,
321
+ * along with the latency, cost, and number of tokens used.
322
+ * @param {Run} run - The run created by the OpenAI assistant.
323
+ * @param {Openlayer.RequestOptions<any> | undefined} [additionalLogs] - Optional metadata logs to include with the request sent to Openlayer.
324
+ * @returns {Promise<void>} A promise that resolves when the run data has been successfully published to Openlayer.
325
+ */
326
+ async monitorThreadRun(run, additionalLogs) {
327
+ if (run.status !== 'completed' || this.openlayerInferencePipelineId.length === 0) {
328
+ return;
329
+ }
330
+ try {
331
+ const { assistant_id, completed_at, created_at, model, thread_id,
332
+ // @ts-ignore
333
+ usage, } = run;
334
+ // @ts-ignore
335
+ const { completion_tokens, prompt_tokens, total_tokens } = typeof usage === 'undefined' || typeof usage !== 'object' || usage === null ? {} : usage;
336
+ const cost = this.cost(model, prompt_tokens, completion_tokens);
337
+ const latency = completed_at === null || created_at === null || isNaN(completed_at) || isNaN(created_at) ?
338
+ undefined
339
+ : (completed_at - created_at) * 1000;
340
+ const messages = await this.openAIClient.beta.threads.messages.list(thread_id, { order: 'asc' });
341
+ const populatedPrompt = await this.threadPrompt(messages);
342
+ const prompt = this.chatCompletionPrompt(populatedPrompt);
343
+ const { inputVariableNames, inputVariablesMap } = this.inputVariables(prompt, populatedPrompt);
344
+ const config = {
345
+ ...this.defaultConfig,
346
+ inputVariableNames,
347
+ prompt: prompt.slice(0, prompt.length - 1),
348
+ };
349
+ const output = prompt[prompt.length - 1]?.content;
350
+ const resolvedOutput = typeof output === 'string' ? output
351
+ : typeof output === 'undefined' || output === null ? ''
352
+ : `${output}`;
353
+ this.openlayerClient.inferencePipelines.data.stream(this.openlayerInferencePipelineId, {
354
+ config,
355
+ rows: [
356
+ {
357
+ cost,
358
+ latency,
359
+ openai_assistant_id: assistant_id,
360
+ openai_thread_id: thread_id,
361
+ output: resolvedOutput,
362
+ timestamp: run.created_at,
363
+ tokens: total_tokens,
364
+ ...inputVariablesMap,
365
+ ...additionalLogs,
366
+ },
367
+ ],
368
+ });
369
+ }
370
+ catch (error) {
371
+ console.error('Error logging thread run:', error);
372
+ }
373
+ }
374
+ }
375
+ exports.default = OpenAIMonitor;
376
+ //# sourceMappingURL=openai-monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-monitor.js","sourceRoot":"","sources":["../../src/lib/core/openai-monitor.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AA0B5B,MAAM,aAAa,GAA+B;IAChD,aAAa,EAAE;QACb,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,aAAa,EAAE;QACb,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;KACd;IACD,eAAe,EAAE;QACf,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,KAAK;KACd;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,KAAK;KACd;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;KACd;IACD,wBAAwB,EAAE;QACxB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;KACd;IACD,wBA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