@revenium/perplexity 1.0.21 → 1.0.23

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/README.md CHANGED
@@ -303,7 +303,9 @@ REVENIUM_METERING_BASE_URL="https://api.revenium.io/meter"
303
303
 
304
304
  ```bash
305
305
  # Perplexity AI examples
306
-
306
+ ## Change type to commonjs in package.json
307
+ "type": "commonjs",
308
+ # Then run any of the following
307
309
  npm run e-basic # Basic chat completion
308
310
  npm run e-streaming # Streaming response
309
311
  npm run e-enhanced # Enhanced request
@@ -462,6 +464,12 @@ export REVENIUM_METERING_API_KEY="your-actual-revenium-key"
462
464
  }
463
465
  ```
464
466
 
467
+ ```json
468
+ {
469
+ "type": "commonjs"
470
+ }
471
+ ```
472
+
465
473
  This will show:
466
474
 
467
475
  - Request/response details
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Metering = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const calculateDurationMs_1 = require("../utils/calculateDurationMs");
6
- const formatTimeStamp_1 = require("../utils/formatTimeStamp");
6
+ const formatTimestamp_1 = require("../utils/formatTimestamp");
7
7
  const generateTransactionId_1 = require("../utils/generateTransactionId");
8
8
  const Logger_1 = require("./Logger");
9
9
  class Metering {
@@ -67,11 +67,11 @@ class Metering {
67
67
  },
68
68
  model: metering.modelName,
69
69
  transactionId: (_r = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.transactionId) !== null && _r !== void 0 ? _r : (0, generateTransactionId_1.generateTransactionId)(),
70
- responseTime: (0, formatTimeStamp_1.formatTimestamp)(metering.endTime),
70
+ responseTime: (0, formatTimestamp_1.formatTimestamp)(metering.endTime),
71
71
  requestDuration: (0, calculateDurationMs_1.calculateDurationMs)(metering.startTime, metering.endTime),
72
72
  provider: agent,
73
- requestTime: (_t = (_s = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.requestTime) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : (0, formatTimeStamp_1.formatTimestamp)(metering.startTime),
74
- completionStartTime: (_v = (_u = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.completionStartTime) === null || _u === void 0 ? void 0 : _u.toString()) !== null && _v !== void 0 ? _v : (0, formatTimeStamp_1.formatTimestamp)(metering.endTime),
73
+ requestTime: (_t = (_s = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.requestTime) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : (0, formatTimestamp_1.formatTimestamp)(metering.startTime),
74
+ completionStartTime: (_v = (_u = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.completionStartTime) === null || _u === void 0 ? void 0 : _u.toString()) !== null && _v !== void 0 ? _v : (0, formatTimestamp_1.formatTimestamp)(metering.endTime),
75
75
  timeToFirstToken: (_w = usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.timeToFirstToken) !== null && _w !== void 0 ? _w : 0,
76
76
  middleware_source: utils_1.MIDDLEWARE_SOURCE,
77
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenium/perplexity",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "NodeJS middleware for perplexity's AI API",
5
5
  "homepage": "https://github.com/revenium/revenium-middleware-perplexity-node#readme",
6
6
  "bugs": {
@@ -17,6 +17,8 @@
17
17
  "p-basic": "npx ts-node playground/basic.js",
18
18
  "p-streaming": "npx ts-node playground/streaming.js",
19
19
  "p-enhanced": "npx ts-node playground/enhanced.js",
20
+ "p-chat-completions": "npx ts-node playground/chat-completions.js",
21
+ "p-metadata": "npx ts-node playground/metadata.js",
20
22
  "e-basic": "npx ts-node examples/basic.ts",
21
23
  "e-streaming": "npx ts-node examples/streaming.ts",
22
24
  "e-chat-completions": "npx ts-node examples/chat-completions.ts",
@@ -9,7 +9,7 @@ import {
9
9
  REVENIUM_METERING_BASE_URL,
10
10
  } from "../utils";
11
11
  import { calculateDurationMs } from "../utils/calculateDurationMs";
12
- import { formatTimestamp } from "../utils/formatTimeStamp";
12
+ import { formatTimestamp } from "../utils/formatTimestamp";
13
13
  import { generateTransactionId } from "../utils/generateTransactionId";
14
14
  import { logger } from "./Logger";
15
15