@lockllm/sdk 1.0.1 → 1.2.0
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/CHANGELOG.md +223 -5
- package/README.md +272 -40
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +56 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +132 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +127 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/scan.d.ts +20 -5
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +59 -5
- package/dist/scan.js.map +1 -1
- package/dist/scan.mjs +59 -5
- package/dist/types/common.d.ts +116 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/errors.d.ts +39 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/scan.d.ts +118 -3
- package/dist/types/scan.d.ts.map +1 -1
- package/dist/utils/proxy-headers.d.ts +24 -0
- package/dist/utils/proxy-headers.d.ts.map +1 -0
- package/dist/utils/proxy-headers.js +234 -0
- package/dist/utils/proxy-headers.js.map +1 -0
- package/dist/utils/proxy-headers.mjs +229 -0
- package/dist/utils.d.ts +24 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +27 -0
- package/dist/wrappers/anthropic-wrapper.d.ts +10 -1
- package/dist/wrappers/anthropic-wrapper.d.ts.map +1 -1
- package/dist/wrappers/anthropic-wrapper.js +17 -2
- package/dist/wrappers/anthropic-wrapper.js.map +1 -1
- package/dist/wrappers/anthropic-wrapper.mjs +17 -2
- package/dist/wrappers/generic-wrapper.d.ts +5 -0
- package/dist/wrappers/generic-wrapper.d.ts.map +1 -1
- package/dist/wrappers/generic-wrapper.js +12 -1
- package/dist/wrappers/generic-wrapper.js.map +1 -1
- package/dist/wrappers/generic-wrapper.mjs +12 -1
- package/dist/wrappers/openai-wrapper.d.ts +10 -1
- package/dist/wrappers/openai-wrapper.d.ts.map +1 -1
- package/dist/wrappers/openai-wrapper.js +17 -2
- package/dist/wrappers/openai-wrapper.js.map +1 -1
- package/dist/wrappers/openai-wrapper.mjs +17 -2
- package/package.json +2 -2
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* // With this:
|
|
14
14
|
* import { createAnthropic } from '@lockllm/sdk/wrappers';
|
|
15
15
|
* const anthropic = createAnthropic({
|
|
16
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
16
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
17
|
+
* proxyOptions: {
|
|
18
|
+
* scanMode: 'combined',
|
|
19
|
+
* scanAction: 'block'
|
|
20
|
+
* }
|
|
17
21
|
* });
|
|
18
22
|
*
|
|
19
23
|
* // Everything else stays the same!
|
|
@@ -24,6 +28,7 @@
|
|
|
24
28
|
* });
|
|
25
29
|
* ```
|
|
26
30
|
*/
|
|
31
|
+
import type { ProxyRequestOptions } from '../types/common';
|
|
27
32
|
export interface CreateAnthropicConfig {
|
|
28
33
|
/**
|
|
29
34
|
* Your LockLLM API key
|
|
@@ -35,6 +40,10 @@ export interface CreateAnthropicConfig {
|
|
|
35
40
|
* Override this only if you're using a custom LockLLM endpoint
|
|
36
41
|
*/
|
|
37
42
|
baseURL?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Proxy request options for scan, policy, abuse, and routing control
|
|
45
|
+
*/
|
|
46
|
+
proxyOptions?: ProxyRequestOptions;
|
|
38
47
|
/**
|
|
39
48
|
* Other Anthropic client options
|
|
40
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/anthropic-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"anthropic-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/anthropic-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,iBAAU,GAAG,GAAG,CAShE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,GAAG,CAwBlE"}
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* // With this:
|
|
15
15
|
* import { createAnthropic } from '@lockllm/sdk/wrappers';
|
|
16
16
|
* const anthropic = createAnthropic({
|
|
17
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
17
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
18
|
+
* proxyOptions: {
|
|
19
|
+
* scanMode: 'combined',
|
|
20
|
+
* scanAction: 'block'
|
|
21
|
+
* }
|
|
18
22
|
* });
|
|
19
23
|
*
|
|
20
24
|
* // Everything else stays the same!
|
|
@@ -28,6 +32,7 @@
|
|
|
28
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
33
|
exports.getAnthropicConstructor = getAnthropicConstructor;
|
|
30
34
|
exports.createAnthropic = createAnthropic;
|
|
35
|
+
const proxy_headers_1 = require("../utils/proxy-headers");
|
|
31
36
|
/**
|
|
32
37
|
* Create an Anthropic client that routes through LockLLM proxy
|
|
33
38
|
*
|
|
@@ -67,11 +72,21 @@ function getAnthropicConstructor(requireFn = require) {
|
|
|
67
72
|
function createAnthropic(config) {
|
|
68
73
|
// Get Anthropic SDK constructor
|
|
69
74
|
const AnthropicConstructor = getAnthropicConstructor();
|
|
70
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
75
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
76
|
+
// Build LockLLM headers from proxy options
|
|
77
|
+
const lockllmHeaders = (0, proxy_headers_1.buildLockLLMHeaders)(proxyOptions);
|
|
78
|
+
// Merge with existing headers
|
|
79
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
80
|
+
const mergedHeaders = {
|
|
81
|
+
...defaultHeaders,
|
|
82
|
+
...lockllmHeaders,
|
|
83
|
+
...(proxyOptions?.headers || {}),
|
|
84
|
+
};
|
|
71
85
|
// Create Anthropic client with LockLLM proxy
|
|
72
86
|
return new AnthropicConstructor({
|
|
73
87
|
apiKey,
|
|
74
88
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/anthropic',
|
|
89
|
+
defaultHeaders: mergedHeaders,
|
|
75
90
|
...otherOptions,
|
|
76
91
|
});
|
|
77
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/anthropic-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"anthropic-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/anthropic-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA0B7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAS,GAAG,OAAO;IACzD,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACvD,OAAO,eAAe,CAAC,OAAO,IAAI,eAAe,CAAC,SAAS,IAAI,eAAe,CAAC;IACjF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAA6B;IAC3D,gCAAgC;IAChC,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IAEvD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAElE,2CAA2C;IAC3C,MAAM,cAAc,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEzD,8BAA8B;IAC9B,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,EAAE,CAAC;IACzD,MAAM,aAAa,GAAG;QACpB,GAAG,cAAc;QACjB,GAAG,cAAc;QACjB,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC;KACjC,CAAC;IAEF,6CAA6C;IAC7C,OAAO,IAAI,oBAAoB,CAAC;QAC9B,MAAM;QACN,OAAO,EAAE,OAAO,IAAI,4CAA4C;QAChE,cAAc,EAAE,aAAa;QAC7B,GAAG,YAAY;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* // With this:
|
|
14
14
|
* import { createAnthropic } from '@lockllm/sdk/wrappers';
|
|
15
15
|
* const anthropic = createAnthropic({
|
|
16
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
16
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
17
|
+
* proxyOptions: {
|
|
18
|
+
* scanMode: 'combined',
|
|
19
|
+
* scanAction: 'block'
|
|
20
|
+
* }
|
|
17
21
|
* });
|
|
18
22
|
*
|
|
19
23
|
* // Everything else stays the same!
|
|
@@ -24,6 +28,7 @@
|
|
|
24
28
|
* });
|
|
25
29
|
* ```
|
|
26
30
|
*/
|
|
31
|
+
import { buildLockLLMHeaders } from '../utils/proxy-headers';
|
|
27
32
|
/**
|
|
28
33
|
* Create an Anthropic client that routes through LockLLM proxy
|
|
29
34
|
*
|
|
@@ -63,11 +68,21 @@ export function getAnthropicConstructor(requireFn = require) {
|
|
|
63
68
|
export function createAnthropic(config) {
|
|
64
69
|
// Get Anthropic SDK constructor
|
|
65
70
|
const AnthropicConstructor = getAnthropicConstructor();
|
|
66
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
71
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
72
|
+
// Build LockLLM headers from proxy options
|
|
73
|
+
const lockllmHeaders = buildLockLLMHeaders(proxyOptions);
|
|
74
|
+
// Merge with existing headers
|
|
75
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
76
|
+
const mergedHeaders = {
|
|
77
|
+
...defaultHeaders,
|
|
78
|
+
...lockllmHeaders,
|
|
79
|
+
...(proxyOptions?.headers || {}),
|
|
80
|
+
};
|
|
67
81
|
// Create Anthropic client with LockLLM proxy
|
|
68
82
|
return new AnthropicConstructor({
|
|
69
83
|
apiKey,
|
|
70
84
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/anthropic',
|
|
85
|
+
defaultHeaders: mergedHeaders,
|
|
71
86
|
...otherOptions,
|
|
72
87
|
});
|
|
73
88
|
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
import type { ProviderName } from '../types/providers';
|
|
23
|
+
import type { ProxyRequestOptions } from '../types/common';
|
|
23
24
|
export interface GenericClientConfig {
|
|
24
25
|
/**
|
|
25
26
|
* Your LockLLM API key
|
|
@@ -31,6 +32,10 @@ export interface GenericClientConfig {
|
|
|
31
32
|
* By default, uses LockLLM proxy URL for the provider
|
|
32
33
|
*/
|
|
33
34
|
baseURL?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Proxy request options for scan, policy, abuse, and routing control
|
|
37
|
+
*/
|
|
38
|
+
proxyOptions?: ProxyRequestOptions;
|
|
34
39
|
/**
|
|
35
40
|
* Other client-specific options
|
|
36
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/generic-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"generic-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/generic-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAClC,QAAQ,EAAE,YAAY,EACtB,iBAAiB,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,CAAC,EACzC,MAAM,EAAE,mBAAmB,GAC1B,CAAC,CAwBH;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,iBAAU,GAAG,GAAG,CASpE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,mBAAmB,GAC1B,GAAG,CAGL;AAED;;GAEG;AAEH;;GAEG;AACH,w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 -41,6 +41,7 @@ exports.createAzure = createAzure;
|
|
|
41
41
|
exports.createBedrock = createBedrock;
|
|
42
42
|
exports.createVertexAI = createVertexAI;
|
|
43
43
|
const utils_1 = require("../utils");
|
|
44
|
+
const proxy_headers_1 = require("../utils/proxy-headers");
|
|
44
45
|
/**
|
|
45
46
|
* Create a client for any provider using their official SDK
|
|
46
47
|
*
|
|
@@ -74,13 +75,23 @@ const utils_1 = require("../utils");
|
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
77
|
function createClient(provider, ClientConstructor, config) {
|
|
77
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
78
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
78
79
|
// Use provided baseURL or default to LockLLM proxy
|
|
79
80
|
const clientBaseURL = baseURL || (0, utils_1.getProxyURL)(provider);
|
|
81
|
+
// Build LockLLM headers from proxy options
|
|
82
|
+
const lockllmHeaders = (0, proxy_headers_1.buildLockLLMHeaders)(proxyOptions);
|
|
83
|
+
// Merge with existing headers
|
|
84
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
85
|
+
const mergedHeaders = {
|
|
86
|
+
...defaultHeaders,
|
|
87
|
+
...lockllmHeaders,
|
|
88
|
+
...(proxyOptions?.headers || {}),
|
|
89
|
+
};
|
|
80
90
|
// Create client with LockLLM proxy configuration
|
|
81
91
|
return new ClientConstructor({
|
|
82
92
|
apiKey,
|
|
83
93
|
baseURL: clientBaseURL,
|
|
94
|
+
defaultHeaders: mergedHeaders,
|
|
84
95
|
...otherOptions,
|
|
85
96
|
});
|
|
86
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/generic-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"generic-wrapper.js","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xyURL } from '../utils';
|
|
23
|
+
import { buildLockLLMHeaders } from '../utils/proxy-headers';
|
|
23
24
|
/**
|
|
24
25
|
* Create a client for any provider using their official SDK
|
|
25
26
|
*
|
|
@@ -53,13 +54,23 @@ import { getProxyURL } from '../utils';
|
|
|
53
54
|
* ```
|
|
54
55
|
*/
|
|
55
56
|
export function createClient(provider, ClientConstructor, config) {
|
|
56
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
57
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
57
58
|
// Use provided baseURL or default to LockLLM proxy
|
|
58
59
|
const clientBaseURL = baseURL || getProxyURL(provider);
|
|
60
|
+
// Build LockLLM headers from proxy options
|
|
61
|
+
const lockllmHeaders = buildLockLLMHeaders(proxyOptions);
|
|
62
|
+
// Merge with existing headers
|
|
63
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
64
|
+
const mergedHeaders = {
|
|
65
|
+
...defaultHeaders,
|
|
66
|
+
...lockllmHeaders,
|
|
67
|
+
...(proxyOptions?.headers || {}),
|
|
68
|
+
};
|
|
59
69
|
// Create client with LockLLM proxy configuration
|
|
60
70
|
return new ClientConstructor({
|
|
61
71
|
apiKey,
|
|
62
72
|
baseURL: clientBaseURL,
|
|
73
|
+
defaultHeaders: mergedHeaders,
|
|
63
74
|
...otherOptions,
|
|
64
75
|
});
|
|
65
76
|
}
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* // With this:
|
|
14
14
|
* import { createOpenAI } from '@lockllm/sdk/wrappers';
|
|
15
15
|
* const openai = createOpenAI({
|
|
16
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
16
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
17
|
+
* proxyOptions: {
|
|
18
|
+
* scanMode: 'combined',
|
|
19
|
+
* scanAction: 'block'
|
|
20
|
+
* }
|
|
17
21
|
* });
|
|
18
22
|
*
|
|
19
23
|
* // Everything else stays the same!
|
|
@@ -23,6 +27,7 @@
|
|
|
23
27
|
* });
|
|
24
28
|
* ```
|
|
25
29
|
*/
|
|
30
|
+
import type { ProxyRequestOptions } from '../types/common';
|
|
26
31
|
export interface CreateOpenAIConfig {
|
|
27
32
|
/**
|
|
28
33
|
* Your LockLLM API key
|
|
@@ -34,6 +39,10 @@ export interface CreateOpenAIConfig {
|
|
|
34
39
|
* Override this only if you're using a custom LockLLM endpoint
|
|
35
40
|
*/
|
|
36
41
|
baseURL?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Proxy request options for scan, policy, abuse, and routing control
|
|
44
|
+
*/
|
|
45
|
+
proxyOptions?: ProxyRequestOptions;
|
|
37
46
|
/**
|
|
38
47
|
* Other OpenAI client options
|
|
39
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"openai-wrapper.d.ts","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,iBAAU,GAAG,GAAG,CAS7D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,GAAG,CAwB5D"}
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* // With this:
|
|
15
15
|
* import { createOpenAI } from '@lockllm/sdk/wrappers';
|
|
16
16
|
* const openai = createOpenAI({
|
|
17
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
17
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
18
|
+
* proxyOptions: {
|
|
19
|
+
* scanMode: 'combined',
|
|
20
|
+
* scanAction: 'block'
|
|
21
|
+
* }
|
|
18
22
|
* });
|
|
19
23
|
*
|
|
20
24
|
* // Everything else stays the same!
|
|
@@ -27,6 +31,7 @@
|
|
|
27
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
32
|
exports.getOpenAIConstructor = getOpenAIConstructor;
|
|
29
33
|
exports.createOpenAI = createOpenAI;
|
|
34
|
+
const proxy_headers_1 = require("../utils/proxy-headers");
|
|
30
35
|
/**
|
|
31
36
|
* Create an OpenAI client that routes through LockLLM proxy
|
|
32
37
|
*
|
|
@@ -65,11 +70,21 @@ function getOpenAIConstructor(requireFn = require) {
|
|
|
65
70
|
function createOpenAI(config) {
|
|
66
71
|
// Get OpenAI SDK constructor
|
|
67
72
|
const OpenAIConstructor = getOpenAIConstructor();
|
|
68
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
73
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
74
|
+
// Build LockLLM headers from proxy options
|
|
75
|
+
const lockllmHeaders = (0, proxy_headers_1.buildLockLLMHeaders)(proxyOptions);
|
|
76
|
+
// Merge with existing headers
|
|
77
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
78
|
+
const mergedHeaders = {
|
|
79
|
+
...defaultHeaders,
|
|
80
|
+
...lockllmHeaders,
|
|
81
|
+
...(proxyOptions?.headers || {}),
|
|
82
|
+
};
|
|
69
83
|
// Create OpenAI client with LockLLM proxy
|
|
70
84
|
return new OpenAIConstructor({
|
|
71
85
|
apiKey,
|
|
72
86
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/openai',
|
|
87
|
+
defaultHeaders: mergedHeaders,
|
|
73
88
|
...otherOptions,
|
|
74
89
|
});
|
|
75
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"openai-wrapper.js","sourceRoot":"","sources":["../../src/wrappers/openai-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA0B7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAS,GAAG,OAAO;IACtD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;IAEjD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAElE,2CAA2C;IAC3C,MAAM,cAAc,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEzD,8BAA8B;IAC9B,MAAM,cAAc,GAAG,YAAY,CAAC,cAAc,IAAI,EAAE,CAAC;IACzD,MAAM,aAAa,GAAG;QACpB,GAAG,cAAc;QACjB,GAAG,cAAc;QACjB,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC;KACjC,CAAC;IAEF,0CAA0C;IAC1C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,MAAM;QACN,OAAO,EAAE,OAAO,IAAI,yCAAyC;QAC7D,cAAc,EAAE,aAAa;QAC7B,GAAG,YAAY;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* // With this:
|
|
14
14
|
* import { createOpenAI } from '@lockllm/sdk/wrappers';
|
|
15
15
|
* const openai = createOpenAI({
|
|
16
|
-
* apiKey: process.env.LOCKLLM_API_KEY
|
|
16
|
+
* apiKey: process.env.LOCKLLM_API_KEY,
|
|
17
|
+
* proxyOptions: {
|
|
18
|
+
* scanMode: 'combined',
|
|
19
|
+
* scanAction: 'block'
|
|
20
|
+
* }
|
|
17
21
|
* });
|
|
18
22
|
*
|
|
19
23
|
* // Everything else stays the same!
|
|
@@ -23,6 +27,7 @@
|
|
|
23
27
|
* });
|
|
24
28
|
* ```
|
|
25
29
|
*/
|
|
30
|
+
import { buildLockLLMHeaders } from '../utils/proxy-headers';
|
|
26
31
|
/**
|
|
27
32
|
* Create an OpenAI client that routes through LockLLM proxy
|
|
28
33
|
*
|
|
@@ -61,11 +66,21 @@ export function getOpenAIConstructor(requireFn = require) {
|
|
|
61
66
|
export function createOpenAI(config) {
|
|
62
67
|
// Get OpenAI SDK constructor
|
|
63
68
|
const OpenAIConstructor = getOpenAIConstructor();
|
|
64
|
-
const { apiKey, baseURL, ...otherOptions } = config;
|
|
69
|
+
const { apiKey, baseURL, proxyOptions, ...otherOptions } = config;
|
|
70
|
+
// Build LockLLM headers from proxy options
|
|
71
|
+
const lockllmHeaders = buildLockLLMHeaders(proxyOptions);
|
|
72
|
+
// Merge with existing headers
|
|
73
|
+
const defaultHeaders = otherOptions.defaultHeaders || {};
|
|
74
|
+
const mergedHeaders = {
|
|
75
|
+
...defaultHeaders,
|
|
76
|
+
...lockllmHeaders,
|
|
77
|
+
...(proxyOptions?.headers || {}),
|
|
78
|
+
};
|
|
65
79
|
// Create OpenAI client with LockLLM proxy
|
|
66
80
|
return new OpenAIConstructor({
|
|
67
81
|
apiKey,
|
|
68
82
|
baseURL: baseURL || 'https://api.lockllm.com/v1/proxy/openai',
|
|
83
|
+
defaultHeaders: mergedHeaders,
|
|
69
84
|
...otherOptions,
|
|
70
85
|
});
|
|
71
86
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lockllm/sdk",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Enterprise-grade AI security SDK providing real-time protection against prompt injection, jailbreaks, and adversarial attacks. Drop-in replacement for OpenAI, Anthropic, and
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Enterprise-grade AI security SDK providing real-time protection against prompt injection, jailbreaks, and adversarial attacks. Drop-in replacement for OpenAI, Anthropic, and 17+ providers with zero code changes. Includes REST API, proxy mode, browser extension, and webhook support. Free BYOK model with unlimited scanning.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|