@revenium/perplexity 2.0.6 → 2.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.
- package/.env.example +10 -0
- package/CHANGELOG.md +82 -113
- package/LICENSE +21 -21
- package/README.md +408 -292
- package/SECURITY.md +34 -34
- package/dist/cjs/core/config/index.js +0 -1
- package/dist/cjs/core/config/index.js.map +1 -1
- package/dist/cjs/core/config/manager.js +0 -1
- package/dist/cjs/core/config/manager.js.map +1 -1
- package/dist/cjs/core/providers/detector.js +0 -2
- package/dist/cjs/core/providers/detector.js.map +1 -1
- package/dist/cjs/core/providers/index.js +0 -1
- package/dist/cjs/core/providers/index.js.map +1 -1
- package/dist/cjs/index.js +1 -34
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/stop-reason-mapper.js +18 -20
- package/dist/cjs/utils/stop-reason-mapper.js.map +1 -1
- package/dist/esm/core/config/index.js +3 -4
- package/dist/esm/core/config/index.js.map +1 -1
- package/dist/esm/core/config/manager.js +0 -1
- package/dist/esm/core/config/manager.js.map +1 -1
- package/dist/esm/core/providers/detector.js +0 -2
- package/dist/esm/core/providers/detector.js.map +1 -1
- package/dist/esm/core/providers/index.js +0 -1
- package/dist/esm/core/providers/index.js.map +1 -1
- package/dist/esm/index.js +1 -34
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/stop-reason-mapper.js +18 -20
- package/dist/esm/utils/stop-reason-mapper.js.map +1 -1
- package/dist/types/core/config/index.d.ts +3 -4
- package/dist/types/core/config/index.d.ts.map +1 -1
- package/dist/types/core/config/manager.d.ts +0 -1
- package/dist/types/core/config/manager.d.ts.map +1 -1
- package/dist/types/core/providers/detector.d.ts +0 -2
- package/dist/types/core/providers/detector.d.ts.map +1 -1
- package/dist/types/core/providers/index.d.ts +0 -1
- package/dist/types/core/providers/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -32
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/stop-reason-mapper.d.ts +1 -3
- package/dist/types/utils/stop-reason-mapper.d.ts.map +1 -1
- package/examples/README.md +274 -226
- package/examples/advanced.ts +123 -123
- package/examples/basic.ts +45 -45
- package/examples/getting_started.ts +41 -41
- package/examples/metadata.ts +68 -68
- package/examples/stream.ts +53 -53
- package/package.json +80 -72
package/SECURITY.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Reporting a Vulnerability
|
|
4
|
-
|
|
5
|
-
If you discover a security vulnerability in this package, please report it to us.
|
|
6
|
-
|
|
7
|
-
**DO NOT** create a public GitHub issue for security vulnerabilities.
|
|
8
|
-
|
|
9
|
-
### How to Report
|
|
10
|
-
|
|
11
|
-
Email: support@revenium.io
|
|
12
|
-
|
|
13
|
-
Please include:
|
|
14
|
-
- Package name and version
|
|
15
|
-
- Description of the vulnerability
|
|
16
|
-
- Steps to reproduce (if applicable)
|
|
17
|
-
- Potential impact
|
|
18
|
-
- Suggested fix (if available)
|
|
19
|
-
|
|
20
|
-
We will review and respond to security reports in a timely manner.
|
|
21
|
-
|
|
22
|
-
## Security Best Practices
|
|
23
|
-
|
|
24
|
-
When using this middleware:
|
|
25
|
-
|
|
26
|
-
1. **API Keys**: Never commit API keys to version control
|
|
27
|
-
2. **Environment Variables**: Use environment variables for sensitive configuration
|
|
28
|
-
3. **PII Handling**: Ensure no PII is sent to Revenium unless explicitly configured for billing purposes
|
|
29
|
-
4. **Network Security**: Always use HTTPS connections
|
|
30
|
-
5. **Updates**: Keep the package updated to the latest version
|
|
31
|
-
|
|
32
|
-
## Additional Resources
|
|
33
|
-
|
|
34
|
-
- [Revenium Documentation](https://docs.revenium.io)
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
If you discover a security vulnerability in this package, please report it to us.
|
|
6
|
+
|
|
7
|
+
**DO NOT** create a public GitHub issue for security vulnerabilities.
|
|
8
|
+
|
|
9
|
+
### How to Report
|
|
10
|
+
|
|
11
|
+
Email: support@revenium.io
|
|
12
|
+
|
|
13
|
+
Please include:
|
|
14
|
+
- Package name and version
|
|
15
|
+
- Description of the vulnerability
|
|
16
|
+
- Steps to reproduce (if applicable)
|
|
17
|
+
- Potential impact
|
|
18
|
+
- Suggested fix (if available)
|
|
19
|
+
|
|
20
|
+
We will review and respond to security reports in a timely manner.
|
|
21
|
+
|
|
22
|
+
## Security Best Practices
|
|
23
|
+
|
|
24
|
+
When using this middleware:
|
|
25
|
+
|
|
26
|
+
1. **API Keys**: Never commit API keys to version control
|
|
27
|
+
2. **Environment Variables**: Use environment variables for sensitive configuration
|
|
28
|
+
3. **PII Handling**: Ensure no PII is sent to Revenium unless explicitly configured for billing purposes
|
|
29
|
+
4. **Network Security**: Always use HTTPS connections
|
|
30
|
+
5. **Updates**: Keep the package updated to the latest version
|
|
31
|
+
|
|
32
|
+
## Additional Resources
|
|
33
|
+
|
|
34
|
+
- [Revenium Documentation](https://docs.revenium.io)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Configuration module - Main exports
|
|
4
4
|
*
|
|
5
5
|
* This module provides a clean interface for configuration management.
|
|
6
|
-
* Aligned with OpenAI modular implementation.
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
exports.defaultLogger = exports.initializeConfig = exports.getLogger = exports.setConfig = exports.getConfig = exports.validateConfig = exports.loadConfigFromEnv = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,4CAA4C;AAC5C,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAE1B,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AAEvB,2CAMsB;AALpB,uGAAA,SAAS,OAAA;AACT,uGAAA,SAAS,OAAA;AACT,uGAAA,SAAS,OAAA;AACT,8GAAA,gBAAgB,OAAA;AAChB,2GAAA,aAAa,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAoCH,8BAEC;AAKD,8BAQC;AAKD,8BAEC;AAKD,4CAkBC;AA9ED,2CAAgD;AAChD,iDAAgD;AAEhD;;GAEG;AACH,IAAI,YAAY,GAA0B,IAAI,CAAC;AAE/C;;GAEG;AACU,QAAA,aAAa,GAAW;IACnC,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC7C,IAAI,YAAY,EAAE,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YACjE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC7C,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;CACF,CAAC;AAEF,IAAI,YAAY,GAAW,qBAAa,CAAC;AAEzC;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,MAAsB;IAC9C,IAAA,6BAAc,EAAC,MAAM,CAAC,CAAC;IACvB,YAAY,GAAG,MAAM,CAAC;IACtB,YAAY,CAAC,KAAK,CAAC,gCAAgC,EAAE;QACnD,OAAO,EAAE,MAAM,CAAC,eAAe;QAC/B,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc;QACvC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,gBAAgB;KAC5C,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,SAAS,GAAG,IAAA,6BAAiB,GAAE,CAAC;IAEtC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,YAAY,CAAC,KAAK,CAChB,iHAAiH,CAClH,CAAC;QACF,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,SAAS,CAAC,CAAC;IACrB,YAAY,CAAC,KAAK,CAChB,4DAA4D,CAC7D,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Provider Detection Module
|
|
4
4
|
*
|
|
5
5
|
* Handles provider metadata for Perplexity AI.
|
|
6
|
-
* Simplified compared to OpenAI modular since Perplexity doesn't have Azure variant.
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
exports.detectProvider = detectProvider;
|
|
@@ -13,7 +12,6 @@ const index_js_1 = require("../config/index.js");
|
|
|
13
12
|
const logger = (0, index_js_1.getLogger)();
|
|
14
13
|
/**
|
|
15
14
|
* Get provider info for Perplexity
|
|
16
|
-
* Always returns Perplexity since there's no Azure variant
|
|
17
15
|
*
|
|
18
16
|
* @returns ProviderInfo with Perplexity provider
|
|
19
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAaH,wCAMC;AAOD,kDAQC;AA/BD,iDAA+C;AAE/C,gBAAgB;AAChB,MAAM,MAAM,GAAG,IAAA,oBAAS,GAAE,CAAC;AAE3B;;;;GAIG;AACH,SAAgB,cAAc;IAC5B,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7C,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,YAAY;KAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB;IAIjC,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,YAAY;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Providers module - Main exports
|
|
4
4
|
*
|
|
5
5
|
* This module provides a clean interface for provider detection and management.
|
|
6
|
-
* Simplified for Perplexity (no Azure variant).
|
|
7
6
|
*/
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
exports.getProviderMetadata = exports.detectProvider = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAuC;AACvC,6CAAoE;AAA3D,6GAAA,cAAc,OAAA;AAAE,kHAAA,mBAAmB,OAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,41 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Revenium Perplexity Middleware for TypeScript
|
|
4
|
-
*
|
|
5
|
-
* This middleware tracks Perplexity AI usage and sends metrics to Revenium.
|
|
6
|
-
* Uses Go-aligned API pattern with Initialize/GetClient.
|
|
7
|
-
*
|
|
8
|
-
* Environment Variables:
|
|
9
|
-
* REVENIUM_METERING_API_KEY=hak_your_api_key
|
|
10
|
-
* REVENIUM_METERING_BASE_URL=https://api.revenium.ai (optional)
|
|
11
|
-
* PERPLEXITY_API_KEY=pplx_your_perplexity_key
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* import { Initialize, GetClient } from "@revenium/perplexity";
|
|
15
|
-
*
|
|
16
|
-
* // Initialize from environment
|
|
17
|
-
* Initialize();
|
|
18
|
-
*
|
|
19
|
-
* // Get client
|
|
20
|
-
* const client = GetClient();
|
|
21
|
-
*
|
|
22
|
-
* // Use client
|
|
23
|
-
* const response = await client.chat().completions().create({
|
|
24
|
-
* model: "sonar",
|
|
25
|
-
* messages: [{ role: "user", content: "Hello!" }]
|
|
26
|
-
* }, {
|
|
27
|
-
* organizationId: "my-org",
|
|
28
|
-
* productId: "my-app",
|
|
29
|
-
* subscriber: {
|
|
30
|
-
* id: "user-123",
|
|
31
|
-
* email: "user@my-org.com"
|
|
32
|
-
* }
|
|
33
|
-
* });
|
|
34
|
-
*/
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getProviderMetadata = exports.detectProvider = exports.trackUsageAsync = exports.StreamingWrapper = exports.CompletionsInterface = exports.ChatInterface = exports.ReveniumPerplexity = exports.Configure = exports.Reset = exports.IsInitialized = exports.GetClient = exports.Initialize = void 0;
|
|
37
4
|
/**
|
|
38
|
-
* Main API
|
|
5
|
+
* Main API
|
|
39
6
|
*/
|
|
40
7
|
var index_js_1 = require("./core/client/index.js");
|
|
41
8
|
Object.defineProperty(exports, "Initialize", { enumerable: true, get: function () { return index_js_1.Initialize; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA+BA;;GAEG;AACH,mDAMgC;AAL9B,sGAAA,UAAU,OAAA;AACV,qGAAA,SAAS,OAAA;AACT,yGAAA,aAAa,OAAA;AACb,iGAAA,KAAK,OAAA;AACL,qGAAA,SAAS,OAAA;AAGX;;GAEG;AACH,uDAKoC;AAJlC,8GAAA,kBAAkB,OAAA;AAClB,yGAAA,aAAa,OAAA;AACb,gHAAA,oBAAoB,OAAA;AACpB,4GAAA,gBAAgB,OAAA;AAGlB;;GAEG;AACH,qDAA2D;AAAlD,2GAAA,eAAe,OAAA;AAExB;;GAEG;AACH,sDAAgF;AAAvE,0GAAA,cAAc,OAAA;AAAE,+GAAA,mBAAmB,OAAA"}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Stop Reason Mapper Utilities
|
|
4
4
|
*
|
|
5
5
|
* Centralized stop reason mapping logic using lookup tables
|
|
6
|
-
* instead of nested conditionals.
|
|
7
|
-
* from the anthropic-node middleware.
|
|
6
|
+
* instead of nested conditionals.
|
|
8
7
|
*/
|
|
9
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
9
|
exports.mapStopReason = mapStopReason;
|
|
@@ -15,33 +14,32 @@ exports.isStopReasonSupported = isStopReasonSupported;
|
|
|
15
14
|
* Maps provider-specific stop reasons to Revenium's standardized set
|
|
16
15
|
*/
|
|
17
16
|
const STOP_REASON_MAP = {
|
|
18
|
-
// OpenAI
|
|
19
|
-
stop:
|
|
20
|
-
function_call:
|
|
21
|
-
tool_calls:
|
|
22
|
-
timeout:
|
|
23
|
-
length:
|
|
24
|
-
max_tokens:
|
|
25
|
-
cost_limit:
|
|
26
|
-
completion_limit:
|
|
27
|
-
content_filter:
|
|
28
|
-
error:
|
|
29
|
-
cancelled:
|
|
30
|
-
canceled:
|
|
17
|
+
// OpenAI OpenAI stop reasons
|
|
18
|
+
stop: "END",
|
|
19
|
+
function_call: "END_SEQUENCE",
|
|
20
|
+
tool_calls: "END_SEQUENCE",
|
|
21
|
+
timeout: "TIMEOUT",
|
|
22
|
+
length: "TOKEN_LIMIT",
|
|
23
|
+
max_tokens: "TOKEN_LIMIT",
|
|
24
|
+
cost_limit: "COST_LIMIT",
|
|
25
|
+
completion_limit: "COMPLETION_LIMIT",
|
|
26
|
+
content_filter: "ERROR",
|
|
27
|
+
error: "ERROR",
|
|
28
|
+
cancelled: "CANCELLED",
|
|
29
|
+
canceled: "CANCELLED", // Handle both spellings
|
|
31
30
|
// Anthropic stop reasons (for consistency across middleware)
|
|
32
|
-
end_turn:
|
|
33
|
-
stop_sequence:
|
|
34
|
-
tool_use:
|
|
31
|
+
end_turn: "END",
|
|
32
|
+
stop_sequence: "END_SEQUENCE",
|
|
33
|
+
tool_use: "END_SEQUENCE",
|
|
35
34
|
};
|
|
36
35
|
/**
|
|
37
36
|
* Default stop reason when mapping fails
|
|
38
37
|
*/
|
|
39
|
-
const DEFAULT_STOP_REASON =
|
|
38
|
+
const DEFAULT_STOP_REASON = "END";
|
|
40
39
|
/**
|
|
41
40
|
* Map provider stop reasons to Revenium stop reasons
|
|
42
41
|
*
|
|
43
42
|
* This replaces the nested if/switch logic with a clean lookup table approach.
|
|
44
|
-
* Based on the good example from the anthropic-node middleware.
|
|
45
43
|
*
|
|
46
44
|
* @param providerStopReason - Stop reason from the AI provider
|
|
47
45
|
* @param logger - Optional logger for warnings about unknown reasons
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop-reason-mapper.js","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"stop-reason-mapper.js","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAyCH,sCAiBC;AAKD,0DAEC;AAKD,sDAEC;AAtED;;;GAGG;AACH,MAAM,eAAe,GAA2B;IAC9C,6BAA6B;IAC7B,IAAI,EAAE,KAAK;IACX,aAAa,EAAE,cAAc;IAC7B,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,YAAY;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,OAAO;IACvB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,WAAW,EAAE,wBAAwB;IAE/C,6DAA6D;IAC7D,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,cAAc;IAC7B,QAAQ,EAAE,cAAc;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAElC;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAC3B,kBAA6C,EAC7C,MAA4D;IAE5D,IAAI,CAAC,kBAAkB;QAAE,OAAO,mBAAmB,CAAC;IACpD,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAEvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,mEAAmE;QACnE,MAAM,EAAE,IAAI,CACV,wBAAwB,kBAAkB,gBAAgB,mBAAmB,EAAE,CAChF,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,MAAc;IAClD,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,eAAe,CAAC;AACjD,CAAC"}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Configuration module - Main exports
|
|
3
3
|
*
|
|
4
4
|
* This module provides a clean interface for configuration management.
|
|
5
|
-
* Aligned with OpenAI modular implementation.
|
|
6
5
|
*/
|
|
7
6
|
// Re-export all configuration functionality
|
|
8
|
-
export { loadConfigFromEnv } from
|
|
9
|
-
export { validateConfig } from
|
|
10
|
-
export { getConfig, setConfig, getLogger, initializeConfig, defaultLogger, } from
|
|
7
|
+
export { loadConfigFromEnv } from "./loader.js";
|
|
8
|
+
export { validateConfig } from "./validator.js";
|
|
9
|
+
export { getConfig, setConfig, getLogger, initializeConfig, defaultLogger, } from "./manager.js";
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4CAA4C;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,aAAa,GACd,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,IAAI,YAAY,GAA0B,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC7C,IAAI,YAAY,EAAE,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YACjE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE;QAC7C,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;CACF,CAAC;AAEF,IAAI,YAAY,GAAW,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,YAAY,GAAG,MAAM,CAAC;IACtB,YAAY,CAAC,KAAK,CAAC,gCAAgC,EAAE;QACnD,OAAO,EAAE,MAAM,CAAC,eAAe;QAC/B,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc;QACvC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,gBAAgB;KAC5C,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC;IAEtC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,YAAY,CAAC,KAAK,CAChB,iHAAiH,CAClH,CAAC;QACF,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,SAAS,CAAC,CAAC;IACrB,YAAY,CAAC,KAAK,CAChB,4DAA4D,CAC7D,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* Provider Detection Module
|
|
3
3
|
*
|
|
4
4
|
* Handles provider metadata for Perplexity AI.
|
|
5
|
-
* Simplified compared to OpenAI modular since Perplexity doesn't have Azure variant.
|
|
6
5
|
*/
|
|
7
6
|
import { getLogger } from "../config/index.js";
|
|
8
7
|
// Global logger
|
|
9
8
|
const logger = getLogger();
|
|
10
9
|
/**
|
|
11
10
|
* Get provider info for Perplexity
|
|
12
|
-
* Always returns Perplexity since there's no Azure variant
|
|
13
11
|
*
|
|
14
12
|
* @returns ProviderInfo with Perplexity provider
|
|
15
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,gBAAgB;AAChB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAE3B;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC7C,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,YAAY;KAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IAIjC,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,WAAW,EAAE,YAAY;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Providers module - Main exports
|
|
3
3
|
*
|
|
4
4
|
* This module provides a clean interface for provider detection and management.
|
|
5
|
-
* Simplified for Perplexity (no Azure variant).
|
|
6
5
|
*/
|
|
7
6
|
// Re-export all provider functionality
|
|
8
7
|
export { detectProvider, getProviderMetadata } from "./detector.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This middleware tracks Perplexity AI usage and sends metrics to Revenium.
|
|
5
|
-
* Uses Go-aligned API pattern with Initialize/GetClient.
|
|
6
|
-
*
|
|
7
|
-
* Environment Variables:
|
|
8
|
-
* REVENIUM_METERING_API_KEY=hak_your_api_key
|
|
9
|
-
* REVENIUM_METERING_BASE_URL=https://api.revenium.ai (optional)
|
|
10
|
-
* PERPLEXITY_API_KEY=pplx_your_perplexity_key
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* import { Initialize, GetClient } from "@revenium/perplexity";
|
|
14
|
-
*
|
|
15
|
-
* // Initialize from environment
|
|
16
|
-
* Initialize();
|
|
17
|
-
*
|
|
18
|
-
* // Get client
|
|
19
|
-
* const client = GetClient();
|
|
20
|
-
*
|
|
21
|
-
* // Use client
|
|
22
|
-
* const response = await client.chat().completions().create({
|
|
23
|
-
* model: "sonar",
|
|
24
|
-
* messages: [{ role: "user", content: "Hello!" }]
|
|
25
|
-
* }, {
|
|
26
|
-
* organizationId: "my-org",
|
|
27
|
-
* productId: "my-app",
|
|
28
|
-
* subscriber: {
|
|
29
|
-
* id: "user-123",
|
|
30
|
-
* email: "user@my-org.com"
|
|
31
|
-
* }
|
|
32
|
-
* });
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* Main API - Go-aligned pattern
|
|
2
|
+
* Main API
|
|
36
3
|
*/
|
|
37
4
|
export { Initialize, GetClient, IsInitialized, Reset, Configure, } from "./core/client/index.js";
|
|
38
5
|
/**
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,KAAK,EACL,SAAS,GACV,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -2,41 +2,39 @@
|
|
|
2
2
|
* Stop Reason Mapper Utilities
|
|
3
3
|
*
|
|
4
4
|
* Centralized stop reason mapping logic using lookup tables
|
|
5
|
-
* instead of nested conditionals.
|
|
6
|
-
* from the anthropic-node middleware.
|
|
5
|
+
* instead of nested conditionals.
|
|
7
6
|
*/
|
|
8
7
|
/**
|
|
9
8
|
* Stop reason mapping configuration
|
|
10
9
|
* Maps provider-specific stop reasons to Revenium's standardized set
|
|
11
10
|
*/
|
|
12
11
|
const STOP_REASON_MAP = {
|
|
13
|
-
// OpenAI
|
|
14
|
-
stop:
|
|
15
|
-
function_call:
|
|
16
|
-
tool_calls:
|
|
17
|
-
timeout:
|
|
18
|
-
length:
|
|
19
|
-
max_tokens:
|
|
20
|
-
cost_limit:
|
|
21
|
-
completion_limit:
|
|
22
|
-
content_filter:
|
|
23
|
-
error:
|
|
24
|
-
cancelled:
|
|
25
|
-
canceled:
|
|
12
|
+
// OpenAI OpenAI stop reasons
|
|
13
|
+
stop: "END",
|
|
14
|
+
function_call: "END_SEQUENCE",
|
|
15
|
+
tool_calls: "END_SEQUENCE",
|
|
16
|
+
timeout: "TIMEOUT",
|
|
17
|
+
length: "TOKEN_LIMIT",
|
|
18
|
+
max_tokens: "TOKEN_LIMIT",
|
|
19
|
+
cost_limit: "COST_LIMIT",
|
|
20
|
+
completion_limit: "COMPLETION_LIMIT",
|
|
21
|
+
content_filter: "ERROR",
|
|
22
|
+
error: "ERROR",
|
|
23
|
+
cancelled: "CANCELLED",
|
|
24
|
+
canceled: "CANCELLED", // Handle both spellings
|
|
26
25
|
// Anthropic stop reasons (for consistency across middleware)
|
|
27
|
-
end_turn:
|
|
28
|
-
stop_sequence:
|
|
29
|
-
tool_use:
|
|
26
|
+
end_turn: "END",
|
|
27
|
+
stop_sequence: "END_SEQUENCE",
|
|
28
|
+
tool_use: "END_SEQUENCE",
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
32
31
|
* Default stop reason when mapping fails
|
|
33
32
|
*/
|
|
34
|
-
const DEFAULT_STOP_REASON =
|
|
33
|
+
const DEFAULT_STOP_REASON = "END";
|
|
35
34
|
/**
|
|
36
35
|
* Map provider stop reasons to Revenium stop reasons
|
|
37
36
|
*
|
|
38
37
|
* This replaces the nested if/switch logic with a clean lookup table approach.
|
|
39
|
-
* Based on the good example from the anthropic-node middleware.
|
|
40
38
|
*
|
|
41
39
|
* @param providerStopReason - Stop reason from the AI provider
|
|
42
40
|
* @param logger - Optional logger for warnings about unknown reasons
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop-reason-mapper.js","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stop-reason-mapper.js","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,eAAe,GAA2B;IAC9C,6BAA6B;IAC7B,IAAI,EAAE,KAAK;IACX,aAAa,EAAE,cAAc;IAC7B,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,YAAY;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,OAAO;IACvB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,WAAW,EAAE,wBAAwB;IAE/C,6DAA6D;IAC7D,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,cAAc;IAC7B,QAAQ,EAAE,cAAc;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,kBAA6C,EAC7C,MAA4D;IAE5D,IAAI,CAAC,kBAAkB;QAAE,OAAO,mBAAmB,CAAC;IACpD,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAEvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,mEAAmE;QACnE,MAAM,EAAE,IAAI,CACV,wBAAwB,kBAAkB,gBAAgB,mBAAmB,EAAE,CAChF,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,eAAe,CAAC;AACjD,CAAC"}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Configuration module - Main exports
|
|
3
3
|
*
|
|
4
4
|
* This module provides a clean interface for configuration management.
|
|
5
|
-
* Aligned with OpenAI modular implementation.
|
|
6
5
|
*/
|
|
7
|
-
export { loadConfigFromEnv } from
|
|
8
|
-
export { validateConfig } from
|
|
9
|
-
export { getConfig, setConfig, getLogger, initializeConfig, defaultLogger, } from
|
|
6
|
+
export { loadConfigFromEnv } from "./loader.js";
|
|
7
|
+
export { validateConfig } from "./validator.js";
|
|
8
|
+
export { getConfig, setConfig, getLogger, initializeConfig, defaultLogger, } from "./manager.js";
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,aAAa,GACd,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/core/config/manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAe3B,CAAC;AAIF;;GAEG;AACH,wBAAgB,SAAS,IAAI,cAAc,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAQtD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,CAkBjD"}
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
* Provider Detection Module
|
|
3
3
|
*
|
|
4
4
|
* Handles provider metadata for Perplexity AI.
|
|
5
|
-
* Simplified compared to OpenAI modular since Perplexity doesn't have Azure variant.
|
|
6
5
|
*/
|
|
7
6
|
import { ProviderInfo } from "../../types/index.js";
|
|
8
7
|
/**
|
|
9
8
|
* Get provider info for Perplexity
|
|
10
|
-
* Always returns Perplexity since there's no Azure variant
|
|
11
9
|
*
|
|
12
10
|
* @returns ProviderInfo with Perplexity provider
|
|
13
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../../src/core/providers/detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMpD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,YAAY,CAM7C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAKA"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Providers module - Main exports
|
|
3
3
|
*
|
|
4
4
|
* This module provides a clean interface for provider detection and management.
|
|
5
|
-
* Simplified for Perplexity (no Azure variant).
|
|
6
5
|
*/
|
|
7
6
|
export { detectProvider, getProviderMetadata } from "./detector.js";
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Revenium Perplexity Middleware for TypeScript
|
|
3
|
-
|
|
4
|
-
* This middleware tracks Perplexity AI usage and sends metrics to Revenium.
|
|
5
|
-
* Uses Go-aligned API pattern with Initialize/GetClient.
|
|
6
|
-
*
|
|
7
|
-
* Environment Variables:
|
|
8
|
-
* REVENIUM_METERING_API_KEY=hak_your_api_key
|
|
9
|
-
* REVENIUM_METERING_BASE_URL=https://api.revenium.ai (optional)
|
|
10
|
-
* PERPLEXITY_API_KEY=pplx_your_perplexity_key
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* import { Initialize, GetClient } from "@revenium/perplexity";
|
|
14
|
-
*
|
|
15
|
-
* // Initialize from environment
|
|
16
|
-
* Initialize();
|
|
17
|
-
*
|
|
18
|
-
* // Get client
|
|
19
|
-
* const client = GetClient();
|
|
20
|
-
*
|
|
21
|
-
* // Use client
|
|
22
|
-
* const response = await client.chat().completions().create({
|
|
23
|
-
* model: "sonar",
|
|
24
|
-
* messages: [{ role: "user", content: "Hello!" }]
|
|
25
|
-
* }, {
|
|
26
|
-
* organizationId: "my-org",
|
|
27
|
-
* productId: "my-app",
|
|
28
|
-
* subscriber: {
|
|
29
|
-
* id: "user-123",
|
|
30
|
-
* email: "user@my-org.com"
|
|
31
|
-
* }
|
|
32
|
-
* });
|
|
33
|
-
*/
|
|
3
|
+
|
|
34
4
|
/**
|
|
35
5
|
* Core types for TypeScript developers using Revenium middleware
|
|
36
6
|
*/
|
|
@@ -40,7 +10,7 @@ export type { ReveniumConfig, UsageMetadata, Logger, ProviderInfo, Subscriber, C
|
|
|
40
10
|
*/
|
|
41
11
|
export type { PerplexityChatRequest, PerplexityChatResponse, PerplexityMessage, PerplexityChoice, PerplexityUsage, PerplexityStreamChunk, PerplexityResponse, TrackingData, } from "./types/function-parameters.js";
|
|
42
12
|
/**
|
|
43
|
-
* Main API
|
|
13
|
+
* Main API
|
|
44
14
|
*/
|
|
45
15
|
export { Initialize, GetClient, IsInitialized, Reset, Configure, } from "./core/client/index.js";
|
|
46
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EACV,cAAc,EACd,aAAa,EACb,MAAM,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,GACb,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,KAAK,EACL,SAAS,GACV,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* Stop Reason Mapper Utilities
|
|
3
3
|
*
|
|
4
4
|
* Centralized stop reason mapping logic using lookup tables
|
|
5
|
-
* instead of nested conditionals.
|
|
6
|
-
* from the anthropic-node middleware.
|
|
5
|
+
* instead of nested conditionals.
|
|
7
6
|
*/
|
|
8
7
|
/**
|
|
9
8
|
* Map provider stop reasons to Revenium stop reasons
|
|
10
9
|
*
|
|
11
10
|
* This replaces the nested if/switch logic with a clean lookup table approach.
|
|
12
|
-
* Based on the good example from the anthropic-node middleware.
|
|
13
11
|
*
|
|
14
12
|
* @param providerStopReason - Stop reason from the AI provider
|
|
15
13
|
* @param logger - Optional logger for warnings about unknown reasons
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop-reason-mapper.d.ts","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stop-reason-mapper.d.ts","sourceRoot":"","sources":["../../../src/utils/stop-reason-mapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7C,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAAE,GAC3D,MAAM,CAcR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,EAAE,CAElD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|